Vertical Bar/Line FFT/Spectrum Display- Feasible?

For general discussion related FlowStone
Youlean
Posts: 176
Joined: Mon Jun 09, 2014 2:49 pm

Re: Vertical Bar/Line FFT/Spectrum Display- Feasible?

Post by Youlean »

You could try this log scaling..
Attachments
Log Scaling.fsm
(449 Bytes) Downloaded 1112 times
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Vertical Bar/Line FFT/Spectrum Display- Feasible?

Post by KG_is_back »

Perfect Human Interface wrote:Wow KG, this thing is pretty. I changed the multiplier value going into the bar graph module to 0.05 for better visibility. I did notice the scaling seems a bit odd though.
FFT Scale.PNG

Even with the log scaling, the higher frequencies get a lot more space. Tried screwing with the math here but apparently don't know what I'm doing. Maybe it's a log base other than 10 on the PEQ2 meter?

Could alpha blending be added to the draw function easily? For example if I want it to blend between a full transparent and a solid color at max value?

One last thing: This would definitely benefit from a smoothed "release" for those transient sounds.

About time I open a book on Ruby I guess. I've been putting it off as long as possible. :P

Edit: Thinking the scale is log base 2, since that's what pitch is based on. How to apply log math to arrays though? I guess you'd just use Ruby for that too.


Oh, totally missed this post :-D wow....
well... logarithms are just multiplied versions of each other.
to convert linear 0-1 to logz(x) that is also in 0-1 (the Z reffers to base of the logarithm)
you just scale the input to be in 1-z range ( x = 1+x*(z-1) ) and then preform log z on that number.
I will update the module on FSguru right away.
Perfect Human Interface
Posts: 643
Joined: Sun Mar 10, 2013 7:32 pm

Re: Vertical Bar/Line FFT/Spectrum Display- Feasible?

Post by Perfect Human Interface »

KG_is_back wrote:scale the input to be in 1-z range ( x = 1+x*(z-1) ) and then preform log z on that number.
I will update the module on FSguru right away.


I actually tried this earlier and log base 2 wasn't good. The goal is to scale it to octaves, such that when you move up and down notes or octaves on the input, the display is scaled linearly. Octaves are based on doubles, so an octave above 400 hz is 800 hz, and an octave above that is 1600 hz. With that in mind, I think it is something to do with 2^x, but I couldn't figure it out.
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Vertical Bar/Line FFT/Spectrum Display- Feasible?

Post by KG_is_back »

Now that I think of it... bins in FFT array are frequencies:
0th value is DC, last value is Nyqist. DC is zero hertz so it should be in the negative infinity on the octave based scale. (that is the first wrong thin in my schematic - DC is simply in the left side)
Nyquist however should have its proper position on the left side of the graph (possibly even outside of view when higher sample rates). Lets define two frequencies that should be the boundaries of our bar graph (20Hz-20kHz).
Now we do not draw the full FFT spectrum only the 20-20k part. We can calculate the index (probably not be integer value) of 20Hz and 20kHz from sample rate and FFT window size.
I have it working now... will post it to FS Guru in short moment...
Perfect Human Interface
Posts: 643
Joined: Sun Mar 10, 2013 7:32 pm

Re: Vertical Bar/Line FFT/Spectrum Display- Feasible?

Post by Perfect Human Interface »

Ah, excited to see it. Too bad the site is down currently.

I was wondering what the frequency range was. Big thanks for looking into this, and for putting the thing together in the first place.
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Vertical Bar/Line FFT/Spectrum Display- Feasible?

Post by KG_is_back »

I'll just post it here I guess...

Th range limits both linear and logarithmic display.
Attachments
bargraph.fsm
(31.33 KiB) Downloaded 1136 times
Perfect Human Interface
Posts: 643
Joined: Sun Mar 10, 2013 7:32 pm

Re: Vertical Bar/Line FFT/Spectrum Display- Feasible?

Post by Perfect Human Interface »

Looks good! Seems to resemble the IL one most with a 2048 sample size. It's not exactly light on CPU overall but I doubt that can be helped (obviously less samples and less triggers make a big difference).

So it looks like the math was just scaled by taking the log2 then? I'm probably going to be drawing on top of this for filter cutoffs, so hopefully if I just take a normalized 0-1 frequency and do log2(x+1) that should do it.
tester
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: Vertical Bar/Line FFT/Spectrum Display- Feasible?

Post by tester »

Nice work KG.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Perfect Human Interface
Posts: 643
Joined: Sun Mar 10, 2013 7:32 pm

Re: Vertical Bar/Line FFT/Spectrum Display- Feasible?

Post by Perfect Human Interface »

Hmm I have noticed another oddity in this. It seems louder (or higher amplitude) signals seem to push back the other drawn frequencies. So, for example, when the kick hits, the higher frequencies fade out (lower frequencies are generally greater amplitude at the same volume).

It doesn't look like this happens with the original version you uploaded, KG. Did you perhaps add something to limit the range of bar intensity?
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Vertical Bar/Line FFT/Spectrum Display- Feasible?

Post by KG_is_back »

Perfect Human Interface wrote:Hmm I have noticed another oddity in this. It seems louder (or higher amplitude) signals seem to push back the other drawn frequencies. So, for example, when the kick hits, the higher frequencies fade out (lower frequencies are generally greater amplitude at the same volume).

It doesn't look like this happens with the original version you uploaded, KG. Did you perhaps add something to limit the range of bar intensity?


I'm not aware of anything that may cause that. I didn't change anything that would affect Y input. What I've done though is that I now resize the Y array, so there is actually less strips and therefore they are wider.
Post Reply