AutoCloseable
, BitsPerSampleAccessor
, BitsPerSampleAccessor.BitsPerSampleBuilder<WavSoundSampleWriter>
, BitsPerSampleAccessor.BitsPerSampleMutator
, BitsPerSampleAccessor.BitsPerSampleProperty
, SampleWriter<SoundSample,B>
, SamplingRateAccessor
, SamplingRateAccessor.SamplingRateBuilder<WavSoundSampleWriter>
, SamplingRateAccessor.SamplingRateMutator
, SamplingRateAccessor.SamplingRateProperty
, SoundSampleWriter<WavSoundSampleWriter>
, WavSampleWriter<SoundSample,B>
, org.refcodes.io.RowWriter<WavSoundSampleWriter>
public class WavSoundSampleWriter extends AbstractWavSampleWriter<SoundSample,WavSoundSampleWriter> implements SoundSampleWriter<WavSoundSampleWriter>
WavSoundSampleWriter
provides means to write sound samples to a
WAV file. Information on the WAV file format has been taken from the
following article:
"https://web.archive.org/web/20120113025807/http://technology.niagarac.on.ca:80/courses/ctec1631/WavFileFormat.html".BitsPerSampleAccessor.BitsPerSampleBuilder<B extends BitsPerSampleAccessor.BitsPerSampleBuilder<B>>, BitsPerSampleAccessor.BitsPerSampleMutator, BitsPerSampleAccessor.BitsPerSampleProperty
SamplingRateAccessor.SamplingRateBuilder<B extends SamplingRateAccessor.SamplingRateBuilder<B>>, SamplingRateAccessor.SamplingRateMutator, SamplingRateAccessor.SamplingRateProperty
_bitsPerSample, _file, _outputStream, DATA, FORMAT, MAX_16_BIT, MAX_8_BIT, RIFF, WAVE
Constructor | Description |
---|---|
WavSoundSampleWriter(File aFile) |
Constructs the
WavSoundSampleWriter for writing sound samples to
a WAV file or stream. |
WavSoundSampleWriter(OutputStream aOutputStream) |
Constructs the
WavSoundSampleWriter for writing sound samples to
a WAV file or stream. |
Modifier and Type | Method | Description |
---|---|---|
int |
getSamplingRate() |
Retrieves the sampling rate from the sampling rate property.
|
void |
setSamplingRate(int aSamplingRate) |
Sets the sampling rate for the sampling rate property.
|
WavSoundSampleWriter |
withBitsPerSample(BitsPerSample aBitsPerSample) |
Sets the bits/sample per channel for the bits/sample per channel
property.
|
WavSoundSampleWriter |
withSamplingRate(int aSamplingRate) |
Sets the sampling rate for the sampling rate property.
|
void |
writeNext(double... aSampleData) |
Writes the next samples, one sample for each channel.
|
void |
writeNext(SoundSample aSample) |
Writes the next samples, one sample for each channel.
|
close, getBitsPerSample, setBitsPerSample, toWavSample, writeHeader
letBitsPerSample
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close
letSamplingRate
public WavSoundSampleWriter(File aFile) throws FileNotFoundException
WavSoundSampleWriter
for writing sound samples to
a WAV file or stream.aFile
- The File
where to write the CSV records to.FileNotFoundException
- If the given file object does not denote an
existing, writable regular file and a new regular file of that
name cannot be created, or if some other error occurs while
opening or creating the file.public WavSoundSampleWriter(OutputStream aOutputStream)
WavSoundSampleWriter
for writing sound samples to
a WAV file or stream.aOutputStream
- The OutputStream
where to write the CSV
records to.public WavSoundSampleWriter withBitsPerSample(BitsPerSample aBitsPerSample)
withBitsPerSample
in interface BitsPerSampleAccessor.BitsPerSampleBuilder<WavSoundSampleWriter>
aBitsPerSample
- The bits/sample per channel to be stored by the
sampling rate property.public void writeNext(double... aSampleData) throws IOException
writeNext
in interface SoundSampleWriter<WavSoundSampleWriter>
aSampleData
- The samples, one for each channel.IOException
- thrown in case writing the sample caused an I/O
related problem.public void writeNext(SoundSample aSample) throws IOException
writeNext
in interface org.refcodes.io.RowWriter<WavSoundSampleWriter>
writeNext
in interface SampleWriter<SoundSample,B extends SoundSampleWriter<B>>
writeNext
in interface SoundSampleWriter<WavSoundSampleWriter>
aSample
- The samples, one for each channel.IOException
- thrown in case writing the sample caused an I/O
related problem.public int getSamplingRate()
getSamplingRate
in interface SamplingRateAccessor
public void setSamplingRate(int aSamplingRate)
setSamplingRate
in interface SamplingRateAccessor.SamplingRateMutator
aSamplingRate
- The sampling rate to be stored by the sampling
rate property.public WavSoundSampleWriter withSamplingRate(int aSamplingRate)
withSamplingRate
in interface SamplingRateAccessor.SamplingRateBuilder<WavSoundSampleWriter>
aSamplingRate
- The sampling rate to be stored by the sampling
rate property.Copyright © 2021. All rights reserved.