Changeset 94029 in webkit
- Timestamp:
- Aug 29, 2011, 4:35:40 PM (15 years ago)
- Location:
- branches/chromium/835/Source/WebCore/webaudio
- Files:
-
- 2 edited
-
RealtimeAnalyser.cpp (modified) (5 diffs)
-
RealtimeAnalyser.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/chromium/835/Source/WebCore/webaudio/RealtimeAnalyser.cpp
r93810 r94029 50 50 51 51 const unsigned RealtimeAnalyser::DefaultFFTSize = 2048; 52 // All FFT implementations are expected to handle power-of-two sizes MinFFTSize <= size <= MaxFFTSize. 53 const unsigned RealtimeAnalyser::MinFFTSize = 128; 52 54 const unsigned RealtimeAnalyser::MaxFFTSize = 2048; 53 55 const unsigned RealtimeAnalyser::InputBufferSize = RealtimeAnalyser::MaxFFTSize * 2; … … 83 85 unsigned log2size = static_cast<unsigned>(log2(size)); 84 86 bool isPOT(1UL << log2size == size); 85 86 if (!isPOT || size > MaxFFTSize ) {87 88 if (!isPOT || size > MaxFFTSize || size < MinFFTSize) { 87 89 // FIXME: It would be good to also set an exception. 88 90 return; … … 90 92 91 93 if (m_fftSize != size) { 92 m_analysisFrame = adoptPtr(new FFTFrame(m_fftSize)); 93 m_magnitudeBuffer.allocate(size); 94 m_analysisFrame = adoptPtr(new FFTFrame(size)); 95 // m_magnitudeBuffer has size = fftSize / 2 because it contains floats reduced from complex values in m_analysisFrame. 96 m_magnitudeBuffer.allocate(size / 2); 94 97 m_fftSize = size; 95 98 } … … 166 169 m_analysisFrame->doFFT(tempP); 167 170 168 size_t n = DefaultFFTSize / 2;169 170 171 float* realP = m_analysisFrame->realData(); 171 172 float* imagP = m_analysisFrame->imagData(); … … 184 185 // Convert the analysis data from complex to magnitude and average with the previous result. 185 186 float* destination = magnitudeBuffer().data(); 186 for (unsigned i = 0; i < n; ++i) { 187 size_t n = magnitudeBuffer().size(); 188 for (size_t i = 0; i < n; ++i) { 187 189 Complex c(realP[i], imagP[i]); 188 190 double scalarMagnitude = abs(c) * MagnitudeScale; -
branches/chromium/835/Source/WebCore/webaudio/RealtimeAnalyser.h
r87173 r94029 71 71 72 72 static const unsigned DefaultFFTSize; 73 static const unsigned MinFFTSize; 73 74 static const unsigned MaxFFTSize; 74 75 static const unsigned InputBufferSize;
Note:
See TracChangeset
for help on using the changeset viewer.