|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- /*
- Demo of the audio sweep function.
- The user specifies the amplitude,
- start and end frequencies (which can sweep up or down)
- and the length of time of the sweep.
-
- FMI:
- The audio board uses the following pins.
- 6 - MEMCS
- 7 - MOSI
- 9 - BCLK
- 10 - SDCS
- 11 - MCLK
- 12 - MISO
- 13 - RX
- 14 - SCLK
- 15 - VOL
- 18 - SDA
- 19 - SCL
- 22 - TX
- 23 - LRCLK
-
- */
-
- #include <arm_math.h>
- #include <Audio.h>
- #include <Wire.h>
- //#include <WM8731.h>
- #include <SD.h>
- #include <SPI.h>
- #include <Bounce.h>
-
- AudioSynthToneSweep myEffect;
- AudioOutputI2S audioOutput; // audio shield: headphones & line-out
-
- // The tone sweep goes to left and right channels
- AudioConnection c1(myEffect, 0, audioOutput, 0);
- AudioConnection c2(myEffect, 0, audioOutput, 1);
-
- AudioControlSGTL5000 audioShield;
-
-
- float t_ampx = 0.8;
- int t_lox = 10;
- int t_hix = 22000;
- // Length of time for the sweep in seconds
- float t_timex = 10;
- // <<<<<<<<<<<<<<>>>>>>>>>>>>>>>>
- void setup(void)
- {
-
- Serial.begin(9600);
- while (!Serial) ;
- delay(3000);
-
- AudioMemory(2);
-
- audioShield.enable();
- audioShield.volume(50);
- // I want output on the line out too
- audioShield.unmuteLineout();
- // audioShield.muteHeadphone();
-
- Serial.println("setup done");
-
- if(!myEffect.play(t_ampx,t_lox,t_hix,t_timex)) {
- Serial.println("AudioSynthToneSweep - begin failed");
- while(1);
- }
- // wait for the sweep to end
- while(myEffect.isPlaying());
-
- // and now reverse the sweep
- if(!myEffect.play(t_ampx,t_hix,t_lox,t_timex)) {
- Serial.println("AudioSynthToneSweep - begin failed");
- while(1);
- }
- // wait for the sweep to end
- while(myEffect.isPlaying());
- Serial.println("Done");
- }
-
- void loop(void)
- {
- }
-
-
-
|