Using multiple sound cards

Hi there,
Has anyone been able to allocate channels to separate sound cards?
If you have id love to know how you’ve managed it.
This is a great way to create immersive installations with gear that we all horde, so it would be great to be able to explore this.
Any info would be graciously received :smile:

If you’re on OS X, you can create an “aggregate” device that manages multiple hardware sound outputs. It’s not 100% rock solid in my experience, though it can be a way to do this.

(open Audio MIDI Setup.app, click the + in the bottom left)

Ah ok, thanks.
In oF would I then be able to have control over the routing of the channels?
I vaguely remember coming across a post talking about being able to have multiple instances of ofsoundstream called from ofApp and then route from there. That pushes me further into a realm of the unknown. Theoretically though would that mean that sound card outputs could be assigned to ofsoundstream instances?

If you create an aggregated device in OS X it will behave like a single Sound Card (I think the order of the channels is defined during the creation of the aggregate device).
In oF the interleaved channels would come from a single ofSoundStream using that aggregate device, so to send sound to channel J you’d do as usual:

ofApp::audioOut(float * output; int bufferSize; int nChannels) {
   
    for (int i = 0; i< bufferSize; i++){
    output[i *nChannels + J-1] = mySound.tick();
    }
}

(mySound.tick() being replaced by whatever you want to send.
The “J-1” is because channels start at 0 in oF)

thats great, thank you.
Im starting work on a guerrilla 3d sound array and I’ve got a few old sound cards lying around so this’ll be perfect.
@danomatika ill be using ofxpd (as usual) so i should be able to just set thenumber of output channels in ofxpd to the same number as the aggregate device right?
I haven’t worked with more than stereo in pd before do i have to use multiple days or something?
Thanks all!!

It should work. Just give ofxPd the same number of channels as ofSoundstream. An aggregate device is not going to provide you with a very low latency since the OS has to try and synchronize different devices.

Thanks guys, worked a charm!

All I’ve done for a test is connect up some oscillators to the dacs and already my office has turned into a strange accidental sound installation.

Im looking to make some of this easier to implement, mainly just routing so that it makes it easier to set up a virtual sound space with a view to including micro delays and more advanced positioning

I’m gonna do a bit of shameless self-promotion, you could try the HOA library for sound spatialisation! It exists both for oF and pure data

not shameless at all, very useful!
ill be giving it a go soon

1 Like

@cabral1349, i tried your examples and the sound spatialization is very cool!
Anyway i’m not very good to work with audio and i don’t understand how to play 10 different tracks with ofSoundPlayer and how spatialize them using your addon.
For my project i need to control 10 different lights, each light connected to 10 differents sounds. This part works and i used ofxAudioDecoder to save all audio samples. So i can handle 10 sounds and get info about each sound. Now i need to spatialize this sound using one sound card and i think your addon could help me, but i don’t know how to use it with ofSoundPlayer. Any suggestion?
Maybe do you have some good and “for dummies” link to understand something about audio? :smile:
Thanks a lot!

I don’t know how the ofxAudioDecoder works, but take a look at the “exampleMultipleSources” to see an easy way of spatalizing multiple sources. If there’s something you don’t understand there, feel free to ask questions!

Here is an approach I used a while ago based on Zach Gage research