Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

65 rindas
2.1KB

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