|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #include <Audio.h>
- #include <Wire.h>
- #include <SPI.h>
- #include <SD.h>
- #include <SerialFlash.h>
- #include <Bounce.h>
-
- AudioSynthWaveform waveform1;
- AudioSynthWaveform waveform2;
- AudioOutputI2S i2s1;
- AudioOutputAnalogStereo dacs1;
- AudioConnection patchCord1(waveform1, 0, i2s1, 0);
- AudioConnection patchCord2(waveform1, 0, dacs1, 0);
- AudioConnection patchCord3(waveform2, 0, i2s1, 1);
- AudioConnection patchCord4(waveform2, 0, dacs1, 1);
- AudioControlSGTL5000 sgtl5000_1;
-
- Bounce button0 = Bounce(0, 15);
- Bounce button1 = Bounce(1, 15);
- Bounce button2 = Bounce(2, 15);
-
- int current_waveform=0;
-
- extern const int16_t myWaveform[256];
-
- void setup() {
- Serial.begin(9600);
- pinMode(0, INPUT_PULLUP);
- pinMode(1, INPUT_PULLUP);
- pinMode(2, INPUT_PULLUP);
-
-
-
- AudioMemory(10);
-
-
-
-
- sgtl5000_1.enable();
- sgtl5000_1.volume(0.8);
-
-
- waveform1.arbitraryWaveform(myWaveform, 172.0);
- waveform2.arbitraryWaveform(myWaveform, 172.0);
-
-
- waveform1.frequency(440);
- waveform2.frequency(440);
- waveform1.amplitude(1.0);
- waveform2.amplitude(1.0);
-
- current_waveform = WAVEFORM_TRIANGLE;
- waveform1.begin(current_waveform);
- }
-
- void loop() {
-
- button0.update();
- button1.update();
- button2.update();
- float knob_A2 = (float)analogRead(A2) / 1023.0;
- float knob_A3 = (float)analogRead(A3) / 1023.0;
-
- AudioNoInterrupts();
-
- waveform1.frequency(100.0 + knob_A2 * 900.0);
- waveform2.frequency(100.0 + knob_A2 * 900.0);
-
- waveform1.phase(knob_A3 * 360.0);
- AudioInterrupts();
-
-
- if (button0.fallingEdge()) {
- switch (current_waveform) {
- case WAVEFORM_SINE:
- current_waveform = WAVEFORM_SAWTOOTH;
- Serial.println("Sawtooth");
- break;
- case WAVEFORM_SAWTOOTH:
- current_waveform = WAVEFORM_SAWTOOTH_REVERSE;
- Serial.println("Reverse Sawtooth");
- break;
- case WAVEFORM_SAWTOOTH_REVERSE:
- current_waveform = WAVEFORM_SQUARE;
- Serial.println("Square");
- break;
- case WAVEFORM_SQUARE:
- current_waveform = WAVEFORM_TRIANGLE;
- Serial.println("Triangle");
- break;
- case WAVEFORM_TRIANGLE:
- current_waveform = WAVEFORM_TRIANGLE_VARIABLE;
- Serial.println("Variable Triangle");
- break;
- case WAVEFORM_TRIANGLE_VARIABLE:
- current_waveform = WAVEFORM_ARBITRARY;
- Serial.println("Arbitary Waveform");
- break;
- case WAVEFORM_ARBITRARY:
- current_waveform = WAVEFORM_PULSE;
- Serial.println("Pulse");
- break;
- case WAVEFORM_PULSE:
- current_waveform = WAVEFORM_SAMPLE_HOLD;
- Serial.println("Sample & Hold");
- break;
- case WAVEFORM_SAMPLE_HOLD:
- current_waveform = WAVEFORM_SINE;
- Serial.println("Sine");
- break;
- }
- AudioNoInterrupts();
- waveform1.begin(current_waveform);
- waveform2.begin(WAVEFORM_SINE);
- AudioInterrupts();
- }
-
- }
-
|