Skip to content

Commit

Permalink
TASK: Change to three modulated oscillators
Browse files Browse the repository at this point in the history
Replace "waveform" with "waveformmod" and use two of those
and a pink noise source too.
  • Loading branch information
Cliff Lawson committed Sep 18, 2020
1 parent 239c4d1 commit 4db863c
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions synth.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,28 @@
#include "NoteData.h"

// GUItool: begin automatically generated code
AudioSynthWaveform waveform1; //xy=291,219
AudioOutputI2S i2s1; //xy=599,232
AudioConnection patchCord1(waveform1, 0, i2s1, 0);
AudioConnection patchCord2(waveform1, 0, i2s1, 1);
AudioSynthWaveformModulated waveformMod1; //xy=242,198
AudioSynthWaveformModulated waveformMod2; //xy=247,271
AudioSynthNoisePink pink1; //xy=258,350
AudioMixer4 mixer1; //xy=485,232
AudioOutputI2S i2s1; //xy=730,235
AudioConnection patchCord1(waveformMod1, 0, mixer1, 0);
AudioConnection patchCord2(waveformMod2, 0, mixer1, 1);
AudioConnection patchCord3(pink1, 0, mixer1, 2);
AudioConnection patchCord4(mixer1, 0, i2s1, 0);
AudioConnection patchCord5(mixer1, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=489,53
// GUItool: end automatically generated code


void OnNoteOn(byte channel, byte note, byte velocity) {
Serial.printf("ch: %u, note: %u, vel: %u\n", channel, note, velocity);
waveform1.frequency(tune_frequencies2_PGM[note]);
waveform1.amplitude(1.0);
waveform1.pulseWidth(0.15);
waveformMod1.frequency(tune_frequencies2_PGM[note]);
waveformMod1.amplitude(1.0);
}

void OnNoteOff(byte channel, byte note, byte velocity) {
waveform1.amplitude(0);
waveformMod1.amplitude(0);
Serial.println("and off");
}

Expand All @@ -31,7 +36,10 @@ void setup() {
AudioMemory(20);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
waveform1.begin(WAVEFORM_SINE);
waveformMod1.begin(WAVEFORM_SINE);
mixer1.gain(0, 0.3);
mixer1.gain(1, 0.3);
mixer1.gain(2, 0.3);
usbMIDI.setHandleNoteOff(OnNoteOff);
usbMIDI.setHandleNoteOn(OnNoteOn);
}
Expand Down

0 comments on commit 4db863c

Please sign in to comment.