• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2  * Use of this source code is governed by a BSD-style license that can be
3  * found in the LICENSE file.
4  */
5 
6 #ifndef CROSSOVER2_H_
7 #define CROSSOVER2_H_
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /* "crossover2" is a two channel version of the "crossover" filter. It processes
14  * two channels of data at once to increase performance. */
15 
16 /* An LR4 filter is two biquads with the same parameters connected in series:
17  *
18  * x -- [BIQUAD] -- y -- [BIQUAD] -- z
19  *
20  * Both biquad filter has the same parameter b[012] and a[12],
21  * The variable [xyz][12][LR] keep the history values.
22  */
23 struct lr42 {
24 	float b0, b1, b2;
25 	float a1, a2;
26 	float x1L, x1R, x2L, x2R;
27 	float y1L, y1R, y2L, y2R;
28 	float z1L, z1R, z2L, z2R;
29 };
30 
31 /* Three bands crossover filter:
32  *
33  * INPUT --+-- lp0 --+-- lp1 --+---> LOW (0)
34  *         |         |         |
35  *         |         \-- hp1 --/
36  *         |
37  *         \-- hp0 --+-- lp2 ------> MID (1)
38  *                   |
39  *                   \-- hp2 ------> HIGH (2)
40  *
41  *            [f0]       [f1]
42  *
43  * Each lp or hp is an LR4 filter, which consists of two second-order
44  * lowpass or highpass butterworth filters.
45  */
46 struct crossover2 {
47 	struct lr42 lp[3], hp[3];
48 };
49 
50 /* Initializes a crossover2 filter
51  * Args:
52  *    xo2 - The crossover2 filter we want to initialize.
53  *    freq1 - The normalized frequency splits low and mid band.
54  *    freq2 - The normalized frequency splits mid and high band.
55  */
56 void crossover2_init(struct crossover2 *xo2, float freq1, float freq2);
57 
58 /* Splits input samples to three bands.
59  * Args:
60  *    xo2 - The crossover2 filter to use.
61  *    count - The number of input samples.
62  *    data0L, data0R - The input samples, also the place to store low band
63  *                     output.
64  *    data1L, data1R - The place to store mid band output.
65  *    data2L, data2R - The place to store high band output.
66  */
67 void crossover2_process(struct crossover2 *xo2, int count,
68 			float *data0L, float *data0R,
69 			float *data1L, float *data1R,
70 			float *data2L, float *data2R);
71 
72 #ifdef __cplusplus
73 } /* extern "C" */
74 #endif
75 
76 #endif /* CROSSOVER2_H_ */
77