Clean up MixSource
[openal-soft.git] / Alc / bs2b.h
blobe235e765e8fb628d97529bbe045b5922484566c8
1 /*-
2 * Copyright (c) 2005 Boris Mikhaylov
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:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
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.
24 #ifndef BS2B_H
25 #define BS2B_H
27 #include "almalloc.h"
29 /* Number of crossfeed levels */
30 #define BS2B_CLEVELS 3
32 /* Normal crossfeed levels */
33 #define BS2B_HIGH_CLEVEL 3
34 #define BS2B_MIDDLE_CLEVEL 2
35 #define BS2B_LOW_CLEVEL 1
37 /* Easy crossfeed levels */
38 #define BS2B_HIGH_ECLEVEL BS2B_HIGH_CLEVEL + BS2B_CLEVELS
39 #define BS2B_MIDDLE_ECLEVEL BS2B_MIDDLE_CLEVEL + BS2B_CLEVELS
40 #define BS2B_LOW_ECLEVEL BS2B_LOW_CLEVEL + BS2B_CLEVELS
42 /* Default crossfeed levels */
43 #define BS2B_DEFAULT_CLEVEL BS2B_HIGH_ECLEVEL
44 /* Default sample rate (Hz) */
45 #define BS2B_DEFAULT_SRATE 44100
47 struct bs2b {
48 int level; /* Crossfeed level */
49 int srate; /* Sample rate (Hz) */
51 /* Lowpass IIR filter coefficients */
52 float a0_lo;
53 float b1_lo;
55 /* Highboost IIR filter coefficients */
56 float a0_hi;
57 float a1_hi;
58 float b1_hi;
60 /* Buffer of last filtered sample.
61 * [0] - first channel, [1] - second channel
63 struct t_last_sample {
64 float asis;
65 float lo;
66 float hi;
67 } last_sample[2];
69 DEF_NEWDEL(bs2b)
72 /* Clear buffers and set new coefficients with new crossfeed level and sample
73 * rate values.
74 * level - crossfeed level of *LEVEL values.
75 * srate - sample rate by Hz.
77 void bs2b_set_params(bs2b *bs2b, int level, int srate);
79 /* Return current crossfeed level value */
80 int bs2b_get_level(bs2b *bs2b);
82 /* Return current sample rate value */
83 int bs2b_get_srate(bs2b *bs2b);
85 /* Clear buffer */
86 void bs2b_clear(bs2b *bs2b);
88 void bs2b_cross_feed(bs2b *bs2b, float *RESTRICT Left, float *RESTRICT Right, int SamplesToDo);
90 #endif /* BS2B_H */