3 pub const MAX_BANDS: usize = 25;
5 const CRITICAL_FREQS: [usize; MAX_BANDS] = [
6 100, 200, 300, 400, 510, 630, 770, 920,
7 1080, 1270, 1480, 1720, 2000, 2320, 2700, 3150,
8 3700, 4400, 5300, 6400, 7700, 9500, 12000, 15500,
12 pub const RUN_TAB: [usize; 16] = [ 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 32, 64 ];
14 pub fn init_bands(srate: usize, len: usize, num_bands: &mut usize, bands: &mut [usize; MAX_BANDS + 1]) {
16 while *num_bands < CRITICAL_FREQS.len() && CRITICAL_FREQS[*num_bands - 1] < srate {
20 for (band, &freq) in bands[1..*num_bands].iter_mut().zip(CRITICAL_FREQS.iter()) {
21 *band = (freq * len / srate) & !1;
23 bands[*num_bands] = len;
26 pub fn get_quants_table() -> [f32; 96] {
27 let mut quants: [f32; 96] = [0.0; 96];
28 for (i, quant) in quants.iter_mut().enumerate() {
29 *quant = ((i as f32) * 0.0664 / consts::LOG10_E).exp();