Question about sample rate and frame rate sizes with Java Sound API
I inherited some code that uses Java's SourceDataLine Sound API.
Below is how they setup the AudioFormat object. It seems strange that the frame-rate and sample-rate were set to be the same. Does that make any sense? Also, is there any point to have a 20000000 frame rate or sample rate? Don't our ears top out at like 20000?
AudioFormat开发者_开发问答 af = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 20000000, 16, 1, 2, 20000000, true);
If the stream is encoded in PCM format and is not compressed, a frame contains the samples for each channel, for one time index. If the stream is compressed, a frame contains the samples for each channel, but for one or more time indexes. The exact structure of the frame depends on the compression type.
Check out AudioFormat class definition for more details: http://download.oracle.com/javase/6/docs/api/javax/sound/sampled/AudioFormat.html
Most sound systems consider the top frequency for the human ear 22KHz, that's why you get the sampling frequency 44KHz (according to the Niquist rule).
精彩评论