1 /*-------------- Telecommunications & Signal Processing Lab ---------------
2 McGill University
3
4 Routine:
5 void PQgroupCB (const double X2[], const struct PQ_CB *CBpar, double Eb[])
6
7 Purpose:
8 Group DFT energy values into partial critical bands
9
10 Description:
11 This routine takes a vector of DFT coefficients (squared magnitudes) and
12 groups them into bands.
13
14 Parameters:
15 -> const double X2[]
16 DFT magnitude values
17 -> const struct PQ_CB *CBpar
18 Mapping tables
19 <- double Eb[]
20 Output energies (excitation) for the bands
21
22 Author / revision:
23 P. Kabal Copyright (C) 2003
24 $Revision: 1.6 $ $Date: 2003/05/13 01:11:27 $
25
26 -------------------------------------------------------------------------*/
27
28 #include "PQevalAudio.h"
29
30 #define MAXV(a, b) (((a) > (b)) ? (a) : (b))
31
32 #define EMIN 1e-12
33
34
35 void
PQgroupCB(const double X2[],const struct Par_CB * CBpar,double Eb[])36 PQgroupCB (const double X2[], const struct Par_CB *CBpar, double Eb[])
37
38 {
39 int i, k;
40 double Ea;
41 const int Nc = CBpar->Nc;
42 const double *Ul = CBpar->Ul;
43 const double *Uu = CBpar->Uu;
44 const int *kl = CBpar->kl;
45 const int *ku = CBpar->ku;
46
47 /* Compute the excitation in each band */
48 for (i = 0; i < Nc; ++i) {
49 Ea = Ul[i] * X2[kl[i]]; /* First bin */
50
51 for (k = kl[i]+1; k < ku[i]; ++k)
52 Ea += X2[k]; /* Middle bins */
53
54 Ea += Uu[i] * X2[ku[i]]; /* Last bin */
55 Eb[i] = MAXV (Ea, EMIN);
56 }
57
58 return;
59 }
60