org.tritonus.sampled.convert.lame
Class Mp3LameFormatConversionProvider

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.lame.Mp3LameFormatConversionProvider

public class Mp3LameFormatConversionProvider
extends TSimpleFormatConversionProvider

ConversionProvider for encoding MP3 audio files with the lame lib.

It uses a sloppy implementation of the MPEG1L3 encoding: It is used as a common denominator. So users can always ask for MPEG1L3 encoding but may get in fact an MPEG2L3 or MPEG2.5L3 encoded stream.

Author:
Florian Bomers

Nested Class Summary
static class Mp3LameFormatConversionProvider.EncodedMpegAudioInputStream
           
 
Field Summary
static AudioFormat.Encoding MPEG1L3
           
static AudioFormat.Encoding MPEG2DOT5L3
           
static AudioFormat.Encoding MPEG2L3
           
 
Fields inherited from class org.tritonus.share.sampled.convert.TFormatConversionProvider
EMPTY_ENCODING_ARRAY, EMPTY_FORMAT_ARRAY
 
Constructor Summary
Mp3LameFormatConversionProvider()
          Constructor.
 
Method Summary
 AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream audioInputStream)
           
protected  AudioFormat getDefaultTargetFormat(AudioFormat targetFormat, AudioFormat sourceFormat, boolean allowNotSpecified)
           
protected  int getFrameSize(AudioFormat.Encoding encoding, float sampleRate, int sampleSize, int channels, float frameRate, boolean bigEndian, int oldFrameSize)
          Calculates the frame size for the given format description.
 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.
 
Methods inherited from class org.tritonus.share.sampled.convert.TSimpleFormatConversionProvider
disable, doMatch, doMatch, getCollectionSourceEncodings, getCollectionSourceFormats, getCollectionTargetEncodings, getCollectionTargetFormats, getSourceEncodings, getTargetEncodings, getTargetEncodings, isAllowedSourceEncoding, isAllowedSourceFormat, isAllowedTargetEncoding, isAllowedTargetFormat, isSourceEncodingSupported, isTargetEncodingSupported, replaceNotSpecified
 
Methods inherited from class org.tritonus.share.sampled.convert.TFormatConversionProvider
getAudioInputStream, getMatchingFormat, isConversionSupported
 
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

MPEG1L3

public static final AudioFormat.Encoding MPEG1L3

MPEG2L3

public static final AudioFormat.Encoding MPEG2L3

MPEG2DOT5L3

public static final AudioFormat.Encoding MPEG2DOT5L3
Constructor Detail

Mp3LameFormatConversionProvider

public Mp3LameFormatConversionProvider()
Constructor.

Method Detail

getAudioInputStream

public AudioInputStream getAudioInputStream(AudioFormat targetFormat,
                                            AudioInputStream audioInputStream)
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

getDefaultTargetFormat

protected AudioFormat getDefaultTargetFormat(AudioFormat targetFormat,
                                             AudioFormat sourceFormat,
                                             boolean allowNotSpecified)

getFrameSize

protected int getFrameSize(AudioFormat.Encoding encoding,
                           float sampleRate,
                           int sampleSize,
                           int channels,
                           float frameRate,
                           boolean bigEndian,
                           int oldFrameSize)
Description copied from class: TSimpleFormatConversionProvider
Calculates the frame size for the given format description. The default implementation returns AudioSystem.NOT_SPECIFIED if either sampleSize or channels is AudioSystem.NOT_SPECIFIED, otherwise sampleSize*channels/8 is returned.

If this does not reflect the way to calculate the right frame size, inheriting classes should overwrite this method if they use replaceNotSpecified(...). It is not used elsewhere in this class.

Overrides:
getFrameSize in class TSimpleFormatConversionProvider