#ifndef _LPC_utilities_h_
#define _LPC_utilities_h_
/* David Weenink, 30/5/95 */

#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_ */
