選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

58 行
1.6KB

  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. AudioSynthWaveformSine sinewave;
  12. AudioAnalyzeFFT1024 myFFT;
  13. AudioOutputI2S audioOutput; // audio shield: headphones & line-out
  14. // Connect either the live input or synthesized sine wave
  15. AudioConnection patchCord1(audioInput, 0, myFFT, 0);
  16. //AudioConnection patchCord1(sinewave, 0, myFFT, 0);
  17. AudioControlSGTL5000 audioShield;
  18. void setup() {
  19. // Audio connections require memory to work. For more
  20. // detailed information, see the MemoryAndCpuUsage example
  21. AudioMemory(12);
  22. // Enable the audio shield and set the output volume.
  23. audioShield.enable();
  24. audioShield.inputSelect(myInput);
  25. audioShield.volume(0.6);
  26. // Configure the window algorithm to use
  27. myFFT.windowFunction(AudioWindowHanning1024);
  28. //myFFT.windowFunction(NULL);
  29. // Create a synthetic sine wave, for testing
  30. // To use this, edit the connections above
  31. sinewave.amplitude(0.8);
  32. sinewave.frequency(1034.007);
  33. }
  34. void loop() {
  35. if (myFFT.available()) {
  36. // each time new FFT data is available
  37. // print it all to the Arduino Serial Monitor
  38. Serial.print("FFT: ");
  39. for (int i=0; i<40; i++) {
  40. Serial.print(myFFT.read(i));
  41. //Serial.print(myFFT.output[i]);
  42. Serial.print(" ");
  43. }
  44. Serial.println();
  45. }
  46. }