S
- The SoundSample
(sub-)type on which the
SampleWriter
implementation is to operate on.B
- The WavSampleWriter
implementing this
AbstractWavSampleWriter
.AutoCloseable
, BitsPerSampleAccessor
, BitsPerSampleAccessor.BitsPerSampleBuilder<S>
, BitsPerSampleAccessor.BitsPerSampleMutator
, BitsPerSampleAccessor.BitsPerSampleProperty
, SampleWriter<S,B>
, SamplingRateAccessor
, SamplingRateAccessor.SamplingRateBuilder<S>
, SamplingRateAccessor.SamplingRateMutator
, SamplingRateAccessor.SamplingRateProperty
, WavSampleWriter<S,B>
, org.refcodes.io.RowWriter<S>
WavMonoSampleWriter
, WavSoundSampleWriter
public abstract class AbstractWavSampleWriter<S extends SoundSample,B extends WavSampleWriter<S,B>> extends Object implements WavSampleWriter<S,B>
AbstractWavSampleWriter
provides a foundation 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
Modifier and Type | Field | Description |
---|---|---|
protected BitsPerSample |
_bitsPerSample |
|
protected File |
_file |
|
protected BufferedOutputStream |
_outputStream |
|
static String |
DATA |
|
static String |
FORMAT |
|
protected static long |
MAX_16_BIT |
|
protected static long |
MAX_8_BIT |
|
static String |
RIFF |
|
static String |
WAVE |
Constructor | Description |
---|---|
AbstractWavSampleWriter(File aFile) |
Constructs the
AbstractWavSampleWriter for writing sound samples
to a WAV file or stream. |
AbstractWavSampleWriter(OutputStream aOutputStream) |
Constructs the
AbstractWavSampleWriter for writing sound samples
to a WAV file or stream. |
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
|
BitsPerSample |
getBitsPerSample() |
Retrieves the bits/sample per channel from the bits/sample per channel
property.
|
void |
setBitsPerSample(BitsPerSample aBitsPerSample) |
Sets the bits/sample per channel for the bits/sample per channel
property.
|
protected long |
toWavSample(double eSampleData) |
|
protected void |
writeHeader(int aSamplingRate,
int aChannelNumber) |
withBitsPerSample
letBitsPerSample
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
writeNext
getSamplingRate
withSamplingRate
setSamplingRate
letSamplingRate
public static String RIFF
public static String WAVE
public static String FORMAT
public static String DATA
protected static final long MAX_16_BIT
protected static final long MAX_8_BIT
protected BufferedOutputStream _outputStream
protected File _file
protected BitsPerSample _bitsPerSample
public AbstractWavSampleWriter(File aFile) throws FileNotFoundException
AbstractWavSampleWriter
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 AbstractWavSampleWriter(OutputStream aOutputStream)
AbstractWavSampleWriter
for writing sound samples
to a WAV file or stream.aOutputStream
- The OutputStream
where to write the CSV
records to.public void setBitsPerSample(BitsPerSample aBitsPerSample)
setBitsPerSample
in interface BitsPerSampleAccessor.BitsPerSampleMutator
aBitsPerSample
- The bits/sample per channel to be stored by the
sampling rate property.public BitsPerSample getBitsPerSample()
getBitsPerSample
in interface BitsPerSampleAccessor
public void close() throws IOException
close
in interface AutoCloseable
close
in interface SampleWriter<S extends SoundSample,B extends WavSampleWriter<S,B>>
IOException
protected long toWavSample(double eSampleData)
protected void writeHeader(int aSamplingRate, int aChannelNumber) throws IOException
IOException
Copyright © 2021. All rights reserved.