- java.lang.Object
-
- org.refcodes.audio.AbstractLineOutSampleWriter<MonoSample,LineOutMonoSampleWriter>
-
- org.refcodes.audio.LineOutMonoSampleWriter
-
- All Implemented Interfaces:
AutoCloseable,BitsPerSampleAccessor,BitsPerSampleAccessor.BitsPerSampleBuilder<LineOutMonoSampleWriter>,BitsPerSampleAccessor.BitsPerSampleMutator,BitsPerSampleAccessor.BitsPerSampleProperty,LineOutSampleWriter<MonoSample,LineOutMonoSampleWriter>,MonoSampleWriter<LineOutMonoSampleWriter>,SampleWriter<MonoSample,LineOutMonoSampleWriter>,SamplingRateAccessor,SamplingRateAccessor.SamplingRateBuilder<LineOutMonoSampleWriter>,SamplingRateAccessor.SamplingRateMutator,SamplingRateAccessor.SamplingRateProperty,org.refcodes.io.RowWriter<MonoSample>
public class LineOutMonoSampleWriter extends AbstractLineOutSampleWriter<MonoSample,LineOutMonoSampleWriter> implements LineOutSampleWriter<MonoSample,LineOutMonoSampleWriter>, MonoSampleWriter<LineOutMonoSampleWriter>
TheLineOutMonoSampleWriterprovides 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 inherited from class org.refcodes.audio.AbstractLineOutSampleWriter
_bitsPerSample, MAX_16_BIT, MAX_8_BIT
-
-
Constructor Summary
Constructors Constructor Description LineOutMonoSampleWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()protected SourceDataLinegetLineOut()Produces a line-outSourceDataLineinstance for writing samples to.intgetSamplingRate()Retrieves the sampling rate from the sampling rate property.voidsetSamplingRate(int aSamplingRate)Sets the sampling rate for the sampling rate property.LineOutMonoSampleWriterwithBitsPerSample(BitsPerSample aBitsPerSample)Sets the bits/sample per channel for the bits/sample per channel property.LineOutMonoSampleWriterwithSamplingRate(int aSamplingRate)Sets the sampling rate for the sampling rate property.voidwriteNext(double aSampleData)Writes the next samples, one sample for each channel.voidwriteNext(MonoSample aSample)Writes the next samples, one sample for each channel.-
Methods inherited from class org.refcodes.audio.AbstractLineOutSampleWriter
getBitsPerSample, setBitsPerSample, toLineOut, toWavSample
-
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
getBitsPerSample
-
Methods inherited from interface org.refcodes.audio.BitsPerSampleAccessor.BitsPerSampleMutator
setBitsPerSample
-
Methods inherited from interface org.refcodes.audio.BitsPerSampleAccessor.BitsPerSampleProperty
letBitsPerSample
-
Methods inherited from interface org.refcodes.audio.SamplingRateAccessor.SamplingRateProperty
letSamplingRate
-
-
-
-
Method Detail
-
withBitsPerSample
public LineOutMonoSampleWriter withBitsPerSample(BitsPerSample aBitsPerSample)
Sets the bits/sample per channel for the bits/sample per channel property.- Specified by:
withBitsPerSamplein interfaceBitsPerSampleAccessor.BitsPerSampleBuilder<LineOutMonoSampleWriter>- Parameters:
aBitsPerSample- The bits/sample per channel to be stored by the sampling rate property.- Returns:
- The builder for applying multiple build operations.
-
writeNext
public void writeNext(double aSampleData) throws IOExceptionWrites the next samples, one sample for each channel. Provide one sample for mono audio, two samples for stereo audio and so on. In case you provide more or less samples than channels being supported by the writer, then it is up to the writer whether to duplicate the samples or calculate an average or the like.- Specified by:
writeNextin interfaceMonoSampleWriter<LineOutMonoSampleWriter>- Parameters:
aSampleData- The samples, one for each channel.- Throws:
IOException- thrown in case writing the sample caused an I/O related problem.
-
writeNext
public void writeNext(MonoSample aSample) throws IOException
Writes the next samples, one sample for each channel. Provide one sample for mono audio, two samples for stereo audio and so on. In case you provide more or less samples than channels being supported by the writer, then it is up to the writer whether to duplicate the samples or calculate an average or the like.- Specified by:
writeNextin interfaceorg.refcodes.io.RowWriter<MonoSample>- Specified by:
writeNextin interfaceSampleWriter<MonoSample,LineOutMonoSampleWriter>- Parameters:
aSample- The samples, one for each channel.- Throws:
IOException- thrown in case writing the sample caused an I/O related problem.
-
getSamplingRate
public int getSamplingRate()
Retrieves the sampling rate from the sampling rate property.- Specified by:
getSamplingRatein interfaceSamplingRateAccessor- Returns:
- The sampling rate stored by the sampling rate property.
-
setSamplingRate
public void setSamplingRate(int aSamplingRate)
Sets the sampling rate for the sampling rate property.- Specified by:
setSamplingRatein interfaceSamplingRateAccessor.SamplingRateMutator- Parameters:
aSamplingRate- The sampling rate to be stored by the sampling rate property.
-
withSamplingRate
public LineOutMonoSampleWriter withSamplingRate(int aSamplingRate)
Sets the sampling rate for the sampling rate property.- Specified by:
withSamplingRatein interfaceSamplingRateAccessor.SamplingRateBuilder<LineOutMonoSampleWriter>- Parameters:
aSamplingRate- The sampling rate to be stored by the sampling rate property.- Returns:
- The builder for applying multiple build operations.
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSampleWriter<MonoSample,LineOutMonoSampleWriter>- Throws:
IOException
-
getLineOut
protected SourceDataLine getLineOut() throws LineUnavailableException
Produces a line-outSourceDataLineinstance for writing samples to.- Returns:
- The
SourceDataLineupon success. - Throws:
LineUnavailableException- thrown in case the audio-line cannot be acquired.
-
-