Loss of sound when using ofxSoundObjects-AudioUnit with ofxSoundMatrixMixer

This is a bit of a specific question, but I’m using the ofxSoundObjects addon in combination with the ofxSoundObjects-AudioUnit addon to bridge the gap between ofxSoundObjects and ofxAudioUnit. Everything seems to be working for most contexts, but when I connect a chain containing ofxAudioUnits to an ofxSoundMatrixMixer, I don’t get any sound. I’ve tested the exact same chain with an ofxSoundOutput at the end instead, and that worked, but when I change the terminal component to a MatrixMixer, I don’t get any sound. I have also tested the same chain terminating in a MatrixMixer but without any ofxAudioUnits, and that also works. It is only when an ofxAudioUnit and a MatrixMixer are in the same chain that audio fails.
Placing a VUMeter early in the chain reveals that not only is audio not making it to the output, but it’s not making it to the VUMeter, which seems to indicate that MatrixMixer just isn’t pulling samples from further up in the chain?
Here’s what my audio chains look like:

//These are the objects that are in use:
    ofxSoundPlayerObject soundPlayer;
    ofxSoundObjectAudioUnitBridge fromAU, toAU;
    ofxAudioUnit AUreverb;
    ofxAudioUnitTap AUtap;
    VUMeter vuMeter;
    ofSoundStream soundStream;
    ofxSoundMatrixMixer matrixMixer;
    ofxSoundOutput soundOutput; 

//These are the different ways that I've connected them. I've omitted the obvious setup stuff:
   //Method 1: this one works, but doesn't allow for multi-channel output
   soundPlayer.connectTo(toAU);
   toAU.connectToAU(AUreverb);
   AUreverb.connectTo(AUtap);
   AUtap.connectTo(fromAU);
   fromAU.connectTo(vuMeter).connectTo(soundOutput);

   //Method 2: this one works, but doesn't include any ofxAudioUnits:
   soundPlayer.connectTo(vuMeter).connectTo(matrixMixer);

   //Method 3: this is the one I would like, but it doesn't work
   soundPlayer.connectTo(toAU);
   toAU.connectToAU(AUreverb);
   AUreverb.connectTo(AUtap);
   AUtap.connectTo(fromAU);
   fromAU.connectTo(vuMeter).connectTo(matrixMixer);

Found a strange solution. I placed a VUMeter further up the chain in the Method 3 chain to see whether any samples were being pulled through at an earlier stage. After doing this, Method 3 looked like this:

   soundPlayer.connectTo(vuMeter).connectTo(toAU);
   toAU.connectToAU(AUreverb);
   AUreverb.connectTo(AUtap);
   AUtap.connectTo(fromAU);
   fromAU.connectTo(matrixMixer);

…and now it works. I don’t fully understand why, other than that maybe toAU, which is an ofxSoundObjectAudioUnitBridge wasn’t pulling samples from the soundPlayer for some reason, but vuMeter manages to do it. Again, no idea why it’s working now, but it is. Just putting this here for anyone who might have this problem in the future.

1 Like

hi. I just noticed this post.
next time just ping me.
I will take a look at it…

1 Like

Hi @roymacdonald, thanks for offering to look into it. Has anything turned up since then? I’m still stuck on this. I realised that it wasn’t actually working the way that I thought it was in my second post. I was getting audio out because of a typo I made elsewhere, but I’m still not getting audio in the configuration that I’ve described in the first post.

Hi @sdnorris I have not. As far as I recall, the way in which the matrix mixer has to pull the data through it might be breaking the way that the audio unit works. I will be using a configuration very similar to yours on an upcoming project by the end of this month, but right now I am busy on something else.
Nonetheless, there is a matrix mixer in the default AudioUnits. Have you tried it?
Or, do you need the matrix mixer just to have access to all output channels?

I have taken a look at the matrix mixer in AudioUnit, and it doesn’t have any documentation so I’m not really sure how to use it. I’ll try getting in touch with the developer and see if I can make a start with it, though.

I need a matrix mixer to set the output levels of many different objects in many different channels dependent upon the position of the objects on a display. This was working well with the ofxSoundMatrixMixer, but yeah I’m not sure how to apply that to the ofxAudioUnitMatrixMixer.
I’ll give it a shot, but do update if you make any progress with it on your own project if you have the time in the future!
Thanks

@roymacdonald, is there any other way to connect one audio source (e.g. a sound player) to multiple sound objects? In order to get around the issues I’ve been having with the MatrixMixer, I tried to mimic the funcionality of a matrix mixer using the ofxSoundMultiplexer, but this also doesn’t seem to be working.

As a test, I tried to connect an ofxSoundPlayer to a group of two channels in an ofxSoundBaseMultiplexer, and then connect each channel to a different channel on an ofxSoundOutputMultiplexer, like so:

//test: send left channel of input to right channel of output, and vice versa
soundPlayer.connectTo(soundBaseMultiplexer.getOrCreateChannelGroup({0,1}));
soundBaseMultiplexer.getOrCreateChannel(0).connectTo(soundOutputMultiplexer.getOrCreateChannel({1}));
soundBaseMultiplexer.getOrCreateChannel(1).connectTo(soundOutputMultiplexer.getOrCreateChannel({0}));

That didn’t work. I didn’t hear any audio. I can only get sound output when I do something like the following:

soundPlayer.connectTo(soundBaseMultiplexer.getOrCreateChannelGroup({0,1}));
soundBaseMultiplexer.getOrCreateChannelGroup({0,1}).connectTo(soundOutputMultiplexer.getOrCreateChannel({0,1}));

In this latter example, I’m just connecting a 2-channel multiplexer to a stereo output. Despite my input audio being connected to two channels on the first multiplexer, I can’t actually use that multiplexer to route individual channels to different places, which makes it feel kind of redundant. Is there anyway to split an audio source to a bunch of different objects?

Hi,
the multiplexer is intended to split the channels of a multichannel source so you can connect each channel to a different sound object.
I thought that there was something like that already in there, but thinking on how to implement it , it has several tricky things that need to be properly addressed.
BTW, you might also want to test the experimental branch, as it has several more updates and changes.
Let me think on how to implement this properly and I will reach back.

1 Like

Ah okay, so the multiplexer expects a multichannel source, i.e. it doesn’t duplicate the channels of a mono source, gotcha.
Also I tried doing the same setup as before (connecting ofxSoundObjectAudioUnitBridge to a matrix mixer) using the experimental branch of ofxSoundObjects, but still no luck unfortunately. I can see that

right. so, the soundstream is literaly a data stream where the samples of each channel are interlaced, so in order to access an individual channel as a buffer you need to use the multiplexer to disentangle the samples and get the ones from the channel you need as a single continuous block of samples.

The way that ofxSoundObjects works is that it “pulls” sound data from the output. This is, the output requests for data to whatever it has connected, where this other does the same , and so on untill it reaches an input or the end of the chain.
Now the problem with audiounits is that these work in the opposite way, so I had to make an adaptor to deal with such. But when you use a matrix mixer, because of its very nature it needs to “break” and rebuild this pull through pattern, which is what I guess is conflicting with the audio units. This is just a conjecture but most probably what is going on.