WaveForm API
-
I am trying to use the Waveform API to capture the digitized sound from the sound card. The issue I am having once I have a handle the sound card, actually receiving anything from it. Here is the pertinent code:
while(h->running){ //\*\*\* Start capture sound. memset(hWaveInHdr.lpData, '\\0', h->rate \* 2 \* sizeof(short)); result = waveInStart(hWaveIn); if (result){
#ifdef DEBUG
fprintf(stderr, "Failed to start recording");
#endif // DEBUG
return;
}
//*** Wait until we have the data
do{}while (waveInUnprepareHeader(hWaveIn, &hWaveInHdr, sizeof(WAVEHDR)) == WAVERR_STILLPLAYING);
for(i = 0; i < hWaveInHdr.dwBytesRecorded; i++){
ch = i % 2;
PluginDevFifoPutW(h->channelData[ch], (sample16_t)hWaveInHdr.lpData[i]);
if(PluginDevFifoFull(h->channelData[ch]) < h->channelData[ch]->level){
ready = 0;
}
else{
ready = 1;
}
}
struct PluginDevEvent e = { 0 };
PluginDevFifoPutE(h->parameterData[0], e);
if(ready){
h->callback(h->argument, PLUGINDEV_DATA, NULL);
}
}I seem to get one block of sound when I first start, but nothing after that. Any ideas what I am doing wrong? :confused:
Thanks, Kevin (Bear)