org.tritonus.sampled.convert
Class PCM2PCMConversionProvider

java.lang.Object
  extended byjavax.sound.sampled.spi.FormatConversionProvider
      extended byorg.tritonus.share.sampled.convert.TFormatConversionProvider
          extended byorg.tritonus.share.sampled.convert.TSimpleFormatConversionProvider
              extended byorg.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.

Author:
Florian Bomers
See Also:
FloatSampleBuffer, TConversionTool

Nested Class Summary
(package private)  class PCM2PCMConversionProvider.PCM2PCMStream
          PCM2PCMStream Provides direct conversion of some selected formats and rxpanding of channels.
 
Field Summary
static AudioFormat.Encoding PCM_SIGNED
           
static AudioFormat.Encoding PCM_UNSIGNED
           
 
Fields inherited from class org.tritonus.share.sampled.convert.TFormatConversionProvider
EMPTY_ENCODING_ARRAY, EMPTY_FORMAT_ARRAY
 
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
disable, doMatch, doMatch, getCollectionSourceEncodings, getCollectionSourceFormats, getCollectionTargetEncodings, getCollectionTargetFormats, getFrameSize, getSourceEncodings, getTargetEncodings, getTargetEncodings, isAllowedSourceEncoding, isAllowedSourceFormat, isAllowedTargetEncoding, isAllowedTargetFormat, isSourceEncodingSupported, isTargetEncodingSupported, replaceNotSpecified
 
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PCM_SIGNED

public static AudioFormat.Encoding PCM_SIGNED

PCM_UNSIGNED

public static 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