OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 std::unique_ptr<FFTFrame> FFTFrame::createInterpolatedFrame( | 51 std::unique_ptr<FFTFrame> FFTFrame::createInterpolatedFrame( |
52 const FFTFrame& frame1, | 52 const FFTFrame& frame1, |
53 const FFTFrame& frame2, | 53 const FFTFrame& frame2, |
54 double x) { | 54 double x) { |
55 std::unique_ptr<FFTFrame> newFrame = | 55 std::unique_ptr<FFTFrame> newFrame = |
56 wrapUnique(new FFTFrame(frame1.fftSize())); | 56 wrapUnique(new FFTFrame(frame1.fftSize())); |
57 | 57 |
58 newFrame->interpolateFrequencyComponents(frame1, frame2, x); | 58 newFrame->interpolateFrequencyComponents(frame1, frame2, x); |
59 | 59 |
60 // In the time-domain, the 2nd half of the response must be zero, to avoid cir
cular convolution aliasing... | 60 // In the time-domain, the 2nd half of the response must be zero, to avoid |
| 61 // circular convolution aliasing... |
61 int fftSize = newFrame->fftSize(); | 62 int fftSize = newFrame->fftSize(); |
62 AudioFloatArray buffer(fftSize); | 63 AudioFloatArray buffer(fftSize); |
63 newFrame->doInverseFFT(buffer.data()); | 64 newFrame->doInverseFFT(buffer.data()); |
64 buffer.zeroRange(fftSize / 2, fftSize); | 65 buffer.zeroRange(fftSize / 2, fftSize); |
65 | 66 |
66 // Put back into frequency domain. | 67 // Put back into frequency domain. |
67 newFrame->doFFT(buffer.data()); | 68 newFrame->doFFT(buffer.data()); |
68 | 69 |
69 return newFrame; | 70 return newFrame; |
70 } | 71 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 // Unwrap | 198 // Unwrap |
198 if (deltaPhase < -piDouble) | 199 if (deltaPhase < -piDouble) |
199 deltaPhase += twoPiDouble; | 200 deltaPhase += twoPiDouble; |
200 if (deltaPhase > piDouble) | 201 if (deltaPhase > piDouble) |
201 deltaPhase -= twoPiDouble; | 202 deltaPhase -= twoPiDouble; |
202 | 203 |
203 aveSum += mag * deltaPhase; | 204 aveSum += mag * deltaPhase; |
204 weightSum += mag; | 205 weightSum += mag; |
205 } | 206 } |
206 | 207 |
207 // Note how we invert the phase delta wrt frequency since this is how group de
lay is defined | 208 // Note how we invert the phase delta wrt frequency since this is how group |
| 209 // delay is defined |
208 double ave = aveSum / weightSum; | 210 double ave = aveSum / weightSum; |
209 double aveSampleDelay = -ave / samplePhaseDelay; | 211 double aveSampleDelay = -ave / samplePhaseDelay; |
210 | 212 |
211 // Leave 20 sample headroom (for leading edge of impulse) | 213 // Leave 20 sample headroom (for leading edge of impulse) |
212 if (aveSampleDelay > 20.0) | 214 if (aveSampleDelay > 20.0) |
213 aveSampleDelay -= 20.0; | 215 aveSampleDelay -= 20.0; |
214 | 216 |
215 // Remove average group delay (minus 20 samples for headroom) | 217 // Remove average group delay (minus 20 samples for headroom) |
216 addConstantGroupDelay(-aveSampleDelay); | 218 addConstantGroupDelay(-aveSampleDelay); |
217 | 219 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 float imag0 = imagP1[0]; | 263 float imag0 = imagP1[0]; |
262 | 264 |
263 VectorMath::zvmul(realP1, imagP1, realP2, imagP2, realP1, imagP1, halfSize); | 265 VectorMath::zvmul(realP1, imagP1, realP2, imagP2, realP1, imagP1, halfSize); |
264 | 266 |
265 // Multiply the packed DC/nyquist component | 267 // Multiply the packed DC/nyquist component |
266 realP1[0] = real0 * realP2[0]; | 268 realP1[0] = real0 * realP2[0]; |
267 imagP1[0] = imag0 * imagP2[0]; | 269 imagP1[0] = imag0 * imagP2[0]; |
268 } | 270 } |
269 | 271 |
270 } // namespace blink | 272 } // namespace blink |
OLD | NEW |