Post processing on a sum of audio sources? [SOLVED]

So my project is coming along nicely now.

But I have another problem that I don’t really understand how to tackle.

I have various audio sources computing sound information and putting that information into their getNextAudioBlock() functions.

Then I combine them with a MixerAudioSource class.

Now I wish to continue processing on that combined source.

How would I do this? I can’t figure out the logic in my head.

I tried creating a custom class that inherits from MixerAudioSource - which has its own getNextAudioBlock function. Overriding it, with my mine, copying in the existing MixerAudioSource.getNextAudioBlock() code, then below doing my own DSP after, but it doesn’t know appear to have access to the info object of MixerAudioSource.

And I’m thinking that what I want to do is common enough, there must be a standard, elegant way?

What graph/flow you’re after?
are you planning to take the summed audio and process it? or you just consider the MixerAudioSource as nice way to keep your AudioSources?

Yes I want to process them, that’s the whole reason for the problem.

Playing them together oherwise is a diddle with MixerAudioSource.addInput()

Basically I want to combine my three audio sources and then process them altogether (rather than run my DSP on all three sources independently). If MixerAudioSource is not the right way to do this, I’m fine to restructure the code.

Still I’m sorry that I don’t understand.
If you’re just after processing the summed output. you own the AudioSourceChannelInfo so just process it after the summed buffer. or am I missing something?

Could you explain how to do that? Maybe I’m getting confused by how audio callbacks work.

Because I can only set the callbacks to be received in one place (I assume)… Which I set it to be an instance of AudioSourcePlayer, which is set to take my MixerAudioSource as its source.

so just create another juce::AudioSource for example OutputSource.

  • set it to be your callback.

  • test (add debug message or whatever works for you) it gets to the getNextAudioBlock you’ve overriden.

  • now add your mixer and all its sources as members for your OutputSource.

  • make sure you add your sources to the mixer class.

  • make sure you call the prepareToPlay/getNextAudioBlock OutputSource to the mixer class.

now within your getNextAudioBlock of OutputSource. it should look like this:

void getNextAudioBlock (const AudioSourceChannelInfo &bufferToFill)
    myMixerObj.getNextAudioBlock (bufferToFill);
    // now your bufferToFill has sum of all sources
   // let's say we just want to set lower gain (for the sake of example)
   bufferToFill.buffer->applyGain (0.3f);

just remember flow goes one way. and one callback would make a “Stack” of callbacks. all are on the audio thread so don’t do allocations or locks on it.

1 Like

Ahhh yeah!! That was it. Thank you so much!