|
-
-
- #include <Audio.h>
- #include <Wire.h>
- #include <SD.h>
- #include <SPI.h>
- #include <SerialFlash.h>
- #include <Bounce.h>
-
-
- #define FLANGE_DELAY_LENGTH (6*AUDIO_BLOCK_SAMPLES)
-
- short l_delayline[FLANGE_DELAY_LENGTH];
- short r_delayline[FLANGE_DELAY_LENGTH];
-
-
-
-
- #define PASSTHRU_PIN 1
-
- Bounce b_passthru = Bounce(PASSTHRU_PIN,15);
-
-
- const int myInput = AUDIO_INPUT_LINEIN;
-
- AudioInputI2S audioInput;
- AudioEffectFlange l_myEffect;
- AudioEffectFlange r_myEffect;
- AudioOutputI2S audioOutput;
-
-
-
- AudioConnection c1(audioInput, 0, l_myEffect, 0);
- AudioConnection c2(audioInput, 1, r_myEffect, 0);
-
- AudioConnection c3(l_myEffect, 0, audioOutput, 0);
- AudioConnection c4(r_myEffect, 0, audioOutput, 1);
-
- AudioControlSGTL5000 audioShield;
-
-
- int s_idx = FLANGE_DELAY_LENGTH/4;
- int s_depth = FLANGE_DELAY_LENGTH/4;
- double s_freq = .5;
- void setup() {
-
- Serial.begin(9600);
- while (!Serial) ;
- delay(3000);
-
- pinMode(PASSTHRU_PIN,INPUT_PULLUP);
-
-
-
-
-
- AudioMemory(8);
-
- audioShield.enable();
- audioShield.inputSelect(myInput);
- audioShield.volume(0.5);
-
-
- if(!digitalRead(PASSTHRU_PIN)) {
- Serial.print("PASSTHRU_PIN (");
- Serial.print(PASSTHRU_PIN);
- Serial.println(") is grounded");
- }
-
-
-
-
-
-
-
- l_myEffect.begin(l_delayline,FLANGE_DELAY_LENGTH,s_idx,s_depth,s_freq);
- r_myEffect.begin(r_delayline,FLANGE_DELAY_LENGTH,s_idx,s_depth,s_freq);
-
-
- l_myEffect.voices(FLANGE_DELAY_PASSTHRU,0,0);
- r_myEffect.voices(FLANGE_DELAY_PASSTHRU,0,0);
-
- Serial.println("setup done");
- AudioProcessorUsageMaxReset();
- AudioMemoryUsageMaxReset();
- }
-
-
-
- int volume = 0;
-
- unsigned long last_time = millis();
- void loop()
- {
-
- int n = analogRead(15);
- if (n != volume) {
- volume = n;
- audioShield.volume((float)n / 10.23);
- }
- if(0) {
- if(millis() - last_time >= 5000) {
- Serial.print("Proc = ");
- Serial.print(AudioProcessorUsage());
- Serial.print(" (");
- Serial.print(AudioProcessorUsageMax());
- Serial.print("), Mem = ");
- Serial.print(AudioMemoryUsage());
- Serial.print(" (");
- Serial.print(AudioMemoryUsageMax());
- Serial.println(")");
- last_time = millis();
- }
- }
-
- b_passthru.update();
-
-
-
-
- if(b_passthru.fallingEdge()) {
- l_myEffect.voices(s_idx,s_depth,s_freq);
- r_myEffect.voices(s_idx,s_depth,s_freq);
- }
-
-
- if(b_passthru.risingEdge()) {
- l_myEffect.voices(FLANGE_DELAY_PASSTHRU,0,0);
- r_myEffect.voices(FLANGE_DELAY_PASSTHRU,0,0);
- }
-
- }
|