Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ToneSweep.ino 1.6KB

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