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.

преди 11 години
преди 10 години
преди 11 години
преди 10 години
преди 11 години
преди 10 години
преди 11 години
преди 10 години
преди 11 години
преди 10 години
преди 11 години
преди 10 години
преди 11 години
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. float n;
  36. int i;
  37. if (myFFT.available()) {
  38. // each time new FFT data is available
  39. // print it all to the Arduino Serial Monitor
  40. Serial.print("FFT: ");
  41. for (i=0; i<40; i++) {
  42. n = myFFT.read(i);
  43. if (n >= 0.01) {
  44. Serial.print(n);
  45. Serial.print(" ");
  46. } else {
  47. Serial.print(" - ");
  48. }
  49. }
  50. Serial.println();
  51. }
  52. }