1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
/*****************************************
EQ10 library version 1.0
Copyright (C)2002 4Front Technologies
Written by George Yohng
http://www.opensound.com
Proprietary software.
*****************************************/
#ifndef EQ10DSP_H_INCLUDED
#define EQ10DSP_H_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
/* used for volume detectors. for instance, if you want to plot
frequency response, you can use "detect" variable of needed
subband to query level of that frequency band.
release time - is the time in seconds in which detector falls back
to zero, if no peaks detected */
// #define EQ10_DETECTOR_CODE /* uncomment this to */
// #define EQ10_DETECTOR_RELEASE 1.0f /* enable band detector */
/* Dynamic limiter, which prevents EQ from distortion. In no case you
can overflow EQ and cause it to clip */
#define EQ10_TRIM_CODE 0.930 /* trim at -0.6dB */
#define EQ10_TRIM_RELEASE 0.700 /* trim release, in seconds */
#define EQ10_NOFBANDS 10 /* want more bands? not a problem */
#define EQ10_Q 1.41 /* global `Q' factor */
/* if you want separate Q per each band, comment global Q and uncomment
the following array */
//#define EQ10_DQ {1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4,1.4}
/* frequency table compatible to Q10 standard */
typedef
struct eq10band_s
{
double gain; /* gain of current band. Do not use this value,
use eq10_setgain instead */
#ifdef EQ10_DETECTOR_CODE
double detect; /* band detector value, do not use.
use eq10_detect to read detector value in dB */
double detectdecay; /* internal - do not use */
#endif
double ua0,ub1,ub2; /* internal - do not use */
double da0,db1,db2; /* internal - do not use */
double x1,x2,y1,y2; /* internal - do not use */
} eq10band_t;
typedef
struct eq10_s
{
double rate; /* sample rate; do not modify */
/* use eq10_setup to change */
eq10band_t band[EQ10_NOFBANDS]; /* bands of equalizer */
double detect; /* global detector value. do not use */
double detectdecay; /* internal - do not use */
} eq10_t;
double eq10_db2gain(double gain_dB); /* converts decibels to internal gain value*/
double eq10_gain2db(double gain); /* converts internal gain value to decibels*/
/* prepare eq array for processing,
eq - pointer to array,
eqs - number of elements in array (number of audio channels)
rate - sample rate
WARNING! this function resets all data in eq and sets all gains to 0dB
*/
void eq10_setup(eq10_t *eq, int eqs, double rate);
/* set band gain */
/*
eq - pointer to array,
eqs - number of elements in array (number of audio channels)
bandnr - # of band (0...EQ_NOFBANDS-1)
*/
void eq10_setgain(eq10_t *eq,int eqs,int bandnr,double gain_dB);
/* get current band gain */
/* eq - pointer to element, possible to read gain on each channel
separately */
double eq10_getgain(eq10_t *eq,int bandnr);
/* get detector value */
/* eq - pointer to element, possible to read detector value on
each channel separately */
double eq10_detect(eq10_t *eq,int bandnr);
/* process function
eq - pointer to eq structure, corresponding to wanted channel
buf - input buffer (interleaved multichannel)
outbuf - output buffer
sz - number of samples in input buffer
idx - index of processed channel (0...N-1)
step - total number of channels in interleaved stream (N)
*/
void eq10_processf(eq10_t *eq,float *buf,float *outbuf,int sz,int idx,int step);
/*
Example:
#define NCHAN 6
...
eq10_t eq[NCHAN]; // we process 5.1 data, thus 6 channels
int t;
eq10_t *peq;
...
eq10_setup(eq,NCHAN,44100); // initialize
...
eq10_setgain(eq,NCHAN, 5, -10.0f ); // set -10dB for gain6 (nr's from zero)
...
while (bla bla bla) // inner loop
{
for(t=0, peq=eq; t<NCHAN; t++, peq++)
{
eq10_processf(peq, input_buf, output_buf, cSamples, t, NCHAN);
}
}
...
*/
#ifdef __cplusplus
}
#endif
#endif //EQ10DSP_H_INCLUDED
|