diff OpenAL32/Include/bs2b.h @ 0:f9476ff7637e

initial forking of open-al to create multiple listeners
author Robert McIntyre <rlm@mit.edu>
date Tue, 25 Oct 2011 13:02:31 -0700
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/OpenAL32/Include/bs2b.h	Tue Oct 25 13:02:31 2011 -0700
     1.3 @@ -0,0 +1,109 @@
     1.4 +/*-
     1.5 + * Copyright (c) 2005 Boris Mikhaylov
     1.6 + *
     1.7 + * Permission is hereby granted, free of charge, to any person obtaining
     1.8 + * a copy of this software and associated documentation files (the
     1.9 + * "Software"), to deal in the Software without restriction, including
    1.10 + * without limitation the rights to use, copy, modify, merge, publish,
    1.11 + * distribute, sublicense, and/or sell copies of the Software, and to
    1.12 + * permit persons to whom the Software is furnished to do so, subject to
    1.13 + * the following conditions:
    1.14 + *
    1.15 + * The above copyright notice and this permission notice shall be
    1.16 + * included in all copies or substantial portions of the Software.
    1.17 + *
    1.18 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    1.19 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    1.20 + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    1.21 + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    1.22 + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    1.23 + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    1.24 + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    1.25 + */
    1.26 +
    1.27 +#ifndef BS2B_H
    1.28 +#define BS2B_H
    1.29 +
    1.30 +/* Number of crossfeed levels */
    1.31 +#define BS2B_CLEVELS           3
    1.32 +
    1.33 +/* Normal crossfeed levels */
    1.34 +#define BS2B_HIGH_CLEVEL       3
    1.35 +#define BS2B_MIDDLE_CLEVEL     2
    1.36 +#define BS2B_LOW_CLEVEL        1
    1.37 +
    1.38 +/* Easy crossfeed levels */
    1.39 +#define BS2B_HIGH_ECLEVEL      BS2B_HIGH_CLEVEL    + BS2B_CLEVELS
    1.40 +#define BS2B_MIDDLE_ECLEVEL    BS2B_MIDDLE_CLEVEL  + BS2B_CLEVELS
    1.41 +#define BS2B_LOW_ECLEVEL       BS2B_LOW_CLEVEL     + BS2B_CLEVELS
    1.42 +
    1.43 +/* Default crossfeed levels */
    1.44 +#define BS2B_DEFAULT_CLEVEL    BS2B_HIGH_ECLEVEL
    1.45 +/* Default sample rate (Hz) */
    1.46 +#define BS2B_DEFAULT_SRATE     44100
    1.47 +
    1.48 +#ifdef __cplusplus
    1.49 +extern "C" {
    1.50 +#endif /* __cplusplus */
    1.51 +
    1.52 +struct bs2b {
    1.53 +    int level;  /* Crossfeed level */
    1.54 +    int srate;   /* Sample rate (Hz) */
    1.55 +
    1.56 +    /* Lowpass IIR filter coefficients */
    1.57 +    double a0_lo;
    1.58 +    double b1_lo;
    1.59 +
    1.60 +    /* Highboost IIR filter coefficients */
    1.61 +    double a0_hi;
    1.62 +    double a1_hi;
    1.63 +    double b1_hi;
    1.64 +
    1.65 +    /* Global gain against overloading */
    1.66 +    double gain;
    1.67 +
    1.68 +    /* Buffer of last filtered sample.
    1.69 +     * [0] - first channel, [1] - second channel
    1.70 +     */
    1.71 +    struct t_last_sample {
    1.72 +        double asis[2];
    1.73 +        double lo[2];
    1.74 +        double hi[2];
    1.75 +    } last_sample;
    1.76 +};
    1.77 +
    1.78 +/* Clear buffers and set new coefficients with new crossfeed level value.
    1.79 + * level - crossfeed level of *LEVEL values.
    1.80 + */
    1.81 +void bs2b_set_level(struct bs2b *bs2b, int level);
    1.82 +
    1.83 +/* Return current crossfeed level value */
    1.84 +int bs2b_get_level(struct bs2b *bs2b);
    1.85 +
    1.86 +/* Clear buffers and set new coefficients with new sample rate value.
    1.87 + * srate - sample rate by Hz.
    1.88 + */
    1.89 +void bs2b_set_srate(struct bs2b *bs2b, int srate);
    1.90 +
    1.91 +/* Return current sample rate value */
    1.92 +int bs2b_get_srate(struct bs2b *bs2b);
    1.93 +
    1.94 +/* Clear buffer */
    1.95 +void bs2b_clear(struct bs2b *bs2b);
    1.96 +
    1.97 +/* Return 1 if buffer is clear */
    1.98 +int bs2b_is_clear(struct bs2b *bs2b);
    1.99 +
   1.100 +/* Crossfeeds one stereo sample that are pointed by sample.
   1.101 + * [0] - first channel, [1] - second channel.
   1.102 + * Returns crossfided samle by sample pointer.
   1.103 + */
   1.104 +
   1.105 +/* sample poits to floats */
   1.106 +void bs2b_cross_feed(struct bs2b *bs2b, float *sample);
   1.107 +
   1.108 +#ifdef __cplusplus
   1.109 +}    /* extern "C" */
   1.110 +#endif /* __cplusplus */
   1.111 +
   1.112 +#endif /* BS2B_H */