Two audio devices


I need to use two audio devices. I want to read buffers from one device and write it to the other device. ( device1 is a Blackmagic recorder and device2 is an external audio sound card )
I noticed ofSoundStream handles inputs and outputs but from same device.
I tried to use to ofSoundStream objects like that

soundStream1.setup(this, 0, 2, 48000, bufferSize, 2); //INS
soundStream2.setup(this, 2, 0, 48000, bufferSize, 2); //OUTS
With properly soundStreamX.setDeviceID(N); before setups but not works.

Any help or worksaround ?

Ps. I’m using ofxblackmagic2 for input vídeo frames with our audio support.


what are you trying to achieve?

if you just want to copy the audio stream, i would try solving this outside of OF.

if you still want to try inside OF:

  • to keep things easy, use exactly the same sample rate, buffer size and channel count on both cards
  • you will need a ring buffer (circular buffer) implementation to keep intermediate samples
  • in audioIn(…): append the input buffer to your circular buffer
  • in audioOut(…): take data out of the circular buffer and place it in the out buffer. if no data is available, make sure you don’t sleep()!
  • here is an article that looks good to get started:

Hi @kritzikratzi,

I fixed my issue using two soundStreams and normalize both buffers ( sample rate, bits, cahnnels, etc…)

Thank you!