Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

CalcBiquadToneControl.ino 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Tone example using AudioFilterBiquad object 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 BassFilter_L[]={0,0,0,0,0,0,0,0};
  8. int BassFilter_R[]={0,0,0,0,0,0,0,0};
  9. int TrebFilter_L[]={0,0,0,0,0,0,0,0};
  10. int TrebFilter_R[]={0,0,0,0,0,0,0,0};
  11. int updateFilter[5];
  12. AudioInputI2S audioInput; // audio shield: mic or line-in
  13. AudioFilterBiquad filterBass_L(BassFilter_L);
  14. AudioFilterBiquad filterBass_R(BassFilter_R);
  15. AudioFilterBiquad filterTreb_L(TrebFilter_L);
  16. AudioFilterBiquad filterTreb_R(TrebFilter_R);
  17. AudioOutputI2S audioOutput; // audio shield: headphones & line-out
  18. // Create Audio connections between the components
  19. //
  20. AudioConnection c1(audioInput,0,filterBass_L,0);
  21. AudioConnection c2(audioInput,1,filterBass_R,0);
  22. AudioConnection c3(filterBass_L,0,filterTreb_L,0);
  23. AudioConnection c4(filterBass_R,0,filterTreb_R,0);
  24. AudioConnection c5(filterTreb_L,0,audioOutput,0);
  25. AudioConnection c6(filterTreb_R,0,audioOutput,1);
  26. // Create an object to control the audio shield.
  27. //
  28. AudioControlSGTL5000 audioShield;
  29. void setup() {
  30. // Audio connections require memory to work. For more
  31. // detailed information, see the MemoryAndCpuUsage example
  32. AudioMemory(12);
  33. // Enable the audio shield, select the input and set the output volume.
  34. audioShield.enable();
  35. audioShield.inputSelect(myInput);
  36. audioShield.volume(75);
  37. audioShield.unmuteLineout();
  38. calcBiquad(FILTER_PARAEQ,110,0,0.2,2147483648,44100,updateFilter);
  39. filterBass_L.updateCoefs(updateFilter);
  40. filterBass_R.updateCoefs(updateFilter);
  41. calcBiquad(FILTER_PARAEQ,4400,0,0.167,2147483648,44100,updateFilter);
  42. filterTreb_L.updateCoefs(updateFilter);
  43. filterTreb_R.updateCoefs(updateFilter);
  44. }
  45. elapsedMillis chgMsec=0;
  46. float tone1=0;
  47. void loop() {
  48. // every 10 ms, check for adjustment the tone & vol
  49. if (chgMsec > 10) { // more regular updates for actual changes seems better.
  50. float tone2=analogRead(15);
  51. tone2=floor(((tone2-512)/512)*70)/10;
  52. if(tone2!=tone1)
  53. {
  54. // calcBiquad(FilterType,FrequencyC,dBgain,Q,QuantizationUnit,SampleRate,int*);
  55. calcBiquad(FILTER_PARAEQ,110,-tone2,0.2,2147483648,44100,updateFilter);
  56. filterBass_L.updateCoefs(updateFilter);
  57. filterBass_R.updateCoefs(updateFilter);
  58. calcBiquad(FILTER_PARAEQ,4400,tone2,0.167,2147483648,44100,updateFilter);
  59. filterTreb_L.updateCoefs(updateFilter);
  60. filterTreb_R.updateCoefs(updateFilter);
  61. tone1=tone2;
  62. }
  63. chgMsec = 0;
  64. }
  65. }