Class PcmFormat
java.lang.Object
javax.sound.sampled.AudioFormat
net.avadeaux.klipspringer.codec.PcmFormat
Audio format specification that extends
AudioFormat with some convenience functions and
restrictions. The sample size (frame size divided by number of channels) must be 1 or 2 for bit
depth 8 or smaller, 2 for bit depth 9 to 16, 3 or 4 for bit depth 17 to 24, and 4 for bit depth
25 to 32. Bit depth larger than 32 is not allowed. Attempting to construct a PCM format that
does not conform to these rules results in exception. The additional field for significant bits
per sample should normally be equal to bits per sample, but may be smaller if the bit depth has
been scaled up by left shifting, in which case the significant number of bits should be
displayed as the actual quality.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface for selecting a quality-compatible audio format.Nested classes/interfaces inherited from class javax.sound.sampled.AudioFormat
AudioFormat.Encoding -
Field Summary
FieldsFields inherited from class javax.sound.sampled.AudioFormat
bigEndian, channels, encoding, frameRate, frameSize, sampleRate, sampleSizeInBits -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintDesired byte-alignment for data of this format.booleanbigend()Is big-endian, alias forAudioFormat.isBigEndian().intbips()Bits per sample, alias forAudioFormat.getSampleSizeInBits().intbyps()Bytes per sample, ceiling ofbips()/8.intchannels()Number of channels, alias forAudioFormat.getChannels().intfs()Frame size, alias forAudioFormat.getFrameSize().booleanmatchesQuality(PcmFormat that) Checks if formats match in sample rate, bits per channel, and number of channels.static PcmFormatof(AudioFormat format) Gets a PCM format specified by standardAudioFormatstatic PcmFormatof(AudioFormat format, int rate) Gets a PCM format specified by standardAudioFormat, with specified sample rate in case it is unspecified in the given format.order()intrate()Same value asAudioFormat.getSampleRate()but cast to int.booleansigned()Boolean alternative toAudioFormat.getEncoding().intSignificant bits per sample.intss()Number of bytes allocated per sample, fs divided by channels.Methods inherited from class javax.sound.sampled.AudioFormat
getChannels, getEncoding, getFrameRate, getFrameSize, getProperty, getSampleRate, getSampleSizeInBits, isBigEndian, matches, properties, toString
-
Field Details
-
MAX_FS
public static final int MAX_FSMaximum accepted frame size.- See Also:
-
-
Constructor Details
-
PcmFormat
public PcmFormat(int rate, int bips, int channels, boolean signed, int fs, ByteOrder order, int significantBips) Constructor that specifies all fields. -
PcmFormat
public PcmFormat(int rate, int bips, int channels) Constructor that specifies sound quality and sets other parameters to standard values.
-
-
Method Details
-
rate
public int rate()Same value asAudioFormat.getSampleRate()but cast to int. -
bips
public int bips()Bits per sample, alias forAudioFormat.getSampleSizeInBits(). -
significantBips
public int significantBips()Significant bits per sample. Returns the same value asbips()unless the sample values have been scaled up from a smaller bit depth, in which case this is the original bit depth. -
byps
public int byps()Bytes per sample, ceiling ofbips()/8. -
alignment
public int alignment()Desired byte-alignment for data of this format. The lowest set bit ofbyps(). -
channels
public int channels()Number of channels, alias forAudioFormat.getChannels(). -
signed
public boolean signed()Boolean alternative toAudioFormat.getEncoding(). -
ss
public int ss()Number of bytes allocated per sample, fs divided by channels. -
fs
public int fs()Frame size, alias forAudioFormat.getFrameSize(). -
bigend
public boolean bigend()Is big-endian, alias forAudioFormat.isBigEndian(). -
order
-
matchesQuality
Checks if formats match in sample rate, bits per channel, and number of channels. -
of
Gets a PCM format specified by standardAudioFormat, with specified sample rate in case it is unspecified in the given format.- Throws:
UnsupportedFormatException
-
of
Gets a PCM format specified by standardAudioFormat- Throws:
UnsupportedFormatException
-