AudioFormatpublic class AudioFormat extends Object
Fields Summary |
---|
protected boolean | bigEndian | protected int | channels | protected Encoding | encoding | protected float | frameRate | protected int | frameSize | protected float | sampleRate | protected int | sampleSizeInBits | private HashMap | prop |
Constructors Summary |
---|
public AudioFormat(Encoding encoding, float sampleRate, int sampleSizeInBits, int channels, int frameSize, float frameRate, boolean bigEndian)
this.encoding = encoding;
this.sampleRate = sampleRate;
this.sampleSizeInBits = sampleSizeInBits;
this.channels = channels;
this.frameSize = frameSize;
this.frameRate = frameRate;
this.bigEndian = bigEndian;
| public AudioFormat(Encoding encoding, float sampleRate, int sampleSizeInBits, int channels, int frameSize, float frameRate, boolean bigEndian, Map properties)
this.encoding = encoding;
this.sampleRate = sampleRate;
this.sampleSizeInBits = sampleSizeInBits;
this.channels = channels;
this.frameSize = frameSize;
this.frameRate = frameRate;
this.bigEndian = bigEndian;
prop = new HashMap<String, Object>();
prop.putAll(properties);
| public AudioFormat(float sampleRate, int sampleSizeInBits, int channels, boolean signed, boolean bigEndian)
this.encoding = (signed? Encoding.PCM_SIGNED : Encoding.PCM_UNSIGNED);
this.sampleRate = sampleRate;
this.sampleSizeInBits = sampleSizeInBits;
this.channels = channels;
this.frameSize = sampleSizeInBits >> 3;
if ((sampleSizeInBits & 0x7) != 0) {
this.frameSize++;
}
this.frameSize *= channels;
this.frameRate = sampleRate;
this.bigEndian = bigEndian;
|
Methods Summary |
---|
public int | getChannels()
return channels;
| public javax.sound.sampled.AudioFormat$Encoding | getEncoding()
return encoding;
| public float | getFrameRate()
return frameRate;
| public int | getFrameSize()
return frameSize;
| public java.lang.Object | getProperty(java.lang.String key)
if (prop == null) {
return null;
}
return prop.get(key);
| public float | getSampleRate()
return sampleRate;
| public int | getSampleSizeInBits()
return sampleSizeInBits;
| public boolean | isBigEndian()
return bigEndian;
| public boolean | matches(javax.sound.sampled.AudioFormat format)
if (!encoding.equals(format.getEncoding()) ||
channels != format.getChannels() ||
sampleSizeInBits != format.getSampleSizeInBits() ||
frameSize != format.getFrameSize()) {
return false;
}
if (format.getSampleRate() != AudioSystem.NOT_SPECIFIED &&
sampleRate != format.getSampleRate()) {
return false;
}
if (format.getFrameRate() != AudioSystem.NOT_SPECIFIED &&
frameRate != format.getFrameRate()) {
return false;
}
if ((sampleSizeInBits > 8)
&& (bigEndian != format.isBigEndian())) {
return false;
}
return true;
| public java.util.Map | properties()
if (prop != null) {
return Collections.unmodifiableMap(prop);
} else {
return Collections.emptyMap();
}
| public java.lang.String | toString()
String ch;
switch (channels) {
case 1:
ch = "mono,"; //$NON-NLS-1$
break;
case 2:
ch = "stereo,"; //$NON-NLS-1$
default:
ch = channels + " channels, "; //$NON-NLS-1$
}
return encoding + " " + sampleRate + " Hz, " + sampleSizeInBits + " bit, " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ ch + frameSize + " bytes/frame, " + frameRate + " frames/second"; //$NON-NLS-1$ //$NON-NLS-2$
|
|