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

Side by Side Diff: third_party/WebKit/Source/platform/audio/EqualPowerPanner.cpp

Issue 2384073002: reflow comments in platform/audio (Closed)
Patch Set: comments (heh!) Created 4 years, 2 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
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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y 16 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N 19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
23 * DAMAGE.
23 */ 24 */
24 25
25 #include "platform/audio/EqualPowerPanner.h" 26 #include "platform/audio/EqualPowerPanner.h"
26 #include "platform/audio/AudioBus.h" 27 #include "platform/audio/AudioBus.h"
27 #include "platform/audio/AudioUtilities.h" 28 #include "platform/audio/AudioUtilities.h"
28 #include "wtf/MathExtras.h" 29 #include "wtf/MathExtras.h"
29 #include <algorithm> 30 #include <algorithm>
30 #include <cmath> 31 #include <cmath>
31 32
32 namespace blink { 33 namespace blink {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 if (azimuth < -90) 75 if (azimuth < -90)
75 azimuth = -180 - azimuth; 76 azimuth = -180 - azimuth;
76 else if (azimuth > 90) 77 else if (azimuth > 90)
77 azimuth = 180 - azimuth; 78 azimuth = 180 - azimuth;
78 79
79 double desiredPanPosition; 80 double desiredPanPosition;
80 double desiredGainL; 81 double desiredGainL;
81 double desiredGainR; 82 double desiredGainR;
82 83
83 if (numberOfInputChannels == 1) { // For mono source case. 84 if (numberOfInputChannels == 1) { // For mono source case.
84 // Pan smoothly from left to right with azimuth going from -90 -> +90 degree s. 85 // Pan smoothly from left to right with azimuth going from -90 -> +90
86 // degrees.
85 desiredPanPosition = (azimuth + 90) / 180; 87 desiredPanPosition = (azimuth + 90) / 180;
86 } else { // For stereo source case. 88 } else { // For stereo source case.
87 if (azimuth <= 0) { // from -90 -> 0 89 if (azimuth <= 0) { // from -90 -> 0
88 // sourceL -> destL and "equal-power pan" sourceR as in mono case 90 // sourceL -> destL and "equal-power pan" sourceR as in mono case
89 // by transforming the "azimuth" value from -90 -> 0 degrees into the rang e -90 -> +90. 91 // by transforming the "azimuth" value from -90 -> 0 degrees into the
92 // range -90 -> +90.
90 desiredPanPosition = (azimuth + 90) / 90; 93 desiredPanPosition = (azimuth + 90) / 90;
91 } else { // from 0 -> +90 94 } else { // from 0 -> +90
92 // sourceR -> destR and "equal-power pan" sourceL as in mono case 95 // sourceR -> destR and "equal-power pan" sourceL as in mono case
93 // by transforming the "azimuth" value from 0 -> +90 degrees into the rang e -90 -> +90. 96 // by transforming the "azimuth" value from 0 -> +90 degrees into the
97 // range -90 -> +90.
94 desiredPanPosition = azimuth / 90; 98 desiredPanPosition = azimuth / 90;
95 } 99 }
96 } 100 }
97 101
98 desiredGainL = std::cos(piOverTwoDouble * desiredPanPosition); 102 desiredGainL = std::cos(piOverTwoDouble * desiredPanPosition);
99 desiredGainR = std::sin(piOverTwoDouble * desiredPanPosition); 103 desiredGainR = std::sin(piOverTwoDouble * desiredPanPosition);
100 104
101 int n = framesToProcess; 105 int n = framesToProcess;
102 106
103 if (numberOfInputChannels == 1) { // For mono source case. 107 if (numberOfInputChannels == 1) { // For mono source case.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // Alias the azimuth ranges behind us to in front of us: 142 // Alias the azimuth ranges behind us to in front of us:
139 // -90 -> -180 to -90 -> 0 and 90 -> 180 to 90 -> 0 143 // -90 -> -180 to -90 -> 0 and 90 -> 180 to 90 -> 0
140 if (azimuth < -90) 144 if (azimuth < -90)
141 azimuth = -180 - azimuth; 145 azimuth = -180 - azimuth;
142 else if (azimuth > 90) 146 else if (azimuth > 90)
143 azimuth = 180 - azimuth; 147 azimuth = 180 - azimuth;
144 148
145 double desiredPanPosition; 149 double desiredPanPosition;
146 150
147 if (numberOfInputChannels == 1) { // For mono source case. 151 if (numberOfInputChannels == 1) { // For mono source case.
148 // Pan smoothly from left to right with azimuth going from -90 -> +90 degree s. 152 // Pan smoothly from left to right with azimuth going from -90 -> +90
153 // degrees.
149 desiredPanPosition = (azimuth + 90) / 180; 154 desiredPanPosition = (azimuth + 90) / 180;
150 } else { // For stereo source case. 155 } else { // For stereo source case.
151 if (azimuth <= 0) { // from -90 -> 0 156 if (azimuth <= 0) { // from -90 -> 0
152 // sourceL -> destL and "equal-power pan" sourceR as in mono case 157 // sourceL -> destL and "equal-power pan" sourceR as in mono case
153 // by transforming the "azimuth" value from -90 -> 0 degrees into the rang e -90 -> +90. 158 // by transforming the "azimuth" value from -90 -> 0 degrees into the
159 // range -90 -> +90.
154 desiredPanPosition = (azimuth + 90) / 90; 160 desiredPanPosition = (azimuth + 90) / 90;
155 } else { // from 0 -> +90 161 } else { // from 0 -> +90
156 // sourceR -> destR and "equal-power pan" sourceL as in mono case 162 // sourceR -> destR and "equal-power pan" sourceL as in mono case
157 // by transforming the "azimuth" value from 0 -> +90 degrees into the rang e -90 -> +90. 163 // by transforming the "azimuth" value from 0 -> +90 degrees into the
164 // range -90 -> +90.
158 desiredPanPosition = azimuth / 90; 165 desiredPanPosition = azimuth / 90;
159 } 166 }
160 } 167 }
161 168
162 desiredGainL = std::cos(piOverTwoDouble * desiredPanPosition); 169 desiredGainL = std::cos(piOverTwoDouble * desiredPanPosition);
163 desiredGainR = std::sin(piOverTwoDouble * desiredPanPosition); 170 desiredGainR = std::sin(piOverTwoDouble * desiredPanPosition);
164 } 171 }
165 172
166 void EqualPowerPanner::panWithSampleAccurateValues( 173 void EqualPowerPanner::panWithSampleAccurateValues(
167 double* azimuth, 174 double* azimuth,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 float inputL = *sourceL++; 232 float inputL = *sourceL++;
226 float inputR = *sourceR++; 233 float inputR = *sourceR++;
227 *destinationL++ = static_cast<float>(inputL * desiredGainL); 234 *destinationL++ = static_cast<float>(inputL * desiredGainL);
228 *destinationR++ = static_cast<float>(inputR + inputL * desiredGainR); 235 *destinationR++ = static_cast<float>(inputR + inputL * desiredGainR);
229 } 236 }
230 } 237 }
231 } 238 }
232 } 239 }
233 240
234 } // namespace blink 241 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/audio/EqualPowerPanner.h ('k') | third_party/WebKit/Source/platform/audio/FFTConvolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698