選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

CalcBiquadToneControlDAP.ino 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. }