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

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

Issue 170453004: Add constant twoPiDouble/twoPiFloat to MathExtras.h (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add constant values to header Created 6 years, 10 months 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 | « Source/core/svg/SVGPathParser.cpp ('k') | Source/platform/audio/DownSampler.cpp » ('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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 ASSERT(isMainThread()); 131 ASSERT(isMainThread());
132 132
133 // Blackman window 133 // Blackman window
134 double alpha = 0.16; 134 double alpha = 0.16;
135 double a0 = 0.5 * (1 - alpha); 135 double a0 = 0.5 * (1 - alpha);
136 double a1 = 0.5; 136 double a1 = 0.5;
137 double a2 = 0.5 * alpha; 137 double a2 = 0.5 * alpha;
138 138
139 for (unsigned i = 0; i < n; ++i) { 139 for (unsigned i = 0; i < n; ++i) {
140 double x = static_cast<double>(i) / static_cast<double>(n); 140 double x = static_cast<double>(i) / static_cast<double>(n);
141 double window = a0 - a1 * cos(2 * piDouble * x) + a2 * cos(4 * piDouble * x); 141 double window = a0 - a1 * cos(twoPiDouble * x) + a2 * cos(twoPiDouble * 2.0 * x);
142 p[i] *= float(window); 142 p[i] *= float(window);
143 } 143 }
144 } 144 }
145 145
146 } // namespace 146 } // namespace
147 147
148 void RealtimeAnalyser::doFFTAnalysis() 148 void RealtimeAnalyser::doFFTAnalysis()
149 { 149 {
150 ASSERT(isMainThread()); 150 ASSERT(isMainThread());
151 151
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 scaledValue = UCHAR_MAX; 291 scaledValue = UCHAR_MAX;
292 292
293 destination[i] = static_cast<unsigned char>(scaledValue); 293 destination[i] = static_cast<unsigned char>(scaledValue);
294 } 294 }
295 } 295 }
296 } 296 }
297 297
298 } // namespace WebCore 298 } // namespace WebCore
299 299
300 #endif // ENABLE(WEB_AUDIO) 300 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/core/svg/SVGPathParser.cpp ('k') | Source/platform/audio/DownSampler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698