Friday 15 January 2010

c++ - Drawing audio spectrum with Bass library -


How to Can I draw a spectrum for a given audio file ?

I mean the chart originating from Audacity: Enter image details here < / P>

I know that I can get FFT data for a given time t (when I play audio):

  float fft [1024]; BASS_ChannelGetData (chan, fft, BASS_DATA_FFT2048); // Get FFT data   

In this way, every time I get 1024 values ​​in the array for t . Am I right that the values ​​of that array are signal inductees ( DB )? If so, how is the frequency ( Hz ) associated to those values? From the index?

I am a programmer, but I have not experienced anything with audio processing at all. So I do not know what is necessary, with the data, to plot the necessary spectrum.

I am working with the version C ++, but examples in other languages ​​are just fine (I can change them).

From the documentation, the flag will be calculated due to the FFT quantity, and this is linear magnitude .

  db = 10 * log 10 (intensity); DB = 20 * Lose 10 (pressure);  

(I'm not sure whether the audio file sample is a measure of intensity or pressure. How is a microphone output related?)

In addition, point to it Does the length of input and length of FFT match, but half FFT (related to negative frequencies) are discarded. Therefore, the highest FFT frequency will be a half sample frequency. It happens in N / 2 Doc actually says

For example, with 2048 sample FFT, 1024 will return floating-point values. If the BASS_DATA_FIXED flag is used, then the FFT value will be in the 8.24 fixed-point form, whereas floating-point each value, or "bin" from 0 to 1 (can actually go higher if sample data is floating-point And not clap) 1 bin consists of a DC component, in the second, the sample rate of the channel is dimension 1/2048, after which the dimension 2/2048, 3/2048 etc. occurs.

This is very clear.


No comments:

Post a Comment