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 CROSSOVER_H_ 7 #define CROSSOVER_H_ 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 /* An LR4 filter is two biquads with the same parameters connected in series: 14 * 15 * x -- [BIQUAD] -- y -- [BIQUAD] -- z 16 * 17 * Both biquad filter has the same parameter b[012] and a[12], 18 * The variable [xyz][12] keep the history values. 19 */ 20 struct lr4 { 21 float b0, b1, b2; 22 float a1, a2; 23 float x1, x2; 24 float y1, y2; 25 float z1, z2; 26 }; 27 28 /* Three bands crossover filter: 29 * 30 * INPUT --+-- lp0 --+-- lp1 --+---> LOW (0) 31 * | | | 32 * | \-- hp1 --/ 33 * | 34 * \-- hp0 --+-- lp2 ------> MID (1) 35 * | 36 * \-- hp2 ------> HIGH (2) 37 * 38 * [f0] [f1] 39 * 40 * Each lp or hp is an LR4 filter, which consists of two second-order 41 * lowpass or highpass butterworth filters. 42 */ 43 struct crossover { 44 struct lr4 lp[3], hp[3]; 45 }; 46 47 /* Initializes a crossover filter 48 * Args: 49 * xo - The crossover filter we want to initialize. 50 * freq1 - The normalized frequency splits low and mid band. 51 * freq2 - The normalized frequency splits mid and high band. 52 */ 53 void crossover_init(struct crossover *xo, float freq1, float freq2); 54 55 /* Splits input samples to three bands. 56 * Args: 57 * xo - The crossover filter to use. 58 * count - The number of input samples. 59 * data0 - The input samples, also the place to store low band output. 60 * data1 - The place to store mid band output. 61 * data2 - The place to store high band output. 62 */ 63 void crossover_process(struct crossover *xo, int count, float *data0, 64 float *data1, float *data2); 65 66 #ifdef __cplusplus 67 } /* extern "C" */ 68 #endif 69 70 #endif /* CROSSOVER_H_ */ 71