|
-
-
- #include <Audio.h>
- #include <Wire.h>
- #include <SPI.h>
- #include <SD.h>
- #include <SerialFlash.h>
-
- const int myInput = AUDIO_INPUT_LINEIN;
-
-
-
-
-
-
- AudioInputI2S audioInput;
- AudioOutputI2S audioOutput;
-
-
-
-
- AudioConnection c1(audioInput, 0, audioOutput, 0);
- AudioConnection c2(audioInput, 1, audioOutput, 1);
-
-
-
- AudioControlSGTL5000 audioShield;
-
- void setup() {
-
-
- AudioMemory(4);
-
- audioShield.enable();
- audioShield.inputSelect(myInput);
- audioShield.volume(0.5);
- }
-
- elapsedMillis chgMsec=0;
-
- float lastBal=1024;
- float vol1=0.75;
-
- void loop() {
-
- if (chgMsec > 10) {
- float bal1=analogRead(15);
- bal1=((bal1-512)/512);
- bal1=(int)bal1;
- if(lastBal!=bal1)
- {
- if(bal1<0)
- {
- audioShield.volume(vol1,vol1*(1+bal1));
- } else {
- audioShield.volume(vol1*(1-bal1),vol1);
- }
- lastBal=bal1;
- }
- chgMsec = 0;
- }
- }
|