76 4. ANALOG-TO-DIGITAL SIGNAL CONVERSION
- (void) processStream {
//Frame Size
UInt32 frameSize = getFrameSize() * sizeof(short);
int32_t availableBytes;
//Initialize Temporary buffers for processing
short *tail = TPCircularBufferTail(inBuffer, &availableBytes);
if (availableBytes > frameSize) {
short *buffer = malloc(frameSize), *output = malloc(frameSize);
memcpy(buffer, tail, frameSize);
TPCircularBufferConsume(inBuffer, frameSize);
FIRFilter(buffer, frameSize/sizeof(short), output, getDelay());
TPCircularBufferProduceBytes(outBuffer, output, frameSize);
free(output);
free(buffer);
duration+=clock() - startTime;
count++;
startTime = clock();
if(count > getValue()/getFrameSize()) {
printTime((double)duration/((double)count * CLOCKS_PER_SEC));
duration = 0;
count = 0;
}
}
}
In this function, the capacity of the software buffer is checked with the frame size specified by
the user. If the data in the software buffer is larger than the frame size, the input audio data
is copied to the buffer and an empty buffer of the same size called output is created. en, the
C function is called to process the data provided in the buffer and puts it out. Finally, the data
provided by the buffer is copied to the software buffer and it is outputted to the speaker.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.179.119