signal processing - Plotting an audio spectrum -
i'm trying implement app plot spectrum of audio using bass audio (http://www.un4seen.com/). understanding have to:
get fft data stream float[] buffer = new float[256]; bass.bass_channelgetdata(handle, buffer, (int)(bass_data_fft_complex|bass_data_fft_nowindow));
for each fft, compute it’s magnitude
apply window function fft (hanning or hamming do)
then, draw beautiful spectrum analysis
the problem that:
- it seems bass_data_fft_complex bassdata isn't reachable. can see supposed available in documentation http://www.bass.radio42.com/help/html/a13cfef0-1056-bb94-81c4-a4fdf21bd463.htm cannot use since error bassdata not include such enum
- further, i'm wondering if i'm doing right. plot spectrum, should plot magnitude of fft or plat magnitude of fft against frequency of fft? in case, how frequency corresponding fft? don't mind code snipped language (c/c++, c#, vb, java, etc..)
note: i'm not sure if helps i'm using: plotting using microsoft chart control. c# bass.net api http://www.bass.radio42.com/ , suggestions in appreciated
you have mixed order of steps - need apply window function time domain data before calculating fft. steps typically:
1. acquire time domain data 2. apply window function 3. calculate fft 4. calculate log magnitude of fft (log(re*re+im*im)) 5. plot log magnitude (with appropriate scaling) against frequency
note using log magnitude y axis gives db
scale, more natural , useful way view sound amplitude linear magnitude scale.
normally visualizing audio etc apply steps 1 - 5 above on successive blocks of time domain data, typically overlap of 50%.
Comments
Post a Comment