You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
2.2KB

  1. /* Audio Library for Teensy, Ladder Filter
  2. * Copyright (c) 2021, Richard van Hoesel
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice, development funding notice, and this permission
  12. * notice shall be included in all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. * THE SOFTWARE.
  21. */
  22. //-----------------------------------------------------------
  23. // Huovilainen New Moog (HNM) model as per CMJ jun 2006
  24. // Implemented as Teensy Audio Library compatible object
  25. // Richard van Hoesel, Feb. 9 2021
  26. // v.1.02 now includes both cutoff and resonance "CV" modulation inputs
  27. // please retain this header if you use this code.
  28. //-----------------------------------------------------------
  29. // https://forum.pjrc.com/threads/60488?p=269609&viewfull=1#post269609
  30. #ifndef filter_ladder_h_
  31. #define filter_ladder_h_
  32. #include "Arduino.h"
  33. #include "AudioStream.h"
  34. class AudioFilterLadder: public AudioStream
  35. {
  36. public:
  37. AudioFilterLadder() : AudioStream(3, inputQueueArray) {};
  38. void frequency(float FC);
  39. void resonance(float reson);
  40. virtual void update(void);
  41. private:
  42. float LPF(float s, int i);
  43. void compute_coeffs(float fc);
  44. float alpha = 1.0;
  45. float beta[4] = {0.0, 0.0, 0.0, 0.0};
  46. float z0[4] = {0.0, 0.0, 0.0, 0.0};
  47. float z1[4] = {0.0, 0.0, 0.0, 0.0};
  48. float K = 1.0;
  49. float Fbase = 1000;
  50. //float Qbase = 0.5;
  51. //float overdrive = 1.0;
  52. audio_block_t *inputQueueArray[3];
  53. };
  54. #endif