Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

CalcBiquadToneControlDAP.ino 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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(75);
  27. audioShield.unmuteLineout();
  28. audioShield.dap_enable(); // enable the DAP block in SGTL5000
  29. audioShield.dap_audio_eq(1); // using PEQ Biquad filters
  30. audioShield.dap_peqs(2); // enable filter 0 & filter 1
  31. calcBiquad(FILTER_PARAEQ,110,0,0.2,524288,44100,updateFilter);
  32. audioShield.load_peq(0,updateFilter);
  33. calcBiquad(FILTER_PARAEQ,4400,0,0.167,524288,44100,updateFilter);
  34. audioShield.load_peq(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.load_peq(0,updateFilter);
  48. calcBiquad(FILTER_PARAEQ,4400,tone2,0.167,524288,44100,updateFilter);
  49. audioShield.load_peq(1,updateFilter);
  50. tone1=tone2;
  51. }
  52. chgMsec = 0;
  53. }
  54. }