page.title=Floating-Point Audio @jd:body
Will it Float? The Glory and Shame of Floating-Point Audio
Using floating-point numbers to represent audio data can significantly enhance audio quality in high-performance audio applications. Floating point offers the following advantages:
While floating-point can enhance audio quality, it does present certain disadvantages:
Formerly, floating-point was notorious for being unavailable or slow. This is still true for low-end and embedded processors. But processors on modern mobile devices now have hardware floating-point with performance that is similar (or in some cases even faster) than integer. Modern CPUs also support SIMD (Single instruction, multiple data), which can improve performance further.
The following best practices help you avoid problems with floating-point calculations:
For floating-point audio, the audio format encoding
AudioFormat.ENCODING_PCM_FLOAT
is used similarly to
ENCODING_PCM_16_BIT
or ENCODING_PCM_8_BIT
for specifying
AudioTrack data
formats. The corresponding overloaded method AudioTrack.write()
takes in a float array to deliver data.
public int write(float[] audioData, int offsetInFloats, int sizeInFloats, int writeMode)
The following Wikipedia pages are helpful in understanding floating-point audio:
The following article provides information on those aspects of floating-point that have a direct impact on designers of computer systems: