How to analyze every sample to check the hz/db threshold in PortAudio?

16 hours ago 1
ARTICLE AD BOX

I've never worked with PortAudio before. My software is supposed to simply check if a specific sample went for a short period of time on, above an average loud hand clap threshold. This should be recognized by a microphone.

How can I visualize this in the recordCallback function?

My current recordCallback function:

static int recordCallback(const void* inputBuffer, void* outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void* userData) { patestData* data = (patestData*)userData; unsigned long framesLeft = data->maxframeindex - data->frameindex; long framesToCalc, i; int finished; if (framesLeft < framesPerBuffer) { framesToCalc = framesLeft; finished = paComplete; } else { framesToCalc = framesPerBuffer; finished = paComplete; } if (inputBuffer == NULL) { for (int init = 0; init < framesToCalc; init++) { //how to check the sample here?!! } } }
Read Entire Article