Hi Arturo,
I realized that to do what I need I might have enough with the current ofSoundStream. I think if I set up my multichannel device as system default I might be able to control both mono inputs (left and right) attached to two microphones.
However, I started porting the add-on and I have done most of the stuff (I think). I can create an instance and correctly list al devices and preselect one, but as soon as I try to use the setup method, I got a linking complier error related to the callback function (symbols not found ofxSoundStream.o). I will continue looking at this when I have time, but If you think you can guess what’s going on, would be cool. I haven’t spent a lot of time yet and I might be doing something completely wrong, but these are the interesting related parts of it:
// rtAudio callback
int ofxSoundStreamCallback(void *outputBuffer, void *inputBuffer, unsigned int bufferSize, double streamTime, RtAudioStreamStatus status, void *ofStream);
int ofSoundStreamCallback(void *outputBuffer, void *inputBuffer, unsigned int bufferSize, double streamTime, RtAudioStreamStatus status, void *ofStream){
return ((ofxSoundStream*)ofStream)->receiveAudioBuffer(inputBuffer, bufferSize);
}
void ofxSoundStream::setup(int nOutputs, int nInputs, ofBaseApp * OFSA, unsigned int sampleRate, unsigned int bufferSize, unsigned int nBuffers){
RtAudio::StreamParameters inputParams;
RtAudio::StreamParameters outputParams;
RtAudio::StreamOptions streamOptions;
inputParams.deviceId = deviceID;
inputParams.nChannels = nInputs;
outputParams.deviceId = deviceID;
outputParams.nChannels = nOutputs;
streamOptions.numberOfBuffers = nBuffers;
nInputChannels = nInputs;
nOutputChannels = nOutputs;
OFSAptr = OFSA;
bufferSize = ofNextPow2(bufferSize); // must be pow2
if(audio)
close();
audio = new RtAudio();
try {
audio->openStream( &outputParams, &inputParams, RTAUDIO_FLOAT32,
sampleRate, &bufferSize, &ofxSoundStreamCallback, this, &streamOptions);
} catch (RtError &error) {
error.printMessage();
//std::exit(EXIT_FAILURE); // need case here
}
try {
//audio->setStreamCallback(&ofSoundStreamCallback, this);
audio->startStream();
} catch (RtError &error) {
error.printMessage();
}
}
My guess is that what is wrong is the “this” reference of the callback, since the function expects a void* userData, see here:
http://www.music.mcgill.ca/~gary/rtaudio/classRtAudio.html#afacc99740fa4c5606fb35467cdea6da8
I’ll continue looking into it though…
Cheers,
Edu