public class SampleRateConverter extends AudioProcessor
SampleRateConverter.SampleRateConversionAlgorithm.LINEAR_INTERPOLATION
.
To use the class, instantiate using the default constructor or the
chainable constructor. Both of these constructors take the algorithm for
sample rate conversion as well as the output format. The output format
must have the same number of bits and same number of channels as the
expected input otherwise the process(SampleChunk)
method
will throw IllegalArgumentException
. The input format for the samples
is expected to be provided as part of the SampleChunk
.
The class itself checks whether the output format and the input format are the same (in which case the sample does not need to be resampled). That means the algorithm implementation does not need to do this.
Modifier and Type | Class and Description |
---|---|
static class |
SampleRateConverter.SampleRateConversionAlgorithm
An enumerator of the different sample rate conversion algorithms
available in this sample rate converter.
|
Constructor and Description |
---|
SampleRateConverter(AudioStream as,
SampleRateConverter.SampleRateConversionAlgorithm converter,
AudioFormat outputFormat)
Chainable constructor.
|
SampleRateConverter(SampleRateConverter.SampleRateConversionAlgorithm converter,
AudioFormat outputFormat)
Default constructor that takes the input conversion
|
Modifier and Type | Method and Description |
---|---|
SampleChunk |
process(SampleChunk sample)
Function that takes a sample chunk and processes the chunk.
|
getLength, getUnderlyingStream, nextSampleChunk, process, processingComplete, reset, setUnderlyingStream
iterator, seek
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public SampleRateConverter(SampleRateConverter.SampleRateConversionAlgorithm converter, AudioFormat outputFormat)
converter
- The converter to useoutputFormat
- The output format to convert topublic SampleRateConverter(AudioStream as, SampleRateConverter.SampleRateConversionAlgorithm converter, AudioFormat outputFormat)
as
- The audio stream to processconverter
- The converter to useoutputFormat
- The output format to convert topublic SampleChunk process(SampleChunk sample) throws Exception
process
in class AudioProcessor
sample
- The sample chunk to process.Exception
- If the processing could not take placeAudioProcessor.process(org.openimaj.audio.SampleChunk)