Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: Source/modules/webaudio/RealtimeAnalyser.cpp

Issue 801033003: remove WTF::Complex (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: remove WTF::Complex typedef Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/platform/audio/Biquad.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 13 matching lines...) Expand all
24 24
25 #include "config.h" 25 #include "config.h"
26 26
27 #if ENABLE(WEB_AUDIO) 27 #if ENABLE(WEB_AUDIO)
28 28
29 #include "modules/webaudio/RealtimeAnalyser.h" 29 #include "modules/webaudio/RealtimeAnalyser.h"
30 30
31 #include "platform/audio/AudioBus.h" 31 #include "platform/audio/AudioBus.h"
32 #include "platform/audio/AudioUtilities.h" 32 #include "platform/audio/AudioUtilities.h"
33 #include "platform/audio/VectorMath.h" 33 #include "platform/audio/VectorMath.h"
34 #include "wtf/Complex.h"
35 #include "wtf/MainThread.h" 34 #include "wtf/MainThread.h"
36 #include "wtf/MathExtras.h" 35 #include "wtf/MathExtras.h"
37 #include <algorithm> 36 #include <algorithm>
37 #include <complex>
38 #include <limits.h> 38 #include <limits.h>
39 39
40 namespace blink { 40 namespace blink {
41 41
42 const double RealtimeAnalyser::DefaultSmoothingTimeConstant = 0.8; 42 const double RealtimeAnalyser::DefaultSmoothingTimeConstant = 0.8;
43 const double RealtimeAnalyser::DefaultMinDecibels = -100; 43 const double RealtimeAnalyser::DefaultMinDecibels = -100;
44 const double RealtimeAnalyser::DefaultMaxDecibels = -30; 44 const double RealtimeAnalyser::DefaultMaxDecibels = -30;
45 45
46 const unsigned RealtimeAnalyser::DefaultFFTSize = 2048; 46 const unsigned RealtimeAnalyser::DefaultFFTSize = 2048;
47 // All FFT implementations are expected to handle power-of-two sizes MinFFTSize <= size <= MaxFFTSize. 47 // All FFT implementations are expected to handle power-of-two sizes MinFFTSize <= size <= MaxFFTSize.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 176
177 // A value of 0 does no averaging with the previous result. Larger values p roduce slower, but smoother changes. 177 // A value of 0 does no averaging with the previous result. Larger values p roduce slower, but smoother changes.
178 double k = m_smoothingTimeConstant; 178 double k = m_smoothingTimeConstant;
179 k = std::max(0.0, k); 179 k = std::max(0.0, k);
180 k = std::min(1.0, k); 180 k = std::min(1.0, k);
181 181
182 // Convert the analysis data from complex to magnitude and average with the previous result. 182 // Convert the analysis data from complex to magnitude and average with the previous result.
183 float* destination = magnitudeBuffer().data(); 183 float* destination = magnitudeBuffer().data();
184 size_t n = magnitudeBuffer().size(); 184 size_t n = magnitudeBuffer().size();
185 for (size_t i = 0; i < n; ++i) { 185 for (size_t i = 0; i < n; ++i) {
186 Complex c(realP[i], imagP[i]); 186 std::complex<double> c(realP[i], imagP[i]);
187 double scalarMagnitude = abs(c) * magnitudeScale; 187 double scalarMagnitude = abs(c) * magnitudeScale;
188 destination[i] = float(k * destination[i] + (1 - k) * scalarMagnitude); 188 destination[i] = float(k * destination[i] + (1 - k) * scalarMagnitude);
189 } 189 }
190 } 190 }
191 191
192 void RealtimeAnalyser::getFloatFrequencyData(DOMFloat32Array* destinationArray) 192 void RealtimeAnalyser::getFloatFrequencyData(DOMFloat32Array* destinationArray)
193 { 193 {
194 ASSERT(isMainThread()); 194 ASSERT(isMainThread());
195 195
196 if (!destinationArray) 196 if (!destinationArray)
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 scaledValue = UCHAR_MAX; 314 scaledValue = UCHAR_MAX;
315 315
316 destination[i] = static_cast<unsigned char>(scaledValue); 316 destination[i] = static_cast<unsigned char>(scaledValue);
317 } 317 }
318 } 318 }
319 } 319 }
320 320
321 } // namespace blink 321 } // namespace blink
322 322
323 #endif // ENABLE(WEB_AUDIO) 323 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « no previous file | Source/platform/audio/Biquad.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698