Module org.refcodes.audio
Package org.refcodes.audio
Class AbstractWavSampleWriter<S extends SoundSample,B extends WavSampleWriter<S,B>>
java.lang.Object
org.refcodes.audio.AbstractWavSampleWriter<S,B>
- Type Parameters:
S
- TheSoundSample
(sub-)type on which theSampleWriter
implementation is to operate on.B
- TheWavSampleWriter
implementing thisAbstractWavSampleWriter
.
- All Implemented Interfaces:
AutoCloseable
,BitsPerSampleAccessor
,BitsPerSampleAccessor.BitsPerSampleBuilder<B>
,BitsPerSampleAccessor.BitsPerSampleMutator
,BitsPerSampleAccessor.BitsPerSampleProperty
,SampleWriter<S,
,B> SamplingRateAccessor
,SamplingRateAccessor.SamplingRateBuilder<B>
,SamplingRateAccessor.SamplingRateMutator
,SamplingRateAccessor.SamplingRateProperty
,WavSampleWriter<S,
,B> org.refcodes.io.RowWriter<S>
- Direct Known Subclasses:
WavMonoSampleWriter
,WavSoundSampleWriter
public abstract class AbstractWavSampleWriter<S extends SoundSample,B extends WavSampleWriter<S,B>>
extends Object
implements WavSampleWriter<S,B>
The
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".-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.audio.BitsPerSampleAccessor
BitsPerSampleAccessor.BitsPerSampleBuilder<B extends BitsPerSampleAccessor.BitsPerSampleBuilder<B>>, BitsPerSampleAccessor.BitsPerSampleMutator, BitsPerSampleAccessor.BitsPerSampleProperty
Nested classes/interfaces inherited from interface org.refcodes.audio.SamplingRateAccessor
SamplingRateAccessor.SamplingRateBuilder<B extends SamplingRateAccessor.SamplingRateBuilder<B>>, SamplingRateAccessor.SamplingRateMutator, SamplingRateAccessor.SamplingRateProperty
-
Field Summary
Modifier and TypeFieldDescriptionprotected BitsPerSample
protected File
protected BufferedOutputStream
static String
static String
protected static final long
protected static final long
static String
static String
-
Constructor Summary
ConstructorDescriptionAbstractWavSampleWriter
(File aFile) Constructs theAbstractWavSampleWriter
for writing sound samples to a WAV file or stream.AbstractWavSampleWriter
(OutputStream aOutputStream) Constructs theAbstractWavSampleWriter
for writing sound samples to a WAV file or stream. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
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) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.refcodes.audio.BitsPerSampleAccessor.BitsPerSampleBuilder
withBitsPerSample
Methods inherited from interface org.refcodes.audio.BitsPerSampleAccessor.BitsPerSampleProperty
letBitsPerSample
Methods inherited from interface org.refcodes.audio.SampleWriter
writeNext
Methods inherited from interface org.refcodes.audio.SamplingRateAccessor
getSamplingRate
Methods inherited from interface org.refcodes.audio.SamplingRateAccessor.SamplingRateBuilder
withSamplingRate
Methods inherited from interface org.refcodes.audio.SamplingRateAccessor.SamplingRateMutator
setSamplingRate
Methods inherited from interface org.refcodes.audio.SamplingRateAccessor.SamplingRateProperty
letSamplingRate
-
Field Details
-
RIFF
-
WAVE
-
FORMAT
-
DATA
-
MAX_16_BIT
protected static final long MAX_16_BIT- See Also:
-
MAX_8_BIT
protected static final long MAX_8_BIT- See Also:
-
_outputStream
-
_file
-
_bitsPerSample
-
-
Constructor Details
-
AbstractWavSampleWriter
Constructs theAbstractWavSampleWriter
for writing sound samples to a WAV file or stream.- Parameters:
aFile
- TheFile
where to write the CSV records to.- Throws:
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.
-
AbstractWavSampleWriter
Constructs theAbstractWavSampleWriter
for writing sound samples to a WAV file or stream.- Parameters:
aOutputStream
- TheOutputStream
where to write the CSV records to.
-
-
Method Details
-
setBitsPerSample
Sets the bits/sample per channel for the bits/sample per channel property.- Specified by:
setBitsPerSample
in interfaceBitsPerSampleAccessor.BitsPerSampleMutator
- Parameters:
aBitsPerSample
- The bits/sample per channel to be stored by the sampling rate property.
-
getBitsPerSample
Retrieves the bits/sample per channel from the bits/sample per channel property.- Specified by:
getBitsPerSample
in interfaceBitsPerSampleAccessor
- Returns:
- The bits/sample per channel stored by the bits/sample per channel property.
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceSampleWriter<S extends SoundSample,
B extends WavSampleWriter<S, B>> - Throws:
IOException
-
toWavSample
protected long toWavSample(double eSampleData) -
writeHeader
- Throws:
IOException
-