Hi everyone,
I'm trying to figure out something really simple--how to light an LED indicator proportionally to a Sawtooth LFO. So at the beginning of the wave, the LED would be completely dimmed, and by the end of the wave, the LED would be full brightness.
I'm using AudioAnalyzePeak right now, which is great, but it measures the waveforms negative amplitude the same as the positive amplitude, like so:
This makes the LED illuminate more like a triangle wave than like a Sawtooth.
Any ideas how I could modify this code to make the positive waveform peaks align with maximum LED brightness, and negative waveform peaks align with a fully dimmed LED?
Here's a simple sketch where I'm printing the waveform value to Serial. That value would be used for the LED brightness.
Thank you so much for any ideas.
I'm trying to figure out something really simple--how to light an LED indicator proportionally to a Sawtooth LFO. So at the beginning of the wave, the LED would be completely dimmed, and by the end of the wave, the LED would be full brightness.
I'm using AudioAnalyzePeak right now, which is great, but it measures the waveforms negative amplitude the same as the positive amplitude, like so:
This makes the LED illuminate more like a triangle wave than like a Sawtooth.
Any ideas how I could modify this code to make the positive waveform peaks align with maximum LED brightness, and negative waveform peaks align with a fully dimmed LED?
Here's a simple sketch where I'm printing the waveform value to Serial. That value would be used for the LED brightness.
Thank you so much for any ideas.
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioSynthWaveform LFO; //xy=1280.5831108093262,929.1666927337646
AudioAnalyzePeak peakMeter; //xy=1445.333152770996,927.9166450500488
AudioConnection patchCord1(LFO, peakMeter);
AudioOutputI2S i2s2; //xy=1883.333333333333,811.6666666666665
AudioControlSGTL5000 sgtl5000_1; //xy=1989.9999999999998,961.6666666666665
// GUItool: end automatically generated code
void setup() {
AudioMemory(100);
Serial.begin(115200);
LFO.begin(1, .5, WAVEFORM_SAWTOOTH);
}
void loop() {
if (peakMeter.available()) {
double peakValue = peakMeter.read();
Serial.println(peakValue);
}
}