You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
1.6KB

  1. /*
  2. Demo of the audio sweep function.
  3. The user specifies the amplitude,
  4. start and end frequencies (which can sweep up or down)
  5. and the length of time of the sweep.
  6. FMI:
  7. The audio board uses the following pins.
  8. 6 - MEMCS
  9. 7 - MOSI
  10. 9 - BCLK
  11. 10 - SDCS
  12. 11 - MCLK
  13. 12 - MISO
  14. 13 - RX
  15. 14 - SCLK
  16. 15 - VOL
  17. 18 - SDA
  18. 19 - SCL
  19. 22 - TX
  20. 23 - LRCLK
  21. */
  22. #include <Audio.h>
  23. #include <Wire.h>
  24. #include <SPI.h>
  25. #include <SD.h>
  26. #include <Bounce.h>
  27. AudioSynthToneSweep myEffect;
  28. AudioOutputI2S audioOutput; // audio shield: headphones & line-out
  29. // The tone sweep goes to left and right channels
  30. AudioConnection c1(myEffect, 0, audioOutput, 0);
  31. AudioConnection c2(myEffect, 0, audioOutput, 1);
  32. AudioControlSGTL5000 audioShield;
  33. float t_ampx = 0.8;
  34. int t_lox = 10;
  35. int t_hix = 22000;
  36. // Length of time for the sweep in seconds
  37. float t_timex = 10;
  38. // <<<<<<<<<<<<<<>>>>>>>>>>>>>>>>
  39. void setup(void)
  40. {
  41. Serial.begin(9600);
  42. while (!Serial) ;
  43. delay(3000);
  44. AudioMemory(2);
  45. audioShield.enable();
  46. audioShield.volume(0.5);
  47. // I want output on the line out too
  48. audioShield.unmuteLineout();
  49. // audioShield.muteHeadphone();
  50. Serial.println("setup done");
  51. if(!myEffect.play(t_ampx,t_lox,t_hix,t_timex)) {
  52. Serial.println("AudioSynthToneSweep - begin failed");
  53. while(1);
  54. }
  55. // wait for the sweep to end
  56. while(myEffect.isPlaying());
  57. // and now reverse the sweep
  58. if(!myEffect.play(t_ampx,t_hix,t_lox,t_timex)) {
  59. Serial.println("AudioSynthToneSweep - begin failed");
  60. while(1);
  61. }
  62. // wait for the sweep to end
  63. while(myEffect.isPlaying());
  64. Serial.println("Done");
  65. }
  66. void loop(void)
  67. {
  68. }