Beispiel #1
0
        /// <summary>
        /// Computes a bi-linear frequency warped version of the LPC cepstrum from the LPC cepstrum. The recursive algorithm
        /// used is defined in Oppenheim's paper in Proceedings of IEEE, June 1972 The program has been written using g[x,y]
        /// = g_o[x,-y] where g_o is the array used by Oppenheim. To handle the reversed array index the recursion has been
        /// done DOWN the array index.
        /// </summary>
        /// <param name="warp">The warping coefficient. For 16KHz speech 0.6 is good valued..</param>
        /// <param name="nbilincepstra">The number of bilinear cepstral values to be computed from the linear frequencycepstrum.</param>
        /// <returns>A bi-linear frequency warped version of the LPC cepstrum.</returns>
        public double[] GetBilinearCepstra(double warp, int nbilincepstra)
        {
            //double[][] g = new double[nbilincepstra][cepstrumOrder];
            var g = new double[nbilincepstra][];

            // Make a local copy as this gets destroyed
            var lincep = Java.CopyOf(_cepstra, _cepstrumOrder);

            _bilinearCepstra[0]      = lincep[0];
            lincep[0]                = 0;
            g[0][_cepstrumOrder - 1] = lincep[_cepstrumOrder - 1];
            for (var i = 1; i < nbilincepstra; i++)
            {
                g[i][_cepstrumOrder - 1] = 0;
            }

            for (var i = _cepstrumOrder - 2; i >= 0; i--)
            {
                g[0][i] = warp * g[0][i + 1] + lincep[i];
                g[1][i] = (1 - warp * warp) * g[0][i + 1] + warp * g[1][i + 1];
                for (var j = 2; j < nbilincepstra; j++)
                {
                    g[j][i] = warp * (g[j][i + 1] - g[j - 1][i]) + g[j - 1][i + 1];
                }
            }

            for (var i = 1; i <= nbilincepstra; i++)
            {
                _bilinearCepstra[i] = g[i][0];
            }

            return(_bilinearCepstra);
        }