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.

51 line
1.3KB

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