Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
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
4.2KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2008 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. #pragma once
  19. #include "JACK/Client.H"
  20. #include <math.h>
  21. sample_t *buffer_alloc ( nframes_t size );
  22. void buffer_apply_gain ( sample_t *buf, nframes_t nframes, float g );
  23. void buffer_apply_gain_unaligned ( sample_t *buf, nframes_t nframes, float g );
  24. void buffer_apply_gain_buffer ( sample_t *buf, const sample_t *gainbuf, nframes_t nframes );
  25. void buffer_copy_and_apply_gain_buffer ( sample_t *dst, const sample_t *src, const sample_t *gainbuf, nframes_t nframes );
  26. void buffer_mix ( sample_t *dst, const sample_t *src, nframes_t nframes );
  27. void buffer_mix_with_gain ( sample_t *dst, const sample_t *src, nframes_t nframes, float g );
  28. void buffer_interleave_one_channel ( sample_t *dst, const sample_t *src, int channel, int channels, nframes_t nframes );
  29. void buffer_interleave_one_channel_and_mix ( sample_t *dst, const sample_t *src, int channel, int channels, nframes_t nframes );
  30. void buffer_deinterleave_one_channel ( sample_t *dst, const sample_t *src, int channel, int channels, nframes_t nframes );
  31. void buffer_interleaved_mix ( sample_t *__restrict__ dst, const sample_t * __restrict__ src, int dst_channel, int src_channel, int dst_channels, int src_channels, nframes_t nframes );
  32. void buffer_interleaved_copy ( sample_t *__restrict__ dst, const sample_t * __restrict__ src, int dst_channel, int src_channel, int dst_channels, int src_channels, nframes_t nframes );
  33. void buffer_fill_with_silence ( sample_t *buf, nframes_t nframes );
  34. bool buffer_is_digital_black ( const sample_t *buf, nframes_t nframes );
  35. float buffer_get_peak ( const sample_t *buf, nframes_t nframes );
  36. void buffer_copy ( sample_t *dst, const sample_t *src, nframes_t nframes );
  37. void buffer_copy_and_apply_gain ( sample_t *dst, const sample_t *src, nframes_t nframes, float gain );
  38. class Value_Smoothing_Filter
  39. {
  40. float w, g1, g2;
  41. float _cutoff;
  42. public:
  43. Value_Smoothing_Filter ( )
  44. {
  45. g1 = g2 = 0;
  46. _cutoff = 10.0f;
  47. }
  48. void cutoff ( float v ) { _cutoff = v; }
  49. void sample_rate ( nframes_t v );
  50. inline bool target_reached ( float gt ) const { return gt == g2; }
  51. bool apply ( sample_t *dst, nframes_t nframes, float target );
  52. };
  53. static inline float interpolate_cubic ( const float fr, const float inm1, const float in, const float inp1, const float inp2)
  54. {
  55. return in + 0.5f * fr * (inp1 - inm1 +
  56. fr * (4.0f * inp1 + 2.0f * inm1 - 5.0f * in - inp2 +
  57. fr * (3.0f * (in - inp1) - inm1 + inp2)));
  58. }
  59. // from SWH plugins.
  60. // Convert a value in dB's to a coefficent
  61. #define DB_CO(g) ((g) > -90.0f ? powf(10.0f, (g) * 0.05f) : 0.0f)
  62. #define CO_DB(v) (20.0f * log10f(v))
  63. #define DEG2RAD 0.01745329251f
  64. #define ONEOVERSQRT2 0.70710678118f
  65. #ifndef likely
  66. #define likely(x) __builtin_expect(x,1)
  67. #endif
  68. #ifndef unlikely
  69. #define unlikely(x) __builtin_expect(x,0)
  70. #endif