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 theSampleWriter
implementation is to operate on.B
- TheSampleWriter
implementing thisAbstractLineOutSampleWriter
.
- All Implemented Interfaces:
AutoCloseable
,BitsPerSampleAccessor
,BitsPerSampleAccessor.BitsPerSampleBuilder<S>
,BitsPerSampleAccessor.BitsPerSampleMutator
,BitsPerSampleAccessor.BitsPerSampleProperty
,LineOutSampleWriter<S,B>
,SampleWriter<S,B>
,SamplingRateAccessor
,SamplingRateAccessor.SamplingRateBuilder<S>
,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>
TheAbstractLineOutSampleWriter
provides 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
_bitsPerSample
protected static long
MAX_16_BIT
protected static long
MAX_8_BIT
-
Constructor Summary
Constructors Constructor Description AbstractLineOutSampleWriter()
Constructs anAbstractLineOutSampleWriter
.AbstractLineOutSampleWriter(BitsPerSample aBitsPerSample)
Constructs anAbstractLineOutSampleWriter
with the givenBitsPerSample
to use.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 static SourceDataLine
toLineOut(SoundSample aSoundSample, BitsPerSample aBitsPerSample)
Produces a line-outSourceDataLine
instance for writing samples to.protected long
toWavSample(double eSampleData)
-
Methods inherited from interface org.refcodes.audio.BitsPerSampleAccessor.BitsPerSampleBuilder
withBitsPerSample
-
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.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
-
-
-
-
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 anAbstractLineOutSampleWriter
with the givenBitsPerSample
to 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:
setBitsPerSample
in 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:
getBitsPerSample
in 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-outSourceDataLine
instance for writing samples to.- Parameters:
aSoundSample
- TheSoundSample
from which to get the according metrics.aBitsPerSample
- The preferred bits/sample.- Returns:
- An instance of the
SourceDataLine
to which to write data. - Throws:
LineUnavailableException
- thrown in case the audio-line cannot be acquired.
-
-