APIdia Launch Partner
Top Description Inners Constructors Methods
com.sun.media.sound

public final Class PCMtoPCMCodec

extends FormatConversionProvider
Class Inheritance
Imports
java.io.IOException, java.util.ArrayList, .Objects, javax.sound.sampled.AudioFormat, .AudioFormat.Encoding, .AudioInputStream, .AudioSystem, javax.sound.sampled.spi.FormatConversionProvider

Converts among signed/unsigned and little/big endianness of sampled.
Author
Jan Borgersen

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public AudioInputStream
getAudioInputStream(AudioFormat.Encoding targetEncoding, AudioInputStream sourceStream)

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getAudioInputStream.

Obtains an audio input stream with the specified encoding from the given audio input stream.

public AudioInputStream
getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream)

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getAudioInputStream.

Obtains an audio input stream with the specified format from the given audio input stream.

private AudioInputStream

Returns:

stream from which processed data may be read
getConvertedStream
(AudioFormat
desired data format of the stream after processing
outputFormat
,
AudioInputStream
stream from which data to be processed should be read
stream
)

Opens the codec with the specified parameters.

private AudioFormat[]

Returns:

array of supported output formats.
getOutputFormats
(AudioFormat inputFormat)

Obtains the set of output formats supported by the codec given a particular input format.

public AudioFormat.Encoding[]
getSourceEncodings()

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getSourceEncodings.

Obtains the set of source format encodings from which format conversion services are provided by this provider.

public AudioFormat.Encoding[]
getTargetEncodings()

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getTargetEncodings.

Obtains the set of target format encodings to which format conversion services are provided by this provider.

public AudioFormat.Encoding[]
getTargetEncodings(AudioFormat sourceFormat)

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getTargetEncodings.

Obtains the set of target format encodings supported by the format converter given a particular source format.

public AudioFormat[]
getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat)

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getTargetFormats.

Obtains the set of target formats with the encoding specified supported by the format converter.

Inherited from javax.sound.sampled.spi.FormatConversionProvider:
isConversionSupportedisConversionSupportedisSourceEncodingSupportedisTargetEncodingSupported

Constructor Detail

PCMtoPCMCodecback to summary
public PCMtoPCMCodec()

Method Detail

getAudioInputStreamback to summary
public AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, AudioInputStream sourceStream)

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getAudioInputStream.

Doc from javax.sound.sampled.spi.FormatConversionProvider.getAudioInputStream.

Obtains an audio input stream with the specified encoding from the given audio input stream.

Annotations
@Override
getAudioInputStreamback to summary
public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream)

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getAudioInputStream.

Doc from javax.sound.sampled.spi.FormatConversionProvider.getAudioInputStream.

Obtains an audio input stream with the specified format from the given audio input stream.

Annotations
@Override
getConvertedStreamback to summary
private AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInputStream stream)

Opens the codec with the specified parameters.

Parameters
outputFormat:AudioFormat

desired data format of the stream after processing

stream:AudioInputStream

stream from which data to be processed should be read

Returns:AudioInputStream

stream from which processed data may be read

Exceptions
IllegalArgumentException:
if the format combination supplied is not supported.
getOutputFormatsback to summary
private AudioFormat[] getOutputFormats(AudioFormat inputFormat)

Obtains the set of output formats supported by the codec given a particular input format. If no output formats are supported for this input format, returns an array of length 0.

Returns:AudioFormat[]

array of supported output formats.

getSourceEncodingsback to summary
public AudioFormat.Encoding[] getSourceEncodings()

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getSourceEncodings.

Doc from javax.sound.sampled.spi.FormatConversionProvider.getSourceEncodings.

Obtains the set of source format encodings from which format conversion services are provided by this provider.

Annotations
@Override
getTargetEncodingsback to summary
public AudioFormat.Encoding[] getTargetEncodings()

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getTargetEncodings.

Doc from javax.sound.sampled.spi.FormatConversionProvider.getTargetEncodings.

Obtains the set of target format encodings to which format conversion services are provided by this provider.

Annotations
@Override
getTargetEncodingsback to summary
public AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat)

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getTargetEncodings.

Doc from javax.sound.sampled.spi.FormatConversionProvider.getTargetEncodings.

Obtains the set of target format encodings supported by the format converter given a particular source format. If no target format encodings are supported for this source format, an array of length 0 is returned.

Annotations
@Override
getTargetFormatsback to summary
public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat)

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getTargetFormats.

Doc from javax.sound.sampled.spi.FormatConversionProvider.getTargetFormats.

Obtains the set of target formats with the encoding specified supported by the format converter. If no target formats with the specified encoding are supported for this source format, an array of length 0 is returned.

Annotations
@Override
com.sun.media.sound back to summary

pack-priv Class PCMtoPCMCodec.PCMtoPCMCodecStream

extends AudioInputStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
private int
private final int
private final int
private final int
private final int
private final int
private final int
private final int
private final int
private final int
Inherited from javax.sound.sampled.AudioInputStream:
formatframeLengthframePosframeSize

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public int
read()

Overrides javax.sound.sampled.AudioInputStream.read.

Note that this only works for sign conversions.

public int
read(byte[] b)

Overrides javax.sound.sampled.AudioInputStream.read.

Reads some number of bytes from the audio input stream and stores them into the buffer array b.

public int
read(byte[] b, int off, int len)

Overrides javax.sound.sampled.AudioInputStream.read.

Reads up to a specified maximum number of bytes of data from the audio stream, putting them into the given byte array.

private void
switchEndian(byte[] b, int off, int len, int readCount)

private void
switchSigned8bit(byte[] b, int off, int len, int readCount)

private void
switchSignedBE(byte[] b, int off, int len, int readCount)

private void
switchSignedLE(byte[] b, int off, int len, int readCount)

Inherited from javax.sound.sampled.AudioInputStream:
availableclosegetFormatgetFrameLengthmarkmarkSupportedresetskip

Field Detail

conversionTypeback to summary
private int conversionType
PCM_SIGNED_BE2UNSIGNED_LEback to summary
private final int PCM_SIGNED_BE2UNSIGNED_LE
PCM_SIGNED_LE2UNSIGNED_BEback to summary
private final int PCM_SIGNED_LE2UNSIGNED_BE
PCM_SWITCH_ENDIANback to summary
private final int PCM_SWITCH_ENDIAN
PCM_SWITCH_SIGNED_8BITback to summary
private final int PCM_SWITCH_SIGNED_8BIT
PCM_SWITCH_SIGNED_BEback to summary
private final int PCM_SWITCH_SIGNED_BE
PCM_SWITCH_SIGNED_LEback to summary
private final int PCM_SWITCH_SIGNED_LE
PCM_UNSIGNED_BE2SIGNED_LEback to summary
private final int PCM_UNSIGNED_BE2SIGNED_LE
PCM_UNSIGNED_LE2SIGNED_BEback to summary
private final int PCM_UNSIGNED_LE2SIGNED_BE
sampleSizeInBytesback to summary
private final int sampleSizeInBytes

Constructor Detail

PCMtoPCMCodecStreamback to summary
pack-priv PCMtoPCMCodecStream(AudioInputStream stream, AudioFormat outputFormat)

Method Detail

readback to summary
public int read() throws IOException

Overrides javax.sound.sampled.AudioInputStream.read.

Note that this only works for sign conversions. Other conversions require a read of at least 2 bytes.

Annotations
@Override
Exceptions
IOException:

Doc from javax.sound.sampled.AudioInputStream.read.

if an input or output error occurs

readback to summary
public int read(byte[] b) throws IOException

Overrides javax.sound.sampled.AudioInputStream.read.

Doc from javax.sound.sampled.AudioInputStream.read.

Reads some number of bytes from the audio input stream and stores them into the buffer array b. The number of bytes actually read is returned as an integer. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

This method will always read an integral number of frames. If the length of the array is not an integral number of frames, a maximum of b.length - (b.length % frameSize) bytes will be read.

Annotations
@Override
Exceptions
IOException:
if an input or output error occurs
readback to summary
public int read(byte[] b, int off, int len) throws IOException

Overrides javax.sound.sampled.AudioInputStream.read.

Doc from javax.sound.sampled.AudioInputStream.read.

Reads up to a specified maximum number of bytes of data from the audio stream, putting them into the given byte array.

This method will always read an integral number of frames. If len does not specify an integral number of frames, a maximum of len - (len % frameSize) bytes will be read.

Annotations
@Override
Exceptions
IOException:
if an input or output error occurs
switchEndianback to summary
private void switchEndian(byte[] b, int off, int len, int readCount)
switchSigned8bitback to summary
private void switchSigned8bit(byte[] b, int off, int len, int readCount)
switchSignedBEback to summary
private void switchSignedBE(byte[] b, int off, int len, int readCount)
switchSignedLEback to summary
private void switchSignedLE(byte[] b, int off, int len, int readCount)