/* Returns an array of seven floats. ret[0] = num deltas ret[1] = error code ret[2] = duration ret[3] = onset ret[4] = offset ret[5] = max peak ret[6] = min peak Error code = 1 for success, -1 for failure. */ JNIEXPORT jfloatArray JNICALL Java_com_android_cts_verifier_audioquality_Native_overflowCheck( JNIEnv *env, jobject obj, jshortArray jpcm, jfloat sampleRate) { float ret[7]; int numSamples = env->GetArrayLength(jpcm); short *pcm = new short[numSamples]; env->GetShortArrayRegion(jpcm, 0, numSamples, pcm); float duration = -1.0; int numDeltas = -1, onset = -1, offset = -1; int maxPeak = 0, minPeak = 0; int success = overflowCheck(pcm, numSamples, sampleRate, &duration, &numDeltas, &onset, &offset, &maxPeak, &minPeak); ret[0] = numDeltas; ret[1] = success ? 1 : -1; ret[2] = duration; ret[3] = onset; ret[4] = offset; ret[5] = maxPeak; ret[6] = minPeak; jfloatArray ja = env->NewFloatArray(7); env->SetFloatArrayRegion(ja, 0, 7, ret); return ja; }
bool RF_reciever::checkForMessages() { //looping tasks that need to be performed overflowCheck(); if(!interruptIsRunning) { start(); } if(convertPulses2Bits()) { //have a valid message! delay(500); //allow half a second for a few more bits to arrive before stopping the interrupt stop(); //stop the interrupt from firing return true; //message found so return true } return false; //no message found so return false }