20static inline int imin(
int x,
int y)
25static inline int imax(
int x,
int y)
36 int firstBad,
int numBad)
43 float delta = buffer[numBad] - buffer[numBad+1];
44 float value = buffer[numBad];
54 else if (firstBad + numBad == len) {
55 float delta = buffer[firstBad-1] - buffer[firstBad-2];
56 float value = buffer[firstBad-1];
58 while (i < firstBad + numBad) {
67 float v1 = buffer[firstBad-1];
68 float v2 = buffer[firstBad+numBad];
70 float delta = (v2 - v1) / (numBad+1);
72 while (i < firstBad + numBad) {
83 size_t firstBad,
size_t numBad)
90 firstBad+numBad <= len);
101 for(
size_t i=0; i<len; i++)
102 buffer2[len-1-i] = buffer[i];
104 for(
size_t i=0; i<len; i++)
105 buffer[len-1-i] = buffer2[i];
113 imin(
imin(numBad * 3, 50),
imax(firstBad - 1, len - (firstBad + numBad) - 1));
115 if (IP < 3 || IP >= (
int)N) {
128 for(
size_t i=0; i<N; i++)
129 s[i] += (rand()-(RAND_MAX/2))/(RAND_MAX*10000.0);
137 for(
size_t i = 0; i +
P < len; i++)
138 if (i+P < firstBad || i >= (firstBad + numBad))
139 for(
size_t row=0; row<
P; row++) {
140 for(
size_t col=0; col<
P; col++)
141 X[row][col] += (s[i+row] * s[i+col]);
142 b[row] += s[i+
P] * s[i+row];
155 const Vector &a = Xinv * b;
161 for(
size_t row=0; row<N-
P; row++) {
162 for(
size_t col=0; col<
P; col++)
163 A[row][row+col] = -a[col];
176 firstBad+numBad, N-(firstBad+numBad));
181 N-(firstBad+numBad));
199 const Vector &su = X4 * sk;
202 for(
size_t i=0; i<numBad; i++)
203 buffer[firstBad+i] = (
float)su[i];
static int imin(int x, int y)
static void LinearInterpolateAudio(float *buffer, int len, int firstBad, int numBad)
void InterpolateAudio(float *buffer, const size_t len, size_t firstBad, size_t numBad)
static int imax(int x, int y)
Vector VectorConcatenate(const Vector &left, const Vector &right)
Matrix MatrixSubset(const Matrix &input, unsigned startRow, unsigned numRows, unsigned startCol, unsigned numCols)
Matrix TransposeMatrix(const Matrix &other)
bool InvertMatrix(const Matrix &input, Matrix &Minv)
Matrix MatrixConcatenateCols(const Matrix &left, const Matrix &right)
Vector VectorSubset(const Vector &other, unsigned start, unsigned len)
Matrix MatrixMultiply(const Matrix &left, const Matrix &right)
General routine to interpolate (or even extrapolate small amounts) audio when a few of the samples ar...
Holds a matrix of doubles and supports arithmetic, subsetting, and matrix inversion....
Holds a matrix of doubles and supports arithmetic operations, including Vector-Matrix operations....