org.tritonus.sampled.convert
Class PCM2PCMConversionProvider

java.lang.Object
  extended by javax.sound.sampled.spi.FormatConversionProvider
      extended by org.tritonus.share.sampled.convert.TFormatConversionProvider
          extended by org.tritonus.share.sampled.convert.TSimpleFormatConversionProvider
              extended by org.tritonus.sampled.convert.PCM2PCMConversionProvider

public class PCM2PCMConversionProvider
extends TSimpleFormatConversionProvider

This provider supports these PCM conversions (<--> meaning both directions):

The class uses 2 different approaches for conversion:
  1. Simple, often used conversions with performance-optimized methods.
    These are the following conversions:

    Downsampling from 16bit to 8bit is currently done using the float conversion (see next point), in order to profit of dithering.
  2. 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.
  3. 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.

See Also:
FloatSampleBuffer, TConversionTool

Field Summary
static AudioFormat.Encoding PCM_SIGNED
           
static AudioFormat.Encoding PCM_UNSIGNED
           
 
Constructor Summary
PCM2PCMConversionProvider()
          Constructor.
 
Method Summary
 AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream)
           
 AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat)
          This implementation assumes that the converter can convert from each of its source formats to each of its target formats.
 boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat)
          method overidden due to the difficult situation with the channel count and the possible conversions possible.
 
Methods inherited from class org.tritonus.share.sampled.convert.TSimpleFormatConversionProvider
getSourceEncodings, getTargetEncodings, getTargetEncodings, isSourceEncodingSupported, isTargetEncodingSupported
 
Methods inherited from class org.tritonus.share.sampled.convert.TFormatConversionProvider
getAudioInputStream, getMatchingFormat
 
Methods inherited from class javax.sound.sampled.spi.FormatConversionProvider
isConversionSupported
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PCM_SIGNED

public static final AudioFormat.Encoding PCM_SIGNED

PCM_UNSIGNED

public static final AudioFormat.Encoding PCM_UNSIGNED
Constructor Detail

PCM2PCMConversionProvider

public PCM2PCMConversionProvider()
Constructor.

Method Detail

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