您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

52 行
1.3KB

  1. #include <Audio.h>
  2. #include <Wire.h>
  3. #include <SPI.h>
  4. #include <SD.h>
  5. const int myInput = AUDIO_INPUT_LINEIN;
  6. //const int myInput = AUDIO_INPUT_MIC;
  7. // Create the Audio components. These should be created in the
  8. // order data flows, inputs/sources -> processing -> outputs
  9. //
  10. AudioInputI2S audioInput; // audio shield: mic or line-in
  11. AudioAnalyzeFFT256 myFFT(20);
  12. AudioOutputI2S audioOutput; // audio shield: headphones & line-out
  13. // Create Audio connections between the components
  14. //
  15. AudioConnection c1(audioInput, 0, audioOutput, 0);
  16. AudioConnection c2(audioInput, 0, myFFT, 0);
  17. AudioConnection c3(audioInput, 1, audioOutput, 1);
  18. // Create an object to control the audio shield.
  19. //
  20. AudioControlSGTL5000 audioShield;
  21. void setup() {
  22. // Audio connections require memory to work. For more
  23. // detailed information, see the MemoryAndCpuUsage example
  24. AudioMemory(12);
  25. // Enable the audio shield and set the output volume.
  26. audioShield.enable();
  27. audioShield.inputSelect(myInput);
  28. audioShield.volume(0.6);
  29. }
  30. void loop() {
  31. if (myFFT.available()) {
  32. // each time new FFT data is available
  33. // print it all to the Arduino Serial Monitor
  34. Serial.print("FFT: ");
  35. for (int i=0; i<128; i++) {
  36. Serial.print(myFFT.output[i]);
  37. Serial.print(",");
  38. }
  39. Serial.println();
  40. }
  41. }