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 theSampleWriterimplementation is to operate on.B- TheWavSampleWriterimplementing 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.BitsPerSamplePropertyNested classes/interfaces inherited from interface org.refcodes.audio.SamplingRateAccessor
SamplingRateAccessor.SamplingRateBuilder<B extends SamplingRateAccessor.SamplingRateBuilder<B>>, SamplingRateAccessor.SamplingRateMutator, SamplingRateAccessor.SamplingRateProperty -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BitsPerSampleprotected Fileprotected BufferedOutputStreamstatic Stringstatic Stringprotected static final longprotected static final longstatic Stringstatic String -
Constructor Summary
ConstructorsConstructorDescriptionAbstractWavSampleWriter(File aFile) Constructs theAbstractWavSampleWriterfor writing sound samples to a WAV file or stream.AbstractWavSampleWriter(OutputStream aOutputStream) Constructs theAbstractWavSampleWriterfor writing sound samples to a WAV file or stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Retrieves the bits/sample per channel from the bits/sample per channel property.voidsetBitsPerSample(BitsPerSample aBitsPerSample) Sets the bits/sample per channel for the bits/sample per channel property.protected longtoWavSample(double eSampleData) protected voidwriteHeader(int aSamplingRate, int aChannelNumber) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.refcodes.audio.BitsPerSampleAccessor.BitsPerSampleBuilder
withBitsPerSampleMethods inherited from interface org.refcodes.audio.BitsPerSampleAccessor.BitsPerSampleProperty
letBitsPerSampleMethods inherited from interface org.refcodes.audio.SampleWriter
writeNextMethods inherited from interface org.refcodes.audio.SamplingRateAccessor
getSamplingRateMethods inherited from interface org.refcodes.audio.SamplingRateAccessor.SamplingRateBuilder
withSamplingRateMethods inherited from interface org.refcodes.audio.SamplingRateAccessor.SamplingRateMutator
setSamplingRateMethods 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 theAbstractWavSampleWriterfor writing sound samples to a WAV file or stream.- Parameters:
aFile- TheFilewhere 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 theAbstractWavSampleWriterfor writing sound samples to a WAV file or stream.- Parameters:
aOutputStream- TheOutputStreamwhere to write the CSV records to.
-
-
Method Details
-
setBitsPerSample
Sets the bits/sample per channel for the bits/sample per channel property.- Specified by:
setBitsPerSamplein 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:
getBitsPerSamplein interfaceBitsPerSampleAccessor- Returns:
- The bits/sample per channel stored by the bits/sample per channel property.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSampleWriter<S extends SoundSample,B extends WavSampleWriter<S, B>> - Throws:
IOException
-
toWavSample
protected long toWavSample(double eSampleData) -
writeHeader
- Throws:
IOException
-