Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#include <Bounce.h>
// GUItool: begin automatically generated code
AudioSynthWaveformDc dc1; //xy=69.18978881835938,113
AudioSynthWaveformModulated wavelfopitch; //xy=121.18978881835938,194
AudioSynthWaveformModulated waveformMod1; //xy=253.76121520996094,116.42856979370117
AudioEffectEnvelope envelope1; //xy=325.7612075805664,200.71429443359375
AudioSynthWaveformDc dc2; //xy=429.18973541259766,109.14285087585449
AudioSynthWaveformModulated wavelfo_filtre; //xy=489.1897163391113,166.7142848968506
AudioFilterStateVariable filter1; //xy=617.4753913879395,259.5714282989502
AudioEffectMultiply multiply1; //xy=660.1897163391113,139.7142848968506
AudioMixer4 filtermixer; //xy=820.3326683044434,206.4285545349121
AudioEffectDelay delay1; //xy=963.3326683044434,375.4285545349121
AudioEffectFreeverbStereo freeverbs1; //xy=983.3326683044434,214.4285545349121
AudioMixer4 mixerleft; //xy=1143.3326683044434,101.42855453491211
AudioMixer4 mixerright; //xy=1144.3326683044434,324.4285545349121
AudioOutputUSB usb1; //xy=1329.3326683044434,104.42855453491211
AudioOutputAnalogStereo dacs1; //xy=1333.3326683044434,179.4285545349121
AudioConnection patchCord1(dc1, 0, wavelfopitch, 1);
AudioConnection patchCord2(wavelfopitch, 0, waveformMod1, 0);
AudioConnection patchCord3(waveformMod1, envelope1);
AudioConnection patchCord4(envelope1, 0, filter1, 0);
AudioConnection patchCord5(dc2, 0, wavelfo_filtre, 1);
AudioConnection patchCord6(wavelfo_filtre, 0, multiply1, 1);
AudioConnection patchCord7(filter1, 0, multiply1, 0);
AudioConnection patchCord8(filter1, 0, filtermixer, 1);
AudioConnection patchCord9(multiply1, 0, filtermixer, 0);
AudioConnection patchCord10(filtermixer, freeverbs1);
AudioConnection patchCord11(filtermixer, delay1);
AudioConnection patchCord12(filtermixer, 0, mixerleft, 1);
AudioConnection patchCord13(delay1, 0, mixerright, 1);
AudioConnection patchCord14(delay1, 0, filtermixer, 3);
AudioConnection patchCord15(freeverbs1, 0, mixerleft, 0);
AudioConnection patchCord16(freeverbs1, 1, mixerright, 0);
AudioConnection patchCord17(mixerleft, 0, dacs1, 0);
AudioConnection patchCord18(mixerleft, 0, usb1, 0);
AudioConnection patchCord19(mixerright, 0, dacs1, 1);
AudioConnection patchCord20(mixerright, 0, usb1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=1267.3326683044434,404.4285545349121
// GUItool: end automatically generated code
Bounce button24 = Bounce(24, 15);
float hz2;
float cutoff = 19000;
float reso = 1.11;
float revol = 0.1;//0.0
float rsize = 0.2;//0.1
float atk = 1.;
float dcy = 35;
float sus = 1;
float rls = 0;
int swc = 0;
int swc2 = 0;
int wavfrm;
int wavfrm2;
float vely = 0.00;
float shpwm = 0.00;
float shpwm2 = 0.00;
float pitchlfo =0.00;
float filtrelfo =0.00;
float pitchlfofreq = 0.00;
float filtrelfofreq = 0.00;
float filtrelfoamp = 0.00;//mod pour test origine 0
float pitchlfoamp = 0.20;
float pitch = 0;
elapsedMillis timeout = 0;
int valueconvert;
extern const int16_t myWaveform[256]; // defined in myWaveform.ino
float delayfeedback = 1;
#define POLYPHONY 8 // Max # simultaneous notes
#define WAVEFORM WAVEFORM_SAWTOOTH
int current_waveform=0;
byte notesSounding[POLYPHONY] = {0};
void setup() {
dacs1.analogReference(EXTERNAL); //augmente le son du dac intern
Serial.begin(9600);
AudioMemory(200);
pinMode(24, INPUT_PULLUP);
waveformMod1.arbitraryWaveform(myWaveform, 172.0);
current_waveform = WAVEFORM_TRIANGLE_VARIABLE;
waveformMod1.begin(current_waveform);
waveformMod1.amplitude(1.0);
envelope1.attack(10);
envelope1.hold(10);
envelope1.decay(25);
envelope1.sustain(0.4);
envelope1.release(70);
delay1.delay(0, 400);
delay(1000);
delay1.disable(2);
delay1.disable(3);
delay1.disable(4);
delay1.disable(5);
delay1.disable(6);
delay1.disable(7);
freeverbs1.damping(1.0);
filter1.octaveControl(24);
sgtl5000_1.enable();
sgtl5000_1.volume(0.32);
}
void loop() {
button24.update();
if (button24.fallingEdge()) {
timeout = 0;
envelope1.noteOn();
}
if (button24.risingEdge()) {
envelope1.noteOff();
timeout = 0;
}
int cutoffpot = analogRead(A14) *20;
int cutoff = cutoffpot/127;
delay(100);
int filtrelfofreqpot = analogRead(A15);
int filtrelfofreq = filtrelfofreqpot/127;
delay(100);
int filtrelfoamppot = analogRead(A15);
int filtrelfoamp = filtrelfoamppot/127;
delay(100);
int pitchlfofreqpot = analogRead(A16);
int pitchlfofreq = pitchlfofreqpot/254;
delay(100);
int pitchlfoamppot = analogRead(A17);
int pitchlfoamp = pitchlfoamppot/1023;
delay(100);
float freq = 261.0 ;
wavelfopitch.begin(0.3, 440, wavfrm); //loader waveform
wavelfopitch.frequency(pitchlfofreq);
wavelfopitch.amplitude(pitchlfoamp);
waveformMod1.frequency (freq*pitchlfofreqpot);
wavelfo_filtre.begin(0.3, 440, wavfrm);
wavelfo_filtre.frequency(filtrelfofreq);
wavelfo_filtre.amplitude(filtrelfoamp);
envelope1.attack(atk);
envelope1.decay(dcy);
envelope1.sustain(sus);
envelope1.release(rls);
filter1.frequency(cutoff);
filter1.resonance(reso);
filtermixer.gain(0, 0.3);
filtermixer.gain(2, 0.3);
filtermixer.gain(3, 0.2);//delay feedback
dc1.amplitude(pitchlfo); //pitchlfo
dc2.amplitude(filtrelfo); //filtrelfo
mixerleft.gain(0, revol);
mixerleft.gain(0, revol);
}