#ifndef _LPC_utilities_h_
#define _LPC_utilities_h_
/* LPC_utilities.h
 *
 * Copyright (C) 1994-2002 David Weenink
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/*
 djmw 19950530
 djmw 20020812 GPL header
*/

#include "LPC.h"

/* Algorithms based on Markel & Gray, Linear Prediction of Speech */

int MGa_to_rc (const float a[], float rc[], int predictionOrder);
/* Prediction coeffs a[1..predictionOrder] to reflection coeffs rc[lips..glottis] */
/* Markel&Gray, LP of Speech, page 96, formula 5.12 */
/* possible errors: no memory or rc > 1 (unstable filter) */
 

void MGrc_to_area (const float rc[], float area[], int predictionOrder);
/* reflection coeffs rc[lips..glottis] to area function area[lips..glottis] */
/* Markel&Gray, LP of Speech, page 80 */

int MGfb_to_a (const float f[], const float b[], int nfb, double samplingFrequency, float a[]);
/* Formants & bandwidths[1..nfb] to prediction coeffs a[1..2*nfb] */
/* A(z) = Sum(k=0,k=p, a[k]z^-k) = Product(k=1,k=p/2, 1+p[k]z^-1+q[k]z^-2) */
/* possible errors: no memory */

void MGa_to_fb (const float a[], int predictionOrder, double samplingFrequency,
	float f[], float b[], int *nFound);
/* formants and bandwidths from prediction coeffs */

void MGa_to_cepstrum (const float a[], float c[], int predictionOrder, float alpha);
/* lp coeffs a[1..predictionOrder]&alpha to cepstral coeffs c[0..predictionOrder]
 * Saito & Nakata, Fundamentals of Signal processing, 1985, pag 227.
 *		alpha : residual power (sum squared of prediction errors)
 *		our a's have opposite sign!!!
*/

void MGcepstrum_to_a (float c[], float a[], int predictionOrder, float *alpha);


#endif /* _LPC_utilities_h_ */
