I’m getting a memory at 0x0000000 could not be written with the following:

void audioDeviceIOCallback(const float **inputChannelData, int totalNumInputChannels, float **outputChannelData, int totalNumOutputChannels, int numSamples) { for (int i=0; i<numSamples; i++) { for (int j=0; j<totalNumOutputChannels; j++) { outputChannelData[j][i]=waveData[curPos]; } curPos++; if (curPos>=waveData.size()) { curPos=0; } } }

it’s probably something obvious but i’m pretty new to C++ so i have no idea what the problem is…

btw, is this the correct way to open an AudioIODevice with stereo output and no inputs?

BitArray outBA;

I reckon the problem is that you’re looping through every input and output channel your soundcard has, rather than just the ones you want to use. From the manual:

totalNumInputChannels The channel data is arranged with the same array indices as the channel name array returned by AudioIODevice::getOutputChannelNames(), but those channels that aren’t specified in AudioIODevice::open() will have a null pointer for their associated channel, so remember to check for this.

To be honest, this is one of the few things I don’t like so much about JUCE - I think it would be better if the callback only presented the buffers you’re actually using to you.

If you want an example of how to use the AudioIODeviceCallback, you might want to look at my PedalBoard (scroll down), particularly the [size=75]NPBPluginOrganiser::audioDeviceIOCallback()[/size] method.

Also, I don’t think just opening the soundcard with “11” is the best idea - unless I’m mistaken, “11” could be anything (depends on your soundcard, it might be okay). You should at least pass in 0 for the inputChannels parameter though.

  • Niall.

well i have already been using your code for reference but i guess i missed the part where you check to see if they’re null. for opening the sound card, is there an easy way to get the default out or something?

I don’t think so - you basically have to call AudioIOdevice::getOutputChannelNames() (or ASIOAudioIODevice), and use the indices of that to work out the correct values to pass AudioIODevice::open(). A getDefaultDevice() (/getDefaultChannels) method would be very handy though…

  • Niall.

yay! it’s playing now… thanx (again) :smiley: