Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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.01 now includes FC "CV" modulation input
  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(2, 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 overdrive = 1.0;
  51. audio_block_t *inputQueueArray[2];
  52. };
  53. #endif