Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

filter_ladder.h 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. void octaveControl(float octaves);
  41. virtual void update(void);
  42. private:
  43. float LPF(float s, int i);
  44. void compute_coeffs(float fc);
  45. bool resonating();
  46. float alpha = 1.0;
  47. float beta[4] = {0.0, 0.0, 0.0, 0.0};
  48. float z0[4] = {0.0, 0.0, 0.0, 0.0};
  49. float z1[4] = {0.0, 0.0, 0.0, 0.0};
  50. float K = 1.0;
  51. float Fbase = 1000;
  52. float octaveScale = 1.0f/32768.0f;
  53. //float Qbase = 0.5;
  54. //float overdrive = 1.0;
  55. audio_block_t *inputQueueArray[3];
  56. };
  57. #endif