I did something like this:
Edit synth_waveform.cpp around line 175:
Code:
// Hack to get amplitude for LFO purposes.
last_amplitude = static_cast<float>(block->data[AUDIO_BLOCK_SAMPLES-1]) / 32767.0f;
Edit synth_waveform.h around line 117 to add last_amplitude and a getter for it:
Code:
float getLastAmplitude(void) {
return last_amplitude;
}
private:
uint32_t phase_accumulator;
uint32_t phase_increment;
uint32_t phase_offset;
int32_t magnitude;
uint32_t pulse_width;
const int16_t *arbdata;
int16_t sample; // for WAVEFORM_SAMPLE_HOLD
short tone_type;
int16_t tone_offset;
float last_amplitude=0.0;
last_amplitude will only be updated every 128 samples, so the max frequency it could measure would be something like 20000 / 128 = 156Hz which is perfectly fine for LFO usage.
If you don't want to hack up the Audio library, you can use the Peak Analyzer, but I prefer not to since it consumes valuable CPU cycles. Anyway, hope that helps, good luck.