Convert tabs to spaces. Remove accidently committed debug line
[xiph/unicode.git] / postfish / bessel.h
blob46b9598a0ea60d2237be83d96d458f0c6cff2c47
1 /*
3 * postfish
4 *
5 * Copyright (C) 2002-2005 Monty
7 * Postfish is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
12 * Postfish is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Postfish; see the file COPYING. If not, write to the
19 * Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "postfish.h"
25 extern int input_rate;
27 #define MAXORDER 2
29 typedef struct {
30 double c[MAXORDER];
31 double g;
32 int order;
33 float alpha;
34 float Hz;
35 float ms;
36 int samples;
37 } iir_filter;
39 static inline long impulse_ahead2(float alpha){
40 return rint(.13f/alpha);
42 static inline long impulse_ahead3(float alpha){
43 return rint(.22f/alpha);
45 static inline long impulse_ahead4(float alpha){
46 return rint(.32f/alpha);
49 static inline long step_ahead(float alpha){
50 return rint(.6f/alpha);
53 static inline float step_freq(long ahead){
54 return input_rate*.6f/ahead;
57 static inline float impulse_freq2(long ahead){
58 return input_rate*.13f/ahead;
60 static inline float impulse_freq3(long ahead){
61 return input_rate*.22f/ahead;
63 static inline float impulse_freq4(long ahead){
64 return input_rate*.32f/ahead;
67 typedef struct {
68 double x[MAXORDER];
69 double y[MAXORDER];
70 } iir_state;
72 extern double mkbessel(double raw_alpha,int order,double *ycoeff);
75 extern void compute_iir_symmetric_limited(float *x, int n, iir_state *is,
76 iir_filter *attack, iir_filter *limit);
78 extern void compute_iir_decay_limited(float *x, int n, iir_state *is,
79 iir_filter *decay, iir_filter *limit);
82 extern void compute_iir_freefall_limited(float *x, int n, iir_state *is,
83 iir_filter *attack, iir_filter *limit);
85 extern void compute_iir_freefallonly1(float *x, int n, iir_state *is,
86 iir_filter *decay);
89 extern void compute_iir_over_soft(float *x, int n, iir_state *is,
90 iir_filter *attack, iir_filter *limit,
91 float knee, float mult, float *adj);
93 extern void compute_iir_under_soft(float *x, int n, iir_state *is,
94 iir_filter *attack, iir_filter *limit,
95 float knee, float mult, float *adj);
97 extern void compute_iir_over_hard(float *x, int n, iir_state *is,
98 iir_filter *attack, iir_filter *limit,
99 float knee, float mult, float *adj);
101 extern void compute_iir_under_hard(float *x, int n, iir_state *is,
102 iir_filter *attack, iir_filter *limit,
103 float knee, float mult, float *adj);
105 extern void compute_iir_over_soft_del(float *x, int n, iir_state *is,
106 iir_filter *attack, iir_filter *limit,
107 float knee, float mult, float mult2,
108 float *adj);
110 extern void compute_iir_under_soft_del(float *x, int n, iir_state *is,
111 iir_filter *attack, iir_filter *limit,
112 float knee, float mult, float mult2,
113 float *adj);
115 extern void compute_iir_over_hard_del(float *x, int n, iir_state *is,
116 iir_filter *attack, iir_filter *limit,
117 float knee, float mult, float mult2,
118 float *adj);
120 extern void compute_iir_under_hard_del(float *x, int n, iir_state *is,
121 iir_filter *attack, iir_filter *limit,
122 float knee, float mult, float mult2,
123 float *adj);
125 extern void reset_iir(iir_state *is,float value);