0
0

Hello all,

we are trying to do the following operations with fmod, possibly using multiple soundcards/devices as input sources:
– record input signals from input source(s)
– analyse the input signals "on the fly", or as close to "real-time" as possible (for signal detection, volume & frequency detection, also fader/balance)

While some of these things seem to be done by fmod, are such things its focus? Or are we better off working with another sound API altogether?

Thank you!
ACG

  • You must to post comments
0
0

Hello,

I would also appreciate an answer to this question.
Since FMOD’s primary focus seems to be game development (and most of the documentation and examples target that area), I would like to ask if FMOD can also be used for analysing input signals or if it is totally unsuited for this task.

Thanks in advance.

  • You must to post comments
0
0

Hi guys,

@acgrama
[quote:iuh2ccnk]analyse the input signals "on the fly", or as close to "real-time" as possible (for signal detection, volume & frequency detection, also fader/balance) [/quote:iuh2ccnk]
An instance of a signal in FMOD is a channel. FMOD::Channel has a getSpectrum function which can be used for frequency detection. It is quite flexible. Although there is no inbuilt DSP unit for detecting volume and fader balance, since they’re so simple it would be trivial to implement these as user DSP units.

Here is the interface for getSpectrum:
[code:iuh2ccnk]FMOD_RESULT Channel::getSpectrum(
float * spectrumarray,
int numvalues,
int channeloffset,
FMOD_DSP_FFT_WINDOW windowtype
);

spectrumarray
Address of a variable that receives the spectrum data. This is an array of floating point values. Data will range is 0.0 to 1.0. Decibels = 10.0f * (float)log10(val) * 2.0f; See remarks for what the data represents.

numvalues
Size of array in floating point values being passed to the function. Must be a power of 2. (ie 128/256/512 etc). Min = 64. Max = 8192.

channeloffset
Channel of the signal to analyze. If the signal is multichannel (such as a stereo output), then this value represents which channel to analyze. On a stereo signal 0 = left, 1 = right.

windowtype
"Pre-FFT" window method. This filters the PCM data before entering the spectrum analyzer to reduce transient frequency error for more accurate results. See FMOD_DSP_FFT_WINDOW for different types of fft window techniques possible and for a more detailed explanation. [/code:iuh2ccnk]

@heapifyman
[quote:iuh2ccnk]I would like to ask if FMOD can also be used for analysing input signals or if it is totally unsuited for this task. [/quote:iuh2ccnk]
FMOD is used for many non-game applications because it’s a high performance sound engine. The features which make it good for game development don’t hinder it’s ability to perform standard tasks. If there are any features you require which aren’t built in, the API is very extensible and user friendly so it’s easy to add whatever you need.

-Pete

  • You must to post comments
0
0

Thank you, Peter, for your reply! This puts us closer to the right track, I think :-)

  • You must to post comments
0
0

Thanks for the quick reply, Peter.

I think the getSpectrum function might be what we were looking for.
Is there more documentation available on this apart from the API doc? Especially when working with multichannel signals and ideally with some code examples?

I’d appreciate any hints as to where to start looking.
Thanks again

  • You must to post comments
0
0

[quote:thoegfj7]Is there more documentation available on this apart from the API doc[/quote:thoegfj7]
No there is only the API doc, but I only quoted half of it. Here is the rest:
[quote:thoegfj7]
Remarks

The larger the numvalues, the more CPU the FFT will take. Choose the right value to trade off between accuracy / speed.
The larger the numvalues, the more ‘lag’ the spectrum will seem to inherit. This is because the FFT window size stretches the analysis back in time to what was already played. For example if the numvalues size happened to be 44100 and the output rate was 44100 it would be analyzing the past second of data, and giving you the average spectrum over that time period.
If you are not displaying the result in dB, then the data may seem smaller than it should be. To display it you may want to normalize the data – that is, find the maximum value in the resulting spectrum, and scale all values in the array by 1 / max. (ie if the max was 0.5f, then it would become 1).
To get the spectrum for both channels of a stereo signal, call this function twice, once with channeloffset = 0, and again with channeloffset = 1. Then add the spectrums together and divide by 2 to get the average spectrum for both channels.

What the data represents.
To work out what each entry in the array represents, use this formula

entry_hz = (output_rate / 2) / numvalues

The array represents amplitudes of each frequency band from 0hz to the nyquist rate. The nyquist rate is equal to the output rate divided by 2.
For example when FMOD is set to 44100hz output, the range of represented frequencies will be 0hz to 22049hz, a total of 22050hz represented.
If in the same example, 1024 was passed to this function as the numvalues, each entry’s contribution would be as follows.
entry_hz = (44100 / 2) / 1024
entry_hz = 21.53 hz

Note: This function only displays data for sounds playing that were created with FMOD_SOFTWARE. FMOD_HARDWARE based sounds are played using the sound card driver and are not accessable. [/quote:thoegfj7]

[quote:thoegfj7]Especially when working with multichannel signals and ideally with some code examples? [/quote:thoegfj7]
The get spectrum function is used in the pitchdetection example and and the dsppluginviewer example. This should give you a good idea of how to use it. The dsppluginviewer draws the frequency spectrum for multichannel sounds.

-Pete

  • You must to post comments
0
0

[quote="peter":227iikzn]
The get spectrum function is used in the pitchdetection example and and the dsppluginviewer example. This should give you a good idea of how to use it. The dsppluginviewer draws the frequency spectrum for multichannel sounds.
[/quote:227iikzn]

So, regarding the getSpectrum API documentation it states for channeloffset that "On a stereo signal 0 = left, 1 = right"
But I couldn’t find any doc on signals with more channels (e.g. 5.1). Using a channel offset of 3 does give a result but to which "speaker" does it correspond to?

Any hints would be appreciated.
Thanks in advance.

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.