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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 , m_directMode(directMode) | 51 , m_directMode(directMode) |
52 { | 52 { |
53 ASSERT(impulseResponse); | 53 ASSERT(impulseResponse); |
54 ASSERT(accumulationBuffer); | 54 ASSERT(accumulationBuffer); |
55 | 55 |
56 if (!m_directMode) { | 56 if (!m_directMode) { |
57 m_fftKernel = adoptPtr(new FFTFrame(fftSize)); | 57 m_fftKernel = adoptPtr(new FFTFrame(fftSize)); |
58 m_fftKernel->doPaddedFFT(impulseResponse + stageOffset, stageLength); | 58 m_fftKernel->doPaddedFFT(impulseResponse + stageOffset, stageLength); |
59 m_fftConvolver = adoptPtr(new FFTConvolver(fftSize)); | 59 m_fftConvolver = adoptPtr(new FFTConvolver(fftSize)); |
60 } else { | 60 } else { |
| 61 ASSERT(!stageOffset); |
| 62 ASSERT(stageLength <= fftSize / 2); |
| 63 |
61 m_directKernel = adoptPtr(new AudioFloatArray(fftSize / 2)); | 64 m_directKernel = adoptPtr(new AudioFloatArray(fftSize / 2)); |
62 m_directKernel->copyToRange(impulseResponse + stageOffset, 0, fftSize /
2); | 65 m_directKernel->copyToRange(impulseResponse, 0, stageLength); |
63 m_directConvolver = adoptPtr(new DirectConvolver(renderSliceSize)); | 66 m_directConvolver = adoptPtr(new DirectConvolver(renderSliceSize)); |
64 } | 67 } |
65 m_temporaryBuffer.allocate(renderSliceSize); | 68 m_temporaryBuffer.allocate(renderSliceSize); |
66 | 69 |
67 // The convolution stage at offset stageOffset needs to have a corresponding
delay to cancel out the offset. | 70 // The convolution stage at offset stageOffset needs to have a corresponding
delay to cancel out the offset. |
68 size_t totalDelay = stageOffset + reverbTotalLatency; | 71 size_t totalDelay = stageOffset + reverbTotalLatency; |
69 | 72 |
70 // But, the FFT convolution itself incurs fftSize / 2 latency, so subtract t
his out... | 73 // But, the FFT convolution itself incurs fftSize / 2 latency, so subtract t
his out... |
71 size_t halfSize = fftSize / 2; | 74 size_t halfSize = fftSize / 2; |
72 if (!m_directMode) { | 75 if (!m_directMode) { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 m_directConvolver->reset(); | 176 m_directConvolver->reset(); |
174 m_preDelayBuffer.zero(); | 177 m_preDelayBuffer.zero(); |
175 m_accumulationReadIndex = 0; | 178 m_accumulationReadIndex = 0; |
176 m_inputReadIndex = 0; | 179 m_inputReadIndex = 0; |
177 m_framesProcessed = 0; | 180 m_framesProcessed = 0; |
178 } | 181 } |
179 | 182 |
180 } // namespace WebCore | 183 } // namespace WebCore |
181 | 184 |
182 #endif // ENABLE(WEB_AUDIO) | 185 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |