Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

85 lines
1.5KB

  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 <SerialFlash.h>
  27. #include <Bounce.h>
  28. AudioSynthToneSweep myEffect;
  29. AudioOutputI2S audioOutput; // audio shield: headphones & line-out
  30. // The tone sweep goes to left and right channels
  31. AudioConnection c1(myEffect, 0, audioOutput, 0);
  32. AudioConnection c2(myEffect, 0, audioOutput, 1);
  33. AudioControlSGTL5000 audioShield;
  34. float t_ampx = 0.8;
  35. int t_lox = 10;
  36. int t_hix = 22000;
  37. // Length of time for the sweep in seconds
  38. float t_timex = 10;
  39. // <<<<<<<<<<<<<<>>>>>>>>>>>>>>>>
  40. void setup(void)
  41. {
  42. Serial.begin(9600);
  43. while (!Serial) ;
  44. delay(3000);
  45. AudioMemory(2);
  46. audioShield.enable();
  47. audioShield.volume(0.5);
  48. Serial.println("setup done");
  49. if(!myEffect.play(t_ampx,t_lox,t_hix,t_timex)) {
  50. Serial.println("AudioSynthToneSweep - begin failed");
  51. while(1);
  52. }
  53. // wait for the sweep to end
  54. while(myEffect.isPlaying());
  55. // and now reverse the sweep
  56. if(!myEffect.play(t_ampx,t_hix,t_lox,t_timex)) {
  57. Serial.println("AudioSynthToneSweep - begin failed");
  58. while(1);
  59. }
  60. // wait for the sweep to end
  61. while(myEffect.isPlaying());
  62. Serial.println("Done");
  63. }
  64. void loop(void)
  65. {
  66. }