|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.sound.sampled.spi.FormatConversionProvider
org.tritonus.share.sampled.convert.TFormatConversionProvider
org.tritonus.share.sampled.convert.TSimpleFormatConversionProvider
This is a base class for FormatConversionProviders that can convert from each source encoding/format to each target encoding/format. If this is not the case, use TEncodingFormatConversionProvider or TMatrixFormatConversionProvider.
Overriding classes must
provide a constructor that calls the protected constructor of this class and override
AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream)
.
The latter method should be able to handle the case that all fields are NOT_SPECIFIED
and provide appropriate default values.
Field Summary |
---|
Fields inherited from class org.tritonus.share.sampled.convert.TFormatConversionProvider |
---|
EMPTY_ENCODING_ARRAY, EMPTY_FORMAT_ARRAY |
Constructor Summary | |
---|---|
protected |
TSimpleFormatConversionProvider(Collection sourceFormats,
Collection targetFormats)
|
Method Summary | |
---|---|
protected void |
disable()
Disables this FormatConversionProvider. |
protected static boolean |
doMatch(float f1,
float f2)
|
protected static boolean |
doMatch(int i1,
int i2)
Utility method to check whether these values match, taking into account AudioSystem.NOT_SPECIFIED. |
protected Collection |
getCollectionSourceEncodings()
|
protected Collection |
getCollectionSourceFormats()
|
protected Collection |
getCollectionTargetEncodings()
|
protected Collection |
getCollectionTargetFormats()
|
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.Encoding[] |
getSourceEncodings()
|
AudioFormat.Encoding[] |
getTargetEncodings()
|
AudioFormat.Encoding[] |
getTargetEncodings(AudioFormat sourceFormat)
This implementation assumes that the converter can convert from each of its source encodings to each of its target encodings. |
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. |
protected boolean |
isAllowedSourceEncoding(AudioFormat.Encoding sourceEncoding)
|
protected boolean |
isAllowedSourceFormat(AudioFormat sourceFormat)
|
protected boolean |
isAllowedTargetEncoding(AudioFormat.Encoding targetEncoding)
|
protected boolean |
isAllowedTargetFormat(AudioFormat targetFormat)
|
boolean |
isSourceEncodingSupported(AudioFormat.Encoding sourceEncoding)
|
boolean |
isTargetEncodingSupported(AudioFormat.Encoding targetEncoding)
|
protected AudioFormat |
replaceNotSpecified(AudioFormat sourceFormat,
AudioFormat targetFormat)
Utility method, replaces all occurences of AudioSystem.NOT_SPECIFIED in targetFormat with the corresponding value in sourceFormat . |
Methods inherited from class org.tritonus.share.sampled.convert.TFormatConversionProvider |
---|
getAudioInputStream, getMatchingFormat, isConversionSupported |
Methods inherited from class javax.sound.sampled.spi.FormatConversionProvider |
---|
getAudioInputStream, isConversionSupported |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected TSimpleFormatConversionProvider(Collection sourceFormats, Collection targetFormats)
Method Detail |
---|
protected void disable()
public AudioFormat.Encoding[] getSourceEncodings()
getSourceEncodings
in class FormatConversionProvider
public AudioFormat.Encoding[] getTargetEncodings()
getTargetEncodings
in class FormatConversionProvider
public boolean isSourceEncodingSupported(AudioFormat.Encoding sourceEncoding)
isSourceEncodingSupported
in class FormatConversionProvider
public boolean isTargetEncodingSupported(AudioFormat.Encoding targetEncoding)
isTargetEncodingSupported
in class FormatConversionProvider
public AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat)
getTargetEncodings
in class FormatConversionProvider
public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat)
getTargetFormats
in class FormatConversionProvider
protected boolean isAllowedSourceEncoding(AudioFormat.Encoding sourceEncoding)
protected boolean isAllowedTargetEncoding(AudioFormat.Encoding targetEncoding)
protected boolean isAllowedSourceFormat(AudioFormat sourceFormat)
protected boolean isAllowedTargetFormat(AudioFormat targetFormat)
protected Collection getCollectionSourceEncodings()
protected Collection getCollectionTargetEncodings()
protected Collection getCollectionSourceFormats()
protected Collection getCollectionTargetFormats()
protected static boolean doMatch(int i1, int i2)
protected static boolean doMatch(float f1, float f2)
doMatch(int,int)
protected AudioFormat replaceNotSpecified(AudioFormat sourceFormat, AudioFormat targetFormat)
targetFormat
with the corresponding value in sourceFormat
.
If targetFormat
does not contain any fields with AudioSystem.NOT_SPECIFIED,
it is returned unmodified. The endian-ness and encoding remain the same in all cases.
If any of the fields is AudioSystem.NOT_SPECIFIED in both sourceFormat
and
targetFormat
, it will remain not specified.
This method uses getFrameSize(...)
(see below) to set the new frameSize,
if a new AudioFormat instance is created.
This method isn't used in TSimpleFormatConversionProvider - it is solely there for inheriting classes.
protected int getFrameSize(AudioFormat.Encoding encoding, float sampleRate, int sampleSize, int channels, float frameRate, boolean bigEndian, int oldFrameSize)
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.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |