Potentially stupid question about audio callbacks


#1

I am crawling around in de Demo and Plugin Host examples looking for information on the following but still don't grasp it.

Say I initialize an AudioDeviceManager to the default AudioDevice, and add some AudioSourcePlayers as AudioCallback. So far so good, I can now play some soundfiles, and hear them through my speakers. Using a custom class inheriting AudioIODeviceCallback I can also access the samples which come into my AudioDevice through my microphone.

But if I want to somehow access the output samples before they are output, to process them (either in a callback, or using an AudioProccessor, what do I need? In the Plugin Host the input for the ProcessorGraph is still the microphone as far as I can see.

As stated in the title I might be misunderstanding the whole thing, or missing something obvious, but any direction would be welcome...

 

Thanks in advance


#2

You're on the right track, looking at the right code:

- AudioSource::getNextAudioBlock

- AudioProcessor::processBlock (Single audio buffer representing a chained input and output)

- AudioIODeviceCallback::audioDeviceIOCallback (Separate sample I/O buffers)


#3

So I could add an AudioProcessorPlayer to my AudioDevice, and set an AudioProcessor, which would then process the audio between collecting the audio from the other Players and the speakers? And this means to do a simple filter or even calculating the output level I would have to create a whole derived AudioProcessor?


#4

Can anyone shine a light on this?


#5

audioDeviceIOCallback gives you access to the input and output buffers. 

http://www.juce.com/api/classAudioIODeviceCallback.html#a9ba147cd10fe995c3016dbf35132f995


#6

Yeah but I don't think this answers my question, if I read correctly this can give me the input of the AudioDevice (ie the microphone signal) and an empty buffer which I can fill with something that will be added to the output. What I want is acces to the buffer that is going to be send to the output to add an effect or something. So I guess inheriting from AudioProcessor is a good start, but feels a bit complex for some simple operations like measuring the total outputlevel of the AudioDevice. And I do not understand how the AudioProcessorPlayer obtains the output buffer, when an audioDeviceIIOCallback does not.

Again, maybe I am looking in the wrong direction or using the wrong wording, but I hope to understand it better.


#7

Do you mean you're trying to intercept the output from other applications? If so, sorry, that's impossible! You'd need to install drivers to intercept the audio, like soundflower, etc.


#8

Ah no, not that. It is hard for me to explain it clearly by typing in a non native language. As I currently understand it the AudioDevice is similar to an analog mixer. (If we ignore input for a second) With an AudioIODeviceCallback i can add a channel. All the outputs of the AudioIODeviceCallbacks are summed to the master output, which is passed to the driver, and to the speakers et cetera. But what if I would want to put an effect on the master bus. How would I get the total mix of all the callbacks, and change it.


#9

If you have multiple streams, and you want to mix them together and then process their output, then build a graph that does exactly that. That is not what AudioIODevice is designed for - the device simply allows unrelated streams to be played at the same time.


#10

Ok thanks, I will look into that than. So I recreate everything in a graph, then add that one to the AudioDevice

 

Thanks, I think that answers my question (or at least I have something to play with now, to find out)