iPad stereo audio input bug?

Hello all. I’ve just started working with oF so I’m a bit of a newb.

I’m trying to get stereo audio input working- iPad can do stereo with use of a usb soundcard) and it appears that oF is hardcoded for mono input:
ofxiPhoneSoundStream.mm in recordingCallback on line 108-111, and 132 for the audioReceived call. I’ve been hacking at it for a few hours and I’m a bit too novice to figure out how to get it working.

I know in theory it should work just fine.
Thoughts?

Thanks!
/Timothy - trash80

I always thought it did record stereo; it just interleaved the results so that buffer[0] = left1, buffer[1] = right1, buffer[2] = left2 etc. But that belief is based purely on a code comment somewhere in the source so who knows if it’s true or not!

Right but as mentioned the number of inputs in another part of the source is hardcoded to 1. So changing the number of inputs to anything other than 0 or 1 results in audioReceived not being called.

ofxiPhoneSoundStream.mm…

static OSStatus recordingCallback(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *ioData) {

AudioBufferList list;
**
// redundant
list.mNumberBuffers = 1;
list.mBuffers[0].mData = sampleBuffer;
list.mBuffers[0].mDataByteSize = 2 * inNumberFrames;
list.mBuffers[0].mNumberChannels = 1;**

ioData = &list;
//printf(“No buffers: %d, buffer length: %d bus number: %d\n”, ioData->mNumberBuffers, ioData->mBuffers[0].mDataByteSize, inBusNumber);

// Then:
// Obtain recorded samples

OSStatus status = AudioUnitRender(audioUnit, ioActionFlags, inTimeStamp, 1, inNumberFrames, ioData);
checkStatus(status);
if(status!=noErr) return status;
if(ioData->mNumberBuffers>0) {
int i = 0;
short int *buffer = (short int *) list.mBuffers[i].mData;
for(int j = 0; j < ioData->mBuffers[i].mDataByteSize/2; j++) {
// go through each sample and turn it into a float
tempBuffer[j] = (float)buffer[j]/32767.f;

}
done = true;
if(OFSAptr!=NULL) OFSAptr->audioReceived(tempBuffer, ioData->mBuffers[i].mDataByteSize/2, 1);

}
return noErr;
}

I tried playing around with it to get it working but I suppose I suck. :smiley:
Also note I tried another framework for stereo audio input and it works, though I’d rather use oF than have to convert the rest of my code.

Ah, right I see.

  
mNumberChannels  
The number of interleaved channels in the buffer. If the number is 1, the buffer is noninterleaved  

Did you try ofSoundStreamSetup with nInputs as 2 as well as setting mNumberChannels as 2?

Maybe if you posted your code and the error you are getting?