Page 3 of 4

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

Posted: Sat Sep 20, 2014 7:50 pm
by Youlean
You could try this log scaling..

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

Posted: Wed Sep 24, 2014 9:14 pm
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.

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

Posted: Thu Sep 25, 2014 3:13 am
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.

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

Posted: Thu Sep 25, 2014 6:26 pm
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...

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

Posted: Thu Sep 25, 2014 9:41 pm
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.

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

Posted: Thu Sep 25, 2014 10:01 pm
by KG_is_back
I'll just post it here I guess...

Th range limits both linear and logarithmic display.

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

Posted: Thu Sep 25, 2014 11:59 pm
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.

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

Posted: Fri Sep 26, 2014 12:13 am
by tester
Nice work KG.

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

Posted: Fri Sep 26, 2014 4:41 am
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?

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

Posted: Fri Sep 26, 2014 3:44 pm
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.