1 /*(LGPL) 2 --------------------------------------------------------------------------- 3 a_limiter.h - Simple limiter 4 --------------------------------------------------------------------------- 5 * Copyright (C) 2001. 2002, David Olofson 6 * 7 * This program is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU Lesser General Public License as published by 9 * the Free Software Foundation; either version 2.1 of the License, or (at 10 * your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, but 13 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public License 18 * along with this program; if not, write to the Free Software Foundation, 19 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 */ 21 22 #ifndef _A_LIMITER_H_ 23 #define _A_LIMITER_H_ 24 25 typedef struct limiter_t 26 { 27 int samplerate; 28 unsigned threshold; /* Reaction threshold */ 29 int release; /* Release "speed" */ 30 unsigned peak; /* Filtered peak value */ 31 unsigned attenuation; /* Current output attenuation */ 32 } limiter_t; 33 34 enum lim_params_t 35 { 36 LIM_THRESHOLD = 0, /* 16 bit sample units */ 37 LIM_RELEASE /* Units per second */ 38 }; 39 40 41 int lim_open(limiter_t *lim, int samplerate); 42 void lim_close(limiter_t *lim); 43 44 void lim_control(limiter_t *lim, int param, int value); 45 46 /* 47 * Limiter stereo process function. 48 * Supports in-place processing. 49 */ 50 void lims_process(limiter_t *lim, int *in, int *out, unsigned frames); 51 52 /* 53 * Smart Stereo version. 54 * 55 * This algorithm takes both channels in account in a way 56 * that reduces the effect of the center appearing to have 57 * more power after compression of signals with unbalanced 58 * stereo images. 59 * 60 * A dead center signal can only get 3 dB louder than the 61 * same signal in one channel only, as opposed to the 62 * normal 6 dB of a limiter that only looks at max(L, R). 63 * 64 * Meanwhile, with "normal" material (ie most power 65 * relatively centered), this limiter gets an extra 3 dB 66 * compared to a limiter that checks (L+R). 67 */ 68 void limss_process(limiter_t *lim, int *in, int *out, unsigned frames); 69 70 #endif /*_A_LIMITER_H_*/ 71