84{
85 const auto N = len;
86
87 wxASSERT(len > 0 &&
88 firstBad >= 0 &&
89 numBad < len &&
90 firstBad+numBad <= len);
91
92 if(numBad >= len)
93 return;
94
95 if (firstBad == 0) {
96
97
98
99
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];
106 return;
107 }
108
110
111
112 const int IP =
113 imin(
imin(numBad * 3, 50),
imax(firstBad - 1, len - (firstBad + numBad) - 1));
114
115 if (IP < 3 || IP >= (int)N) {
117 return;
118 }
119
121
122
123
124
125
126
127
128 for(size_t i=0; i<N; i++)
129 s[i] += (rand()-(RAND_MAX/2))/(RAND_MAX*10000.0);
130
131
132
133
136
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];
143 }
144
147
148
149
151 return;
152 }
153
154
155 const Vector &a = Xinv * b;
156
157
158
159
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];
165 }
166
167
168
169
170
171
172
176 firstBad+numBad, N-(firstBad+numBad));
178
181 N-(firstBad+numBad));
183
184
185
190
192 return;
193 }
197
198
199 const Vector &su = X4 * sk;
200
201
202 for(size_t i=0; i<numBad; i++)
203 buffer[firstBad+i] = (float)su[i];
204}
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)
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....