Multichannel Audio

Hi,

I’m curious about what the best options for multichannel audio are in of 0.9.2 I’m using this device, MOTU UltraLite-mk3

For Background

I have 5 multiple video players using the Hap codec, https://github.com/bangnoise/ofxHapPlayer and I want them all to play on a different channel of the MOTU DAC mentioned above.

Thanks in advance!

Best,
Mark

Hey Mark,

It has been quite a while since I did this, and not sure if something has changed with v0.9x to allow it. But to my knowledge, you would have to encode all of them in 8 channels and put the audio in the channel of audio you want. OF will mix them and output the 8 together however you have the driver setup.

I wish I knew the first bit on how to change that - its way over my head.

Ryan

1 Like

Thanks Ryan,

It’s gives me one way to a solution, I really appreciate it!

Best,
Mark

Hi Mark,

I have a very similar need for a current project and am wondering if you found a solution. I need 10 videos to 10 different sound outputs on Windows.

Any advice or tips to share?

Thanks!

Hi,

I ended up making a Max patch that triggers off an OSC message from the main OF program. Of is great for the graphics I need and max handles the multichannel audio well. I can send you an example if you want to take that path.

Best,
Mark

Thanks Mark!

I found an all audio solution here… https://github.com/borg/ofxMultiDeviceSoundPlayer which seems to work well. I’m going to try and integrate this with the ofVideoPlayer.

Max looks super cool and that may be my backup option if I can’t get this to work.

Cheers!
Rob

I am using the same technique, but I would like to control the volume of each of the discrete tracks in a movie that has 8 tracks of audio. Does anyone know how I can do this?

Interesting to resurrect a thread I commented on, but now I need to do the same thing again. I need to send audio from hap video played with ofxhapplayer to different audio outputs of the same device. I will use 11 video files at a time that need to go to 11 different pairs of outputs from the same audio device. The audio never needs to go to different channels, no matrixing just hard routing.

I see that inside ofxhapplayer it uses sound stream, and I am willing to have a go modifying it.

Is there a way to set up sound stream start at a specific channel number?

1 Like

Is there a way to set up sound stream start at a specific channel number?

Hi, not really. It does not work like that. What you do is taht you put the audio you want into the sound buffer at the specific channel.

Take a look at ofxSoundObjects, there is an example that sends audio to specific channels… Let me know if this is helpful and or if you need more help

Hi, yes I have been looking at ofxSoundObjects as a reference (briefly so far), I will dive further, but I am trying to wrap my head around how I could make this work from multiple hap video players. Interleaving the samples into the correct channels and then I guess filling unused channels with 0’s makes sense.

It is a bit above my head but would be a cool addition.

I will have a go and likely come back to ask for some guidance.

Cheers.

Hi, I have not tested the following but should work.
In ofxHapPlayer.h do the following:
add along with the other includes #include "ofxSoundObject.h"

make the AudioOutput class public and change its declaration
from
class AudioOutput : public ofBaseSoundOutput {
to
class AudioOutput : public ofxSoundObject {

ofxSoundObject already inherits from ofBaseSoundOutput so the code already in that class should work.

Then, make AudioOutput _audioOut; public.

Then simply connect the hap player instances to the mixer by calling.

hapPlayerInstance._audioOut.connectTo(mixer);

As I said I have not tested this. But should work.
Let me know how it goes.
if you provide me with some test clips encoded in HAP I can run some tests.

Ok, well it compiles but I get an error as soon as it runs:

com.apple.audio.IOThread.client (22): EXC_BAD_ACCESS (code=1, address=0x4)

Any ideas on how I can fix it?

In case you have a chance to look at it here is a sample of a HAP encoded file with audio.

Ok, I managed to get a little further, the ofxHapPlayer code starts an ofSoundstream object and sets a listener. I commented out that code and with some limitations I can get sound out. It does play but can only take aac encoded audio from the video stream, not PCM - PCM gives no audio and an error, but PCM also does not work from the Hap player so it is something to do with the audio decoder on the hap addon.

Even with AAC audio the sound is not right, it comes out slow and strange, like the buffer is not setup in the right way.

At any rate I made a fork of the addon here:

and a branch for trying to do this (using the example and your matrix mixer example mashed together)

Hey, I took a look at it and there might be some changes to be made to the addon in order to make it work but I feel it should be quite straight forwards. Usually what gives problems is that the audio is running on a different thread and issues about it rise some times, as the first error you posted. I can give it a try tomorrow. I will let you know if it works.

@fresla I got it working.
Check it here

There are just some minor changes to the ofxHapPlayer class.
There is also an example on how to use it .
let me know how it goes

@roymacdonald Wow, thanks so much, that is a really useful feature, it is working well for me, I think it will be useful to a lot of others too.

Cheers

1 Like

no problem.
It works in an odd way as the sound stream is managed by the player, which I am not sure how it will work for multiple players. I will make a PR so this stuff I added to the player are available to anyone.