annotate OpenAL32/Include/bs2b.h @ 32:b8bc24918d63

moved ear.org into cortex
author Robert McIntyre <rlm@mit.edu>
date Sat, 04 Feb 2012 01:43:33 -0700
parents f9476ff7637e
children
rev   line source
rlm@0 1 /*-
rlm@0 2 * Copyright (c) 2005 Boris Mikhaylov
rlm@0 3 *
rlm@0 4 * Permission is hereby granted, free of charge, to any person obtaining
rlm@0 5 * a copy of this software and associated documentation files (the
rlm@0 6 * "Software"), to deal in the Software without restriction, including
rlm@0 7 * without limitation the rights to use, copy, modify, merge, publish,
rlm@0 8 * distribute, sublicense, and/or sell copies of the Software, and to
rlm@0 9 * permit persons to whom the Software is furnished to do so, subject to
rlm@0 10 * the following conditions:
rlm@0 11 *
rlm@0 12 * The above copyright notice and this permission notice shall be
rlm@0 13 * included in all copies or substantial portions of the Software.
rlm@0 14 *
rlm@0 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
rlm@0 16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
rlm@0 17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
rlm@0 18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
rlm@0 19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
rlm@0 20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
rlm@0 21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
rlm@0 22 */
rlm@0 23
rlm@0 24 #ifndef BS2B_H
rlm@0 25 #define BS2B_H
rlm@0 26
rlm@0 27 /* Number of crossfeed levels */
rlm@0 28 #define BS2B_CLEVELS 3
rlm@0 29
rlm@0 30 /* Normal crossfeed levels */
rlm@0 31 #define BS2B_HIGH_CLEVEL 3
rlm@0 32 #define BS2B_MIDDLE_CLEVEL 2
rlm@0 33 #define BS2B_LOW_CLEVEL 1
rlm@0 34
rlm@0 35 /* Easy crossfeed levels */
rlm@0 36 #define BS2B_HIGH_ECLEVEL BS2B_HIGH_CLEVEL + BS2B_CLEVELS
rlm@0 37 #define BS2B_MIDDLE_ECLEVEL BS2B_MIDDLE_CLEVEL + BS2B_CLEVELS
rlm@0 38 #define BS2B_LOW_ECLEVEL BS2B_LOW_CLEVEL + BS2B_CLEVELS
rlm@0 39
rlm@0 40 /* Default crossfeed levels */
rlm@0 41 #define BS2B_DEFAULT_CLEVEL BS2B_HIGH_ECLEVEL
rlm@0 42 /* Default sample rate (Hz) */
rlm@0 43 #define BS2B_DEFAULT_SRATE 44100
rlm@0 44
rlm@0 45 #ifdef __cplusplus
rlm@0 46 extern "C" {
rlm@0 47 #endif /* __cplusplus */
rlm@0 48
rlm@0 49 struct bs2b {
rlm@0 50 int level; /* Crossfeed level */
rlm@0 51 int srate; /* Sample rate (Hz) */
rlm@0 52
rlm@0 53 /* Lowpass IIR filter coefficients */
rlm@0 54 double a0_lo;
rlm@0 55 double b1_lo;
rlm@0 56
rlm@0 57 /* Highboost IIR filter coefficients */
rlm@0 58 double a0_hi;
rlm@0 59 double a1_hi;
rlm@0 60 double b1_hi;
rlm@0 61
rlm@0 62 /* Global gain against overloading */
rlm@0 63 double gain;
rlm@0 64
rlm@0 65 /* Buffer of last filtered sample.
rlm@0 66 * [0] - first channel, [1] - second channel
rlm@0 67 */
rlm@0 68 struct t_last_sample {
rlm@0 69 double asis[2];
rlm@0 70 double lo[2];
rlm@0 71 double hi[2];
rlm@0 72 } last_sample;
rlm@0 73 };
rlm@0 74
rlm@0 75 /* Clear buffers and set new coefficients with new crossfeed level value.
rlm@0 76 * level - crossfeed level of *LEVEL values.
rlm@0 77 */
rlm@0 78 void bs2b_set_level(struct bs2b *bs2b, int level);
rlm@0 79
rlm@0 80 /* Return current crossfeed level value */
rlm@0 81 int bs2b_get_level(struct bs2b *bs2b);
rlm@0 82
rlm@0 83 /* Clear buffers and set new coefficients with new sample rate value.
rlm@0 84 * srate - sample rate by Hz.
rlm@0 85 */
rlm@0 86 void bs2b_set_srate(struct bs2b *bs2b, int srate);
rlm@0 87
rlm@0 88 /* Return current sample rate value */
rlm@0 89 int bs2b_get_srate(struct bs2b *bs2b);
rlm@0 90
rlm@0 91 /* Clear buffer */
rlm@0 92 void bs2b_clear(struct bs2b *bs2b);
rlm@0 93
rlm@0 94 /* Return 1 if buffer is clear */
rlm@0 95 int bs2b_is_clear(struct bs2b *bs2b);
rlm@0 96
rlm@0 97 /* Crossfeeds one stereo sample that are pointed by sample.
rlm@0 98 * [0] - first channel, [1] - second channel.
rlm@0 99 * Returns crossfided samle by sample pointer.
rlm@0 100 */
rlm@0 101
rlm@0 102 /* sample poits to floats */
rlm@0 103 void bs2b_cross_feed(struct bs2b *bs2b, float *sample);
rlm@0 104
rlm@0 105 #ifdef __cplusplus
rlm@0 106 } /* extern "C" */
rlm@0 107 #endif /* __cplusplus */
rlm@0 108
rlm@0 109 #endif /* BS2B_H */