“32 bit float mono audio” in Jack

孤街醉人 提交于 2019-12-07 13:20:18

问题


I was playing with Jack, and I noticed that the default audio type JACK_DEFAULT_AUDIO_TYPE is set to "32 bit float mono audio".

I'm a bit confused: IEEE defines 32-bit C float range approximately from 3.4E–38 to 3.4E+38, and I was wondering what is the maximum and minimum "undistorted" amplitude that a jack_default_audio_sample_t can hold with that audio type. For example, if some DSP algorithm gives me samples in the range [0,1], how can I correctly convert between them and Jack's format?


回答1:


It's pretty common to do signal processing operations in floating point, then scale and cast the results to 16-bit or 24-bit integers before sending them to the ADC. Implementing an IIR filter, for instance, in floating point means you can reduce your sensitivity to coefficient quantization. Or if you're doing FFTs, you get greater dynamic range with floating point calculations.

The usual way of converting is to do x_float = x_int * (1.0/SHRT_MAX) when the data comes in from the ADC, and y_int = y_float * SHRT_MAX when sending to the DAC, for 16-bit codecs. For 24-bit codecs, you need to define ADC_MAX = (1 << 24) - 1.

In the case of using JACK, I guess the framework takes care of this conversion for you, so you should see floating point values in the range +/-1, and feed it back values in the same range.



来源:https://stackoverflow.com/questions/6181316/32-bit-float-mono-audio-in-jack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!