Module org.refcodes.audio
Package org.refcodes.audio
Class AbstractLineOutSampleWriter<S extends SoundSample,B extends LineOutSampleWriter<S,B>>
- java.lang.Object
-
- org.refcodes.audio.AbstractLineOutSampleWriter<S,B>
-
- Type Parameters:
S- TheSoundSample(sub-)type on which theSampleWriterimplementation is to operate on.B- TheSampleWriterimplementing thisAbstractLineOutSampleWriter.
- All Implemented Interfaces:
AutoCloseable,BitsPerSampleAccessor,BitsPerSampleAccessor.BitsPerSampleBuilder<B>,BitsPerSampleAccessor.BitsPerSampleMutator,BitsPerSampleAccessor.BitsPerSampleProperty,LineOutSampleWriter<S,B>,SampleWriter<S,B>,SamplingRateAccessor,SamplingRateAccessor.SamplingRateBuilder<B>,SamplingRateAccessor.SamplingRateMutator,SamplingRateAccessor.SamplingRateProperty,org.refcodes.io.RowWriter<S>
- Direct Known Subclasses:
LineOutMonoSampleWriter,LineOutSoundSampleWriter
public abstract class AbstractLineOutSampleWriter<S extends SoundSample,B extends LineOutSampleWriter<S,B>> extends Object implements LineOutSampleWriter<S,B>
TheAbstractLineOutSampleWriterprovides a foundation means to write sound samples to a line-out device.
-
-
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
Fields Modifier and Type Field Description protected BitsPerSample_bitsPerSampleprotected static longMAX_16_BITprotected static longMAX_8_BIT
-
Constructor Summary
Constructors Constructor Description AbstractLineOutSampleWriter()Constructs anAbstractLineOutSampleWriter.AbstractLineOutSampleWriter(BitsPerSample aBitsPerSample)Constructs anAbstractLineOutSampleWriterwith the givenBitsPerSampleto use.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BitsPerSamplegetBitsPerSample()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 static SourceDataLinetoLineOut(SoundSample aSoundSample, BitsPerSample aBitsPerSample)Produces a line-outSourceDataLineinstance for writing samples to.protected longtoWavSample(double eSampleData)-
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
close, 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 Detail
-
MAX_16_BIT
protected static final long MAX_16_BIT
- See Also:
- Constant Field Values
-
MAX_8_BIT
protected static final long MAX_8_BIT
- See Also:
- Constant Field Values
-
_bitsPerSample
protected BitsPerSample _bitsPerSample
-
-
Constructor Detail
-
AbstractLineOutSampleWriter
public AbstractLineOutSampleWriter()
Constructs anAbstractLineOutSampleWriter.
-
AbstractLineOutSampleWriter
public AbstractLineOutSampleWriter(BitsPerSample aBitsPerSample)
Constructs anAbstractLineOutSampleWriterwith the givenBitsPerSampleto use.- Parameters:
aBitsPerSample- The bits/sample to use when doing audio playback.
-
-
Method Detail
-
setBitsPerSample
public void setBitsPerSample(BitsPerSample aBitsPerSample)
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
public BitsPerSample 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.
-
toWavSample
protected long toWavSample(double eSampleData)
-
toLineOut
protected static SourceDataLine toLineOut(SoundSample aSoundSample, BitsPerSample aBitsPerSample) throws LineUnavailableException
Produces a line-outSourceDataLineinstance for writing samples to.- Parameters:
aSoundSample- TheSoundSamplefrom which to get the according metrics.aBitsPerSample- The preferred bits/sample.- Returns:
- An instance of the
SourceDataLineto which to write data. - Throws:
LineUnavailableException- thrown in case the audio-line cannot be acquired.
-
-