// frequency modulated SVF corner frequency
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
// GUItool: begin automatically generated code
AudioSynthWaveformSine sine1; //xy=134,414
AudioSynthWaveformDc dc1; //xy=139,360
AudioSynthWaveform waveform1; //xy=162,198
AudioMixer4 mixer1; //xy=296,384
AudioEffectEnvelope envelope1; //xy=366,199
AudioEffectEnvelope envelope2; //xy=448,353
AudioFilterStateVariable filter1; //xy=572,253
AudioOutputI2S i2s1; //xy=798,236
AudioConnection patchCord1(sine1, 0, mixer1, 1);
AudioConnection patchCord2(dc1, 0, mixer1, 0);
AudioConnection patchCord3(waveform1, envelope1);
AudioConnection patchCord4(mixer1, envelope2);
AudioConnection patchCord5(envelope1, 0, filter1, 0);
AudioConnection patchCord6(envelope2, 0, filter1, 1);
AudioConnection patchCord7(filter1, 0, i2s1, 0);
AudioControlSGTL5000 sgtl5000_1; //xy=828,158
// GUItool: end automatically generated code
float LFOfreq = 1.0;
void setup() {
AudioMemory(12);
sine1.frequency(LFOfreq); // lfo
sine1.amplitude(0.4);
dc1.amplitude(0.3);
// this is the modulation envelope
envelope2.delay(30);
envelope2.attack(60);
envelope2.hold(20);
envelope2.decay(300);
envelope2.sustain(0.3);
envelope2.release(100);
// now the envelope for the note
envelope1.attack(15);
envelope1.decay(45);
envelope1.sustain(0.7);
envelope1.release(250);
// the actual waveform, saw for lots of harmonics so the effect of the LPF is clear
// amplitude 0.5 to allow for positive gain of filter near resonance
waveform1.begin(0.5, 440, TONE_TYPE_SAWTOOTH);
filter1.resonance(3);
filter1.frequency(440);
filter1.octaveControl(1);
// configure output device
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
// sgtl5000_1.unmuteLineout();
}
void loop() {
for (int i = 1; i < 20000; i *=2) {
LFOfreq = i;
sine1.frequency(LFOfreq);
envelope1.noteOn();
envelope2.noteOn();
delay (1500);
envelope1.noteOff();
envelope2.noteOff();
delay (500);
}
}