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

Side by Side Diff: Source/platform/audio/SincResampler.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/platform/audio/FFTFrame.cpp ('k') | Source/platform/audio/UpSampler.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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 double subsampleOffset = static_cast<double>(offsetIndex) / m_numberOfKe rnelOffsets; 112 double subsampleOffset = static_cast<double>(offsetIndex) / m_numberOfKe rnelOffsets;
113 113
114 for (int i = 0; i < n; ++i) { 114 for (int i = 0; i < n; ++i) {
115 // Compute the sinc() with offset. 115 // Compute the sinc() with offset.
116 double s = sincScaleFactor * piDouble * (i - halfSize - subsampleOff set); 116 double s = sincScaleFactor * piDouble * (i - halfSize - subsampleOff set);
117 double sinc = !s ? 1.0 : sin(s) / s; 117 double sinc = !s ? 1.0 : sin(s) / s;
118 sinc *= sincScaleFactor; 118 sinc *= sincScaleFactor;
119 119
120 // Compute Blackman window, matching the offset of the sinc(). 120 // Compute Blackman window, matching the offset of the sinc().
121 double x = (i - subsampleOffset) / n; 121 double x = (i - subsampleOffset) / n;
122 double window = a0 - a1 * cos(2.0 * piDouble * x) + a2 * cos(4.0 * p iDouble * x); 122 double window = a0 - a1 * cos(twoPiDouble * x) + a2 * cos(twoPiDoubl e * 2.0 * x);
123 123
124 // Window the sinc() function and store at the correct offset. 124 // Window the sinc() function and store at the correct offset.
125 m_kernelStorage[i + offsetIndex * m_kernelSize] = sinc * window; 125 m_kernelStorage[i + offsetIndex * m_kernelSize] = sinc * window;
126 } 126 }
127 } 127 }
128 } 128 }
129 129
130 void SincResampler::consumeSource(float* buffer, unsigned numberOfSourceFrames) 130 void SincResampler::consumeSource(float* buffer, unsigned numberOfSourceFrames)
131 { 131 {
132 ASSERT(m_sourceProvider); 132 ASSERT(m_sourceProvider);
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 465
466 // Step (4) 466 // Step (4)
467 // Refresh the buffer with more input. 467 // Refresh the buffer with more input.
468 consumeSource(r5, m_blockSize); 468 consumeSource(r5, m_blockSize);
469 } 469 }
470 } 470 }
471 471
472 } // namespace WebCore 472 } // namespace WebCore
473 473
474 #endif // ENABLE(WEB_AUDIO) 474 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/platform/audio/FFTFrame.cpp ('k') | Source/platform/audio/UpSampler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698