Native Own Reverb Plugin

Hi

I’ve been developing Native Audio Spatializer for Unity.

Things I want to implement are described as below:

  1. Each audio source should pass through spatializer filter.
  2. Audio datas from multiple audio sources should be synthesized before passing through reverb filter

1 was not that difficult since there is a example source.
However, 2 is what I’ve been stuck with…

What exactly are you stuck with? Do you want to get the data that passes through the audio sources?

Sorry that I didn’t explain quite well…

To explain more:

  1. Suppose that there are multiple AudioSources and both AudioClip and output mixer group(my native reverb audio plugin attached) are assigned to each AudioSources.
  2. When playing, each AudioClip’s audio chunk data will be passed to my native spatializer plugin first.
  3. Then, all processed audio data will be synthesized and sent to the plugin within the mixer group.

What I want to do is
to store all original audio data chunks at each audio frame into a variable within my native reverb audio plugin before my native spatializer plugin processes audio data

And I don’t know how to do that…

I’m not so familiar with mixergroups although I know that you can get the audiodata that passes through the audiosource by using OnAudioFilterRead. Look this page for more information: Unity - Scripting API: MonoBehaviour.OnAudioFilterRead(float[], int)

The idea is that you get your data from the buffer, do some processing with it and feed it back to the buffer. The example on the page shows how to change the overall volume (gain) of the incoming audiodata. All is happening in realtime by the way. You could use that same principle to change the data anyway you want. Lets say you have setup an audiosource and also the clip variable of it, and then you call audiosource.Play. From that moment on the data gets passed through the OnAudioFilterRead function and you can modify/store it.

Here’s an example of how your code might look:

void OnAudioFilterRead(float[] data, int channels)
{
     for (int i = 0; i < data.Length; ++i)
     {
         data[i] = CreateReverb(data[i]); //pass data to your reverb function
     }
}

float CreateReverb(float data)
{
    //do something with the data
    return data;
}

I guess you have to do some experimenting first to get a general idea of how it works, and then change your code so it satisfies the conditions you are after. If my example doesn’t make any sense let me know and we’ll figure out a different way to get the point across :stuck_out_tongue:

Hi again, willemsenzo.

Audio data is passed to Spatializer plugin before OnAudioFilterRead.
Thus, with OnAudioFilterRead, I can’t do what I want to :frowning: