org.tritonus.sampled.convert
Class PCM2PCMConversionProvider
java.lang.Object
javax.sound.sampled.spi.FormatConversionProvider
org.tritonus.share.sampled.convert.TFormatConversionProvider
org.tritonus.share.sampled.convert.TSimpleFormatConversionProvider
org.tritonus.sampled.convert.PCM2PCMConversionProvider
- public class PCM2PCMConversionProvider
- extends TSimpleFormatConversionProvider
This provider supports these PCM conversions (<--> meaning both directions):
- 8 Signed <-> 8 unsigned
- 16/24/32 Signed little endian <-> 16/24/32 Signed big endian
- arbitrary conversion between 8/16/24/32 bit sample width
(up-conversion is done by adding low-byte zero(s)).
- 1 channel <-> x channels
The class uses 2 different approaches for conversion:
- Simple, often used conversions with performance-optimized methods.
These are the following conversions:
- 8 Signed <-> 8 unsigned
- 16 signed little endian <--> 16 signed big endian
- 24 signed little endian <--> 24 signed big endian
- 32 signed little endian <--> 32 signed big endian
- 16 signed little endian <--> 8 signed
- 16 signed big endian <--> 8 signed
- 16 signed little endian <--> 8 unsigned
- 16 signed big endian <--> 8 unsigned
Downsampling from 16bit to 8bit is currently done
using the float conversion (see next point), in order
to profit of dithering.
- All other conversions are done using the FloatSampleBuffer.
Mixdown of channels (x channels -> 1 channel) is done by
plainly adding all channels together.
Thus, up mixing and down mixing will not result in the same audio,
as downmixing does NOT lower the volume and clippings are very
probable. To avoid that, the volume of the channels
should be lowered before using this converter for down mixing.
- All conversions support upmixing of channels:
1 channel -> x channels. This is done by
copying the channel to the other channels after
conversion of the format (if necessary).
SampleRate CANNOT be converted.
- Author:
- Florian Bomers
- See Also:
FloatSampleBuffer
,
TConversionTool
Methods inherited from class org.tritonus.share.sampled.convert.TSimpleFormatConversionProvider |
disable, doMatch, doMatch, getCollectionSourceEncodings, getCollectionSourceFormats, getCollectionTargetEncodings, getCollectionTargetFormats, getFrameSize, getSourceEncodings, getTargetEncodings, getTargetEncodings, isAllowedSourceEncoding, isAllowedSourceFormat, isAllowedTargetEncoding, isAllowedTargetFormat, isSourceEncodingSupported, isTargetEncodingSupported, replaceNotSpecified |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PCM_SIGNED
public static AudioFormat.Encoding PCM_SIGNED
PCM_UNSIGNED
public static AudioFormat.Encoding PCM_UNSIGNED
PCM2PCMConversionProvider
public PCM2PCMConversionProvider()
- Constructor.
getAudioInputStream
public AudioInputStream getAudioInputStream(AudioFormat targetFormat,
AudioInputStream sourceStream)
- Specified by:
getAudioInputStream
in class FormatConversionProvider
getTargetFormats
public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding,
AudioFormat sourceFormat)
- Description copied from class:
TSimpleFormatConversionProvider
- This implementation assumes that the converter can convert
from each of its source formats to each of its target
formats. If this is not the case, the converter has to
override this method.
- Overrides:
getTargetFormats
in class TSimpleFormatConversionProvider
isConversionSupported
public boolean isConversionSupported(AudioFormat targetFormat,
AudioFormat sourceFormat)
- method overidden due to the difficult situation with the channel count
and the possible conversions possible.
- Overrides:
isConversionSupported
in class TFormatConversionProvider