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.

66 linhas
2.1KB

  1. /* Tone example using SGTL5000 DAP PEQ filters and calcBiquad filter calculator routine.
  2. This example code is in the public domain
  3. */
  4. #include <Audio.h>
  5. #include <Wire.h>
  6. #include <SD.h>
  7. const int myInput = AUDIO_INPUT_LINEIN;
  8. // const int myInput = AUDIO_INPUT_MIC;
  9. int updateFilter[5];
  10. AudioInputI2S audioInput; // audio shield: mic or line-in
  11. AudioOutputI2S audioOutput; // audio shield: headphones & line-out
  12. // Create Audio connections between the components
  13. //
  14. AudioConnection c1(audioInput, 0, audioOutput, 0); // left passing through
  15. AudioConnection c2(audioInput, 1, audioOutput, 1); // right passing through
  16. // Create an object to control the audio shield.
  17. //
  18. AudioControlSGTL5000 audioShield;
  19. void setup() {
  20. // Audio connections require memory to work. For more
  21. // detailed information, see the MemoryAndCpuUsage example
  22. AudioMemory(4);
  23. // Enable the audio shield, select the input and set the output volume.
  24. audioShield.enable();
  25. audioShield.inputSelect(myInput);
  26. audioShield.volume(0.75);
  27. audioShield.unmuteLineout();
  28. // audioShield.audioProcessorEnable(); // enable the DAP block in SGTL5000
  29. // audioShield.eqSelect(1); // using PEQ Biquad filters
  30. // audioShield.eqFilterCount(2); // enable filter 0 & filter 1
  31. calcBiquad(FILTER_PARAEQ,110,0,0.2,524288,44100,updateFilter); // automation negates the need
  32. audioShield.eqFilter(0,updateFilter); // for the three lines commented out above.
  33. calcBiquad(FILTER_PARAEQ,4400,0,0.167,524288,44100,updateFilter);
  34. audioShield.eqFilter(1,updateFilter);
  35. }
  36. elapsedMillis chgMsec=0;
  37. float tone1=0;
  38. void loop() {
  39. // every 10 ms, check for adjustment
  40. if (chgMsec > 10) {
  41. float tone2=analogRead(15);
  42. tone2=floor(((tone2-512)/512)*70)/10;
  43. if(tone2!=tone1)
  44. {
  45. // calcBiquad(FilterType,FrequencyC,dBgain,Q,QuantizationUnit,SampleRate,int*);
  46. calcBiquad(FILTER_PARAEQ,110,-tone2,0.2,524288,44100,updateFilter);
  47. audioShield.eqFilter(0,updateFilter);
  48. calcBiquad(FILTER_PARAEQ,4400,tone2,0.167,524288,44100,updateFilter);
  49. audioShield.eqFilter(1,updateFilter);
  50. tone1=tone2;
  51. }
  52. chgMsec = 0;
  53. }
  54. }