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

93 lines
2.8KB

  1. /* Audio Library for Teensy 3.X
  2. * Copyright (c) 2018, Paul Stoffregen, paul@pjrc.com
  3. *
  4. * Development of this audio library was funded by PJRC.COM, LLC by sales of
  5. * Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop
  6. * open source software by purchasing Teensy or other PJRC products.
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice, development funding notice, and this permission
  16. * notice shall be included in all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. */
  26. #ifndef effect_freeverb_h_
  27. #define effect_freeverb_h_
  28. #include <Arduino.h>
  29. #include "AudioStream.h"
  30. class AudioEffectFreeverb : public AudioStream
  31. {
  32. public:
  33. AudioEffectFreeverb();
  34. virtual void update();
  35. void roomsize(float n) {
  36. if (n > 1.0f) n = 1.0f;
  37. else if (n < 0.0) n = 0.0f;
  38. combfeeback = (int)(n * 9175.04f) + 22937;
  39. }
  40. void damping(float n) {
  41. if (n > 1.0f) n = 1.0f;
  42. else if (n < 0.0) n = 0.0f;
  43. int x1 = (int)(n * 13107.2f);
  44. int x2 = 32768 - x1;
  45. __disable_irq();
  46. combdamp1 = x1;
  47. combdamp2 = x2;
  48. __enable_irq();
  49. }
  50. private:
  51. audio_block_t *inputQueueArray[2];
  52. int16_t comb1buf[1116];
  53. int16_t comb2buf[1188];
  54. int16_t comb3buf[1277];
  55. int16_t comb4buf[1356];
  56. int16_t comb5buf[1422];
  57. int16_t comb6buf[1491];
  58. int16_t comb7buf[1557];
  59. int16_t comb8buf[1617];
  60. uint16_t comb1index;
  61. uint16_t comb2index;
  62. uint16_t comb3index;
  63. uint16_t comb4index;
  64. uint16_t comb5index;
  65. uint16_t comb6index;
  66. uint16_t comb7index;
  67. uint16_t comb8index;
  68. int16_t comb1filter;
  69. int16_t comb2filter;
  70. int16_t comb3filter;
  71. int16_t comb4filter;
  72. int16_t comb5filter;
  73. int16_t comb6filter;
  74. int16_t comb7filter;
  75. int16_t comb8filter;
  76. int16_t combdamp1;
  77. int16_t combdamp2;
  78. int16_t combfeeback;
  79. int16_t allpass1buf[556];
  80. int16_t allpass2buf[441];
  81. int16_t allpass3buf[341];
  82. int16_t allpass4buf[225];
  83. uint16_t allpass1index;
  84. uint16_t allpass2index;
  85. uint16_t allpass3index;
  86. uint16_t allpass4index;
  87. };
  88. #endif