Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Filter.ino 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. // each filter requires a set up parameters
  7. // http://forum.pjrc.com/threads/24793-Audio-Library?p=40179&viewfull=1#post40179
  8. //
  9. int myFilterParameters[] = { // lowpass, Fc=800 Hz, Q=0.707
  10. 3224322, 6448644, 3224322, 1974735214, -913890679, 0, 0, 0};
  11. // Create the Audio components. These should be created in the
  12. // order data flows, inputs/sources -> processing -> outputs
  13. //
  14. AudioInputI2S audioInput; // audio shield: mic or line-in
  15. AudioFilterBiquad myFilter(myFilterParameters);
  16. AudioOutputI2S audioOutput; // audio shield: headphones & line-out
  17. // Create Audio connections between the components
  18. //
  19. AudioConnection c1(audioInput, 0, audioOutput, 0);
  20. AudioConnection c2(audioInput, 0, myFilter, 0);
  21. AudioConnection c3(myFilter, 0, audioOutput, 1);
  22. // Create an object to control the audio shield.
  23. //
  24. AudioControlSGTL5000 audioShield;
  25. void setup() {
  26. // Audio connections require memory to work. For more
  27. // detailed information, see the MemoryAndCpuUsage example
  28. AudioMemory(12);
  29. // Enable the audio shield and set the output volume.
  30. audioShield.enable();
  31. audioShield.inputSelect(myInput);
  32. audioShield.volume(60);
  33. }
  34. elapsedMillis volmsec=0;
  35. void loop() {
  36. // every 50 ms, adjust the volume
  37. if (volmsec > 50) {
  38. float vol = analogRead(15);
  39. vol = vol / 10.24;
  40. audioShield.volume(vol);
  41. volmsec = 0;
  42. }
  43. }