|
|
|
|
|
|
|
|
#include <SD.h> |
|
|
#include <SD.h> |
|
|
#include <SerialFlash.h> |
|
|
#include <SerialFlash.h> |
|
|
|
|
|
|
|
|
#include "BasicFlute1_samples.h" |
|
|
|
|
|
|
|
|
#include "Flute_100kbyte_samples.h" |
|
|
|
|
|
|
|
|
AudioSynthWavetable wavetable; |
|
|
AudioSynthWavetable wavetable; |
|
|
AudioOutputI2S i2s1; |
|
|
AudioOutputI2S i2s1; |
|
|
|
|
|
|
|
|
AudioControlSGTL5000 sgtl5000_1; |
|
|
AudioControlSGTL5000 sgtl5000_1; |
|
|
|
|
|
|
|
|
// Bounce objects to read pushbuttons |
|
|
// Bounce objects to read pushbuttons |
|
|
Bounce button0 = Bounce(0, 15); |
|
|
|
|
|
Bounce button1 = Bounce(1, 15); // 15 ms debounce time |
|
|
Bounce button1 = Bounce(1, 15); // 15 ms debounce time |
|
|
Bounce button2 = Bounce(2, 15); |
|
|
|
|
|
|
|
|
|
|
|
void setup() { |
|
|
void setup() { |
|
|
Serial.begin(115200); |
|
|
Serial.begin(115200); |
|
|
pinMode(0, INPUT_PULLUP); |
|
|
|
|
|
pinMode(1, INPUT_PULLUP); |
|
|
pinMode(1, INPUT_PULLUP); |
|
|
pinMode(2, INPUT_PULLUP); |
|
|
|
|
|
AudioMemory(20); |
|
|
AudioMemory(20); |
|
|
sgtl5000_1.enable(); |
|
|
sgtl5000_1.enable(); |
|
|
sgtl5000_1.volume(0.8); |
|
|
sgtl5000_1.volume(0.8); |
|
|
mixer.gain(0, 0.7); |
|
|
mixer.gain(0, 0.7); |
|
|
|
|
|
|
|
|
wavetable.setInstrument(BasicFlute1); |
|
|
|
|
|
|
|
|
wavetable.setInstrument(Flute_100kbyte); |
|
|
wavetable.amplitude(1); |
|
|
wavetable.amplitude(1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void loop() { |
|
|
void loop() { |
|
|
// Update all the button objects |
|
|
// Update all the button objects |
|
|
button0.update(); |
|
|
|
|
|
button1.update(); |
|
|
button1.update(); |
|
|
button2.update(); |
|
|
|
|
|
//Read knob values |
|
|
//Read knob values |
|
|
int knob1 = analogRead(A3); |
|
|
int knob1 = analogRead(A3); |
|
|
int knob2 = analogRead(A2); |
|
|
int knob2 = analogRead(A2); |
|
|
//Get frequency and gain from knobs |
|
|
|
|
|
float freq = (float)knob1/5.0; |
|
|
|
|
|
|
|
|
//Get frequency and gain from knobs (Flute range is 261 to 2100 Hz) |
|
|
|
|
|
float freq = 261.0 + (float)knob1/1023.0 * (2100.0 - 261.0); |
|
|
float gain = (float)knob2/1023.0; |
|
|
float gain = (float)knob2/1023.0; |
|
|
//Set a low-limit to the gain |
|
|
//Set a low-limit to the gain |
|
|
if (gain < .05) gain = .05; |
|
|
if (gain < .05) gain = .05; |