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

Side by Side Diff: Source/platform/audio/UpSampler.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/SincResampler.cpp ('k') | Source/platform/graphics/Path.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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 int halfSize = n / 2; 60 int halfSize = n / 2;
61 double subsampleOffset = -0.5; 61 double subsampleOffset = -0.5;
62 62
63 for (int i = 0; i < n; ++i) { 63 for (int i = 0; i < n; ++i) {
64 // Compute the sinc() with offset. 64 // Compute the sinc() with offset.
65 double s = piDouble * (i - halfSize - subsampleOffset); 65 double s = piDouble * (i - halfSize - subsampleOffset);
66 double sinc = !s ? 1.0 : sin(s) / s; 66 double sinc = !s ? 1.0 : sin(s) / s;
67 67
68 // Compute Blackman window, matching the offset of the sinc(). 68 // Compute Blackman window, matching the offset of the sinc().
69 double x = (i - subsampleOffset) / n; 69 double x = (i - subsampleOffset) / n;
70 double window = a0 - a1 * cos(2.0 * piDouble * x) + a2 * cos(4.0 * piDou ble * x); 70 double window = a0 - a1 * cos(twoPiDouble * x) + a2 * cos(twoPiDouble * 2.0 * x);
71 71
72 // Window the sinc() function. 72 // Window the sinc() function.
73 m_kernel[i] = sinc * window; 73 m_kernel[i] = sinc * window;
74 } 74 }
75 } 75 }
76 76
77 void UpSampler::process(const float* sourceP, float* destP, size_t sourceFramesT oProcess) 77 void UpSampler::process(const float* sourceP, float* destP, size_t sourceFramesT oProcess)
78 { 78 {
79 bool isInputBlockSizeGood = sourceFramesToProcess == m_inputBlockSize; 79 bool isInputBlockSizeGood = sourceFramesToProcess == m_inputBlockSize;
80 ASSERT(isInputBlockSizeGood); 80 ASSERT(isInputBlockSizeGood);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 size_t UpSampler::latencyFrames() const 126 size_t UpSampler::latencyFrames() const
127 { 127 {
128 // Divide by two since this is a linear phase kernel and the delay is at the center of the kernel. 128 // Divide by two since this is a linear phase kernel and the delay is at the center of the kernel.
129 return m_kernel.size() / 2; 129 return m_kernel.size() / 2;
130 } 130 }
131 131
132 } // namespace WebCore 132 } // namespace WebCore
133 133
134 #endif // ENABLE(WEB_AUDIO) 134 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/platform/audio/SincResampler.cpp ('k') | Source/platform/graphics/Path.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698