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 EQ_H_ 7 #define EQ_H_ 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 /* An EQ is a chain of biquad filters. See Web Audio API spec for details of the 14 * biquad filters and their parameters. */ 15 16 #include "biquad.h" 17 18 /* Maximum number of biquad filters an EQ can have */ 19 #define MAX_BIQUADS_PER_EQ 10 20 21 struct eq; 22 23 /* Create an EQ. */ 24 struct eq *eq_new(); 25 26 /* Free an EQ. */ 27 void eq_free(struct eq *eq); 28 29 /* Append a biquad filter to an EQ. An EQ can have at most MAX_BIQUADS_PER_EQ 30 * biquad filters. 31 * Args: 32 * eq - The EQ we want to use. 33 * type - The type of the biquad filter we want to append. 34 * frequency - The value should be in the range [0, 1]. It is relative to 35 * half of the sampling rate. 36 * Q, gain - The meaning depends on the type of the filter. See Web Audio 37 * API for details. 38 * Returns: 39 * 0 if success. -1 if the eq has no room for more biquads. 40 */ 41 int eq_append_biquad(struct eq *eq, enum biquad_type type, float freq, float Q, 42 float gain); 43 44 /* Append a biquad filter to an EQ. An EQ can have at most MAX_BIQUADS_PER_EQ 45 * biquad filters. This is similar to eq_append_biquad(), but it specifies the 46 * biquad coefficients directly. 47 * Args: 48 * eq - The EQ we want to use. 49 * biquad - The parameters for the biquad filter. 50 * Returns: 51 * 0 if success. -1 if the eq has no room for more biquads. 52 */ 53 int eq_append_biquad_direct(struct eq *eq, const struct biquad *biquad); 54 55 /* Process a buffer of audio data through the EQ. 56 * Args: 57 * eq - The EQ we want to use. 58 * data - The array of audio samples. 59 * count - The number of elements in the data array to process. 60 */ 61 void eq_process(struct eq *eq, float *data, int count); 62 63 #ifdef __cplusplus 64 } /* extern "C" */ 65 #endif 66 67 #endif /* EQ_H_ */ 68