🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
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.

89 lines
2.7 KiB

  1. /*-
  2. * Copyright (c) 2005 Boris Mikhaylov
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining
  5. * a copy of this software and associated documentation files (the
  6. * "Software"), to deal in the Software without restriction, including
  7. * without limitation the rights to use, copy, modify, merge, publish,
  8. * distribute, sublicense, and/or sell copies of the Software, and to
  9. * permit persons to whom the Software is furnished to do so, subject to
  10. * the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be
  13. * included in all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  18. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  19. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  20. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  21. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. */
  23. #ifndef CORE_BS2B_H
  24. #define CORE_BS2B_H
  25. #include "almalloc.h"
  26. /* Number of crossfeed levels */
  27. #define BS2B_CLEVELS 3
  28. /* Normal crossfeed levels */
  29. #define BS2B_HIGH_CLEVEL 3
  30. #define BS2B_MIDDLE_CLEVEL 2
  31. #define BS2B_LOW_CLEVEL 1
  32. /* Easy crossfeed levels */
  33. #define BS2B_HIGH_ECLEVEL BS2B_HIGH_CLEVEL + BS2B_CLEVELS
  34. #define BS2B_MIDDLE_ECLEVEL BS2B_MIDDLE_CLEVEL + BS2B_CLEVELS
  35. #define BS2B_LOW_ECLEVEL BS2B_LOW_CLEVEL + BS2B_CLEVELS
  36. /* Default crossfeed levels */
  37. #define BS2B_DEFAULT_CLEVEL BS2B_HIGH_ECLEVEL
  38. /* Default sample rate (Hz) */
  39. #define BS2B_DEFAULT_SRATE 44100
  40. struct bs2b {
  41. int level; /* Crossfeed level */
  42. int srate; /* Sample rate (Hz) */
  43. /* Lowpass IIR filter coefficients */
  44. float a0_lo;
  45. float b1_lo;
  46. /* Highboost IIR filter coefficients */
  47. float a0_hi;
  48. float a1_hi;
  49. float b1_hi;
  50. /* Buffer of filter history
  51. * [0] - first channel, [1] - second channel
  52. */
  53. struct t_last_sample {
  54. float lo;
  55. float hi;
  56. } history[2];
  57. DEF_NEWDEL(bs2b)
  58. };
  59. /* Clear buffers and set new coefficients with new crossfeed level and sample
  60. * rate values.
  61. * level - crossfeed level of *LEVEL values.
  62. * srate - sample rate by Hz.
  63. */
  64. void bs2b_set_params(bs2b *bs2b, int level, int srate);
  65. /* Return current crossfeed level value */
  66. int bs2b_get_level(bs2b *bs2b);
  67. /* Return current sample rate value */
  68. int bs2b_get_srate(bs2b *bs2b);
  69. /* Clear buffer */
  70. void bs2b_clear(bs2b *bs2b);
  71. void bs2b_cross_feed(bs2b *bs2b, float *Left, float *Right, size_t SamplesToDo);
  72. #endif /* CORE_BS2B_H */