Hi Guys, I want spectrum analyzer to show in my ImGUI script, but I need a JSFX to process the samples and then feed that into ImGUI. I've looked into "Frequency Spectrum Analyzer Meter (Cockos)", I think the bit that extracts audio information into a frequency spectrum would be the @block and @sample sections? Would someone please be so kind to briefly explain what these few lines are doing, and what variables I need to put into gmem to transfer that data to ImGUI? ---the code is here--- @block slider2 != lfloor ? ( lfloor = slider2; minvol=2*exp(log(10)/20*slider2); ); @sample abs(recpos[]=spl0) > minvol ? update=1; recpos = ((recpos+1) >= histsize ? 0 : (recpos+1)); abs(recpos2[]=spl1) > minvol ? update=1; recpos2 = ((recpos2+1) >= histsize2 ? shift : (recpos2+1)); Thanks very much!!
Well, recpos[0..histsize-1] contains the time-domain samples, but these are transformed to the frequency domain in @gfx; look for fft_real(). This frequency-domain data is probably what you need. BTW, the original gfxanalyzer is mono (spl0+spl1), but the code you posted seems to support 2 separate channels.
Hi Tale, Thanks for the reply! I found the fft_real line: fft_real(fftworkspace,fftsize); fft_permute(fftworkspace,fftsize/2); and here are the lines that defines fftworkspcae: histsize=max_fft_size + (max_fft_size*0.5 - 1); window=histsize; fftworkspace=window+(max_fft_size*0.5 + 1); Still quite clueless on what's going on in this script despite taking another hour or so today studying it and reading the jsfx introduction page on Reaper's official site... Just wondering how you learned it? Any recommended source? Thanks!
OK I feel like I should make my question more specific, is the fft line going to return something like an array of numbers for each frequency? and the fft size is basically how many bands it has? So if size is 16, it will return 16 numbers in an array..? But where do I retrieve that number..? Sorry I have so many questions, really really appreciate it if someone can help me out!
I might be wrong but I think you need to do a stft ( fft will return the energy across all the audio ). I know little about DSP but I think this video might lead you in the right way
Thanks for the inputs! I've made it work with copying lines from the original jsfx, still have many things that I don't understand on the math side of things, I'll learn about it slowly I guess. Just one more question, because the part that sends the fft information is written in @gfx, it'll only send information when the fx window is open. I moved it to the @block section, and it now can send information while it's closed, but it becomes more cpu intensive, as it's processing information in a much higher frequency. I'm wondering if there's a way to limit the update frequency in @block section...? Thanks!!
You can just increment a counter in @block, reset to 0 when it gets to whatever number you want, and then only run the actual code when that counter equals 0.