-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlpc.h
executable file
·97 lines (74 loc) · 2.63 KB
/
lpc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//-----------------------------------------------------------------------------
// name: lpc.h
// desc: linear predictive coding
//
// authors: Ananya Misra ([email protected])
// Ge Wang ([email protected])
//
// based (heavily) on filtlpc.c and lpcresyn.c by Perry Cook
// matrix based on fmatrix by George Tzanetakis
//
// date: today
//-----------------------------------------------------------------------------
#ifndef __LPC_H__
#define __LPC_H__
#include <stdlib.h>
#ifndef SAMPLE
#define SAMPLE float
#endif
// forward reference
typedef struct lpc_data_ * lpc_data;
// init
lpc_data lpc_create( );
// analysis
void lpc_analyze( lpc_data instance, SAMPLE * x, int len, float * coefs,
int order, float * power, float * pitch,
SAMPLE * residue = NULL );
// synthesis
void lpc_synthesize( lpc_data instance, SAMPLE * y, int len, float * coefs,
int order, float power, float pitch, int alt = 0 );
// done
void lpc_destroy( lpc_data & instance );
// helper -- autocorrelation
float autocorrelate( SAMPLE * x, int len, SAMPLE * y );
// helper -- lpc prediction
float lpc_predict( lpc_data lpc, SAMPLE * x, int len, float * coefs, int order );
// helper -- preemphasis
void lpc_preemphasis( SAMPLE * x, int len, float alpha );
// helper -- deemphasis
void lpc_deemphasis( SAMPLE * y, int len, float alpha );
// helper -- set alt src
void lpc_alt( lpc_data lpc, SAMPLE * buffer, int len );
//-----------------------------------------------------------------------------
// name: class thematrix
// desc: ...
//-----------------------------------------------------------------------------
class thematrix
{
public:
thematrix( unsigned int rows, unsigned int cols );
~thematrix();
public:
int invert( thematrix & res );
public:
float * operator[]( const long r );
const float * operator[]( const long r ) const;
public:
float * m_data;
unsigned int m_size;
unsigned int m_rows;
unsigned int m_cols;
};
//-----------------------------------------------------------------------------
// name: operator[]
// desc: yes, you see what this does
//-----------------------------------------------------------------------------
inline float * thematrix::operator[]( const long row )
{ return m_data + row * m_cols; }
//-----------------------------------------------------------------------------
// name: the other operator[]
// desc: for the const cases if you know what i mean
//-----------------------------------------------------------------------------
inline const float * thematrix::operator[]( const long row ) const
{ return m_data + row * m_cols; }
#endif