void process(AUAudioFrameCount frameCount, AUAudioFrameCount bufferOffset) override { for (int frameIndex = 0; frameIndex < frameCount; ++frameIndex) { int frameOffset = int(frameIndex + bufferOffset); for (int channel = 0; channel < channels; ++channel) { float *in = (float *)inBufferListPtr->mBuffers[channel].mData + frameOffset; float temp = *in; float *out = (float *)outBufferListPtr->mBuffers[channel].mData + frameOffset; if (started) { sp_rms_compute(sp, rms, in, out); trackedAmplitude = *out; } else { trackedAmplitude = 0; } *out = temp; } } bool wasAboveThreshold = isAboveThreshold; if (trackedAmplitude > threshold && !wasAboveThreshold) { isAboveThreshold = true; thresholdCallback(true); } if (wasAboveThreshold && trackedAmplitude < threshold) { isAboveThreshold = false; thresholdCallback(false); } }
void process(AUAudioFrameCount frameCount, AUAudioFrameCount bufferOffset) override { for (int frameIndex = 0; frameIndex < frameCount; ++frameIndex) { int frameOffset = int(frameIndex + bufferOffset); for (int channel = 0; channel < channels; ++channel) { float *in = (float *)inBufferListPtr->mBuffers[channel].mData + frameOffset; float temp = *in; float *out = (float *)outBufferListPtr->mBuffers[channel].mData + frameOffset; if (channel == 0) { if (started) { sp_rms_compute(sp, leftRMS, in, out); leftAmplitude = *out; } else { leftAmplitude = 0; } } else { if (started) { sp_rms_compute(sp, rightRMS, in, out); rightAmplitude = *out; } else { rightAmplitude = 0; } } *out = temp; } } bool wasAboveThreshold = isAboveThreshold; if ((leftAmplitude + rightAmplitude) / 2.0 > threshold * 1.05 && !wasAboveThreshold) { isAboveThreshold = true; thresholdCallback(true); } if (wasAboveThreshold && (leftAmplitude + rightAmplitude) / 2.0 < threshold * 0.95) { isAboveThreshold = false; thresholdCallback(false); } }
void process(AUAudioFrameCount frameCount, AUAudioFrameCount bufferOffset) override { // For each sample. for (int frameIndex = 0; frameIndex < frameCount; ++frameIndex) { double halfPowerPoint = double(halfPowerPointRamper.getStep()); int frameOffset = int(frameIndex + bufferOffset); rms->ihp = (float)halfPowerPoint; for (int channel = 0; channel < channels; ++channel) { float *in = (float *)inBufferListPtr->mBuffers[channel].mData + frameOffset; float temp = *in; float *out = (float *)outBufferListPtr->mBuffers[channel].mData + frameOffset; if (started) { sp_rms_compute(sp, rms, in, out); trackedAmplitude = *out; } else { trackedAmplitude = 0; } *out = temp; } } }