static int Sound_into_BarkFilter_frame (Sound me, BarkFilter thee, long frame) { autoMatrix pv = Sound_to_spectralpower (me); long nf = pv -> nx; autoNUMvector<double> z (1, nf); for (long j = 1; j <= nf; j++) { z[j] = HZTOBARK (pv -> x1 + (j - 1) * pv -> dx); } for (long i = 1; i <= thy ny; i++) { double p = 0; double z0 = thy y1 + (i - 1) * thy dy; double *pow = pv -> z[1]; // TODO ?? for (long j = 1; j <= nf; j++) { // Sekey & Hanson filter is defined in the power domain. // We therefore multiply the power with a (and not a^2). // integral (F(z),z=0..25) = 1.58/9 double a = NUMsekeyhansonfilter_amplitude (z0, z[j]); p += a * pow[j] ; } thy z[i][frame] = p; } return 1; }
static void Sound_into_BarkSpectrogram_frame (Sound me, BarkSpectrogram thee, long frame) { autoSpectrum him = Sound_to_Spectrum_power (me); long numberOfFrequencies = his nx; autoNUMvector<double> z (1, numberOfFrequencies); for (long ifreq = 1; ifreq <= numberOfFrequencies; ifreq++) { double fhz = his x1 + (ifreq - 1) * his dx; z[ifreq] = thy v_hertzToFrequency (fhz); } for (long i = 1; i <= thy ny; i++) { double p = 0; double z0 = thy y1 + (i - 1) * thy dy; double *pow = his z[1]; // TODO ?? for (long ifreq = 1; ifreq <= numberOfFrequencies; ifreq++) { // Sekey & Hanson filter is defined in the power domain. // We therefore multiply the power with a (and not a^2). // integral (F(z),z=0..25) = 1.58/9 double a = NUMsekeyhansonfilter_amplitude (z0, z[ifreq]); p += a * pow[ifreq] ; } thy z[i][frame] = p; } }