|
- #include <Audio.h>
- #include <Bounce.h>
- #include <Wire.h>
- #include <SD.h>
-
- const int myInput = AUDIO_INPUT_LINEIN;
-
-
-
-
-
-
- AudioInputI2S audioInput;
- AudioSynthWaveform toneLow(AudioWaveformSine);
- AudioSynthWaveform toneHigh(AudioWaveformTriangle);
- AudioMixer4 mixerLeft;
- AudioMixer4 mixerRight;
- AudioOutputI2S audioOutput;
- AudioOutputPWM pwmOutput;
-
-
-
- AudioConnection c1(audioInput, 0, mixerLeft, 0);
- AudioConnection c2(audioInput, 1, mixerRight, 0);
- AudioConnection c3(toneHigh, 0, mixerLeft, 1);
- AudioConnection c4(toneHigh, 0, mixerRight, 1);
- AudioConnection c5(toneLow, 0, mixerLeft, 2);
- AudioConnection c6(toneLow, 0, mixerRight, 2);
- AudioConnection c7(mixerLeft, 0, audioOutput, 0);
- AudioConnection c8(mixerRight, 0, audioOutput, 1);
- AudioConnection c9(mixerLeft, 0, pwmOutput, 0);
-
-
-
- AudioControlSGTL5000 audioShield;
-
-
-
-
- Bounce button0 = Bounce(0, 12);
- Bounce button1 = Bounce(1, 12);
-
-
- void setup() {
- pinMode(0, INPUT_PULLUP);
- pinMode(1, INPUT_PULLUP);
-
-
-
- AudioMemory(12);
-
-
- audioShield.enable();
- audioShield.inputSelect(myInput);
- audioShield.volume(60);
- }
-
- elapsedMillis volmsec=0;
-
- void loop() {
-
- button0.update();
- button1.update();
-
-
-
- if (button0.fallingEdge()) {
- toneLow.frequency(256);
- toneLow.amplitude(0.4);
- }
- if (button1.fallingEdge()) {
- toneHigh.frequency(980);
- toneHigh.amplitude(0.25);
- }
-
-
-
- if (button0.risingEdge()) {
- toneLow.amplitude(0);
- }
- if (button1.risingEdge()) {
- toneHigh.amplitude(0);
- }
-
-
- if (volmsec > 50) {
- float vol = analogRead(15);
- vol = vol / 10.24;
- audioShield.volume(vol);
- volmsec = 0;
- }
- }
-
|