[code]AudioStuff::AudioStuff()
{
mpData = new tThreadData();
mpData->mGoOn = true;
mpCallBack = new AudioCallBack();
}
AudioStuff::~AudioStuff()
{
}
char* toCString(String str)
{
int length = str.length();
char* res = new char[length+1];
int i;
for (i = 0; i < length; i++)
res[i] = str[i];
res[i] = '\0';
return res;
}
void AudioStuff::LaunchProcess()
{
StringArray tab = AudioIODevice::getDeviceNames();
AudioIODevice device(tab[0]); // 0 is for the Mic input
StringArray chanTab = device.getInputChannelNames();
double SampleRate = device.getSampleRate(0); // 44100
int bufferSize = device.getDefaultBufferSize();
String error = device.open(BitArray(3),BitArray(3),device.getSampleRate(0),device.getDefaultBufferSize()); // BitArray(3), 3 because I want the first and the second channels (0000 0011)
if (error.isEmpty())
printf("device opening was succesfull\n\n");
else
printf("device opening failed. Return value: %s\n\n", toCString(error));
device.start(mpCallBack); // mpCallBack is created in the constructor of this class
}[/code]
here is the code of the class which create and open a device.
My callback class is like this:
[code]void AudioCallBack::audioDeviceIOCallback(const float **inputChannelData, int totalNumInputChannels, float **outputChannelData, int totalNumOutputChannels, int numSamples)
{
printf(“callback\n”);
}
void AudioCallBack::audioDeviceAboutToStart(double sampleRate, int numSamplesPerBlock)
{
printf(“about to start, sampleRate:%f, nbSamplePerBlock:%d\n”, sampleRate, numSamplesPerBlock);
}
void AudioCallBack::audioDeviceStopped()
{
}[/code]
I thought that when I called the “start” method, it called automatically my callback function, but It seems that it’s not the case, or maybe I’m missing something…
Leskimo