Logarithmic Spectrum Analyzer

For general discussion related FlowStone
Post Reply
SBAudio
Posts: 6
Joined: Tue Jan 14, 2014 10:40 pm
Contact:

Logarithmic Spectrum Analyzer

Post by SBAudio »

Hello everybody! First time poster, long time creeper here (and synthmaker too) 8-), and I figured It was finally time to ask for help.

So basically, I'm making a spectrum analyzer and I can't seem to figure out how to transform the frequency axis from linear to logarithmic. I'm not using the graph lines module, but using a draw loop to assign values from the FFT to color intensity of single lines. If anyone can give me some pointers, I'd be eternally grateful!

-Luke
Attachments
Display.fsm
(83.16 KiB) Downloaded 1016 times
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Logarithmic Spectrum Analyzer

Post by KG_is_back »

Here you go. I reworked your x-indexing system a little. The draw loop outputs 0-1 (1/N) being the step), which is in case of linear scale multiplied by width and in case of logarithmic scaled by y=log10(1+x*9) which also outputs 0-1 but logarithmically scaled. That is also multiplied by width and viola...log scaled window. Also I had to redo the line widths, bacause in case of lin scaled the bar should be 1/N wide, but in case of logarithmic the width varies (lower bars are thicker than higher ones).
Attachments
Display_linlog.osm
(21.96 KiB) Downloaded 984 times
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Logarithmic Spectrum Analyzer

Post by KG_is_back »

However the problem with your method is, that lines are drawn from center to sides...this is OK when drawing linear graphs but in logarithmic the width of the line to left should be different than width to right. So it is better to use rectangles instead of lines. Here - this one uses rectangles instead of lines - the width of all rectagles is width of the window, but ther x-offset changes. Rectangles of high frequencies overlap the right-side of the rectangle, so no rectangle-width correction is needed.
Attachments
Display_linlog.osm
(21.83 KiB) Downloaded 1063 times
tester
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: Logarithmic Spectrum Analyzer

Post by tester »

This will not start in synthmaker, it uses FS components.
Loads only in FS, so it's better to rename ext to fsm.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
SBAudio
Posts: 6
Joined: Tue Jan 14, 2014 10:40 pm
Contact:

Re: Logarithmic Spectrum Analyzer

Post by SBAudio »

Thanks for explaining, I understand much better now! I think using lines was messing with my head or something, but yours works great!
Post Reply