We’re using F-mod for a school project and we’re using sound properties to make particles react to it.
I got the idea how to get the spectrum thanks to this post :
I used the code on this page to learn and it worked, but only when the sound was on my left, I hear sound in 3d, but it only gives me data when I hear it on the left side.
I also printed on the console the FMOD.DSP_FFT.DOMINANT_FREQ and it returns 0 when the sound is coming from another way than left.
So I’m a bit lost, I tried to get into channels but I just don’t understand how to use them, how to play an instance in a channel …
I tried to get into the low level api reference but it is really not newbie friendly
I hope someone can help me understand how this mysterious channel thing is working and tell me why only left sounds give me datas !
Thank you very much !
I think a lot of your issue is that you’re processing the signal (in the FFT dsp) AFTER it has been panned in 3D. This makes the dsp signal if the sound gets too far away.
If you put it BEFORE the panner, you’d get the full strength signal
for example (copied from the unity link you provided above)
If you don’t want to do that, and are just more interested why you’re only getting it on the left side and not the right side, then I just looked it up, and it seems that the dominant frequency is only processing the first channel of a multi-channel signal! I’ll have to get this fixed.
If you put the fft pre-panner like I said above, it should be a mono signal anyway so that should work correctly.
You can get the same result from the raw spectrum data if you want to do it yourself. I will paste the dominant frequency code here
// mSystem = System object.
// ‘length’ and ‘spectrum’ = from FMOD_DSP_PARAMETER_FFT see https://www.fmod.com/resources/documentation-api?page=content/generated/FMOD_DSP_PARAMETER_FFT.html
nyquist = length / 2;
float average = 0.0f;
float power = 0.0f;
for (int i = 0; i < nyquist-1; ++i)
float hz = i * (rate * 0.5f) / (nyquist-1);
if (spectrum[i] > 0.0001f) // aritrary cutoff to filter out noise
average += spectrum[i] * hz;
power += spectrum[i];
if (power > 0.001f)
*dominant = average / power;
*dominant = 0;
Hello, thank you very much Brett for taking the time to reply during the week-end !
I thought I tried the tail thing but no, and it is working perfectly !
I’m feeling a bit dumb now
Also, thank your for the code you posted, I’ll dive into it because it could add some richness to our sound visualisation system.
Thanks again for the quick reply !