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

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

Issue 511333002: Removing "using" declarations that import names in the C++ Standard library.(Source/platform/audio) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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
(...skipping 18 matching lines...) Expand all
29 #include "platform/audio/EqualPowerPanner.h" 29 #include "platform/audio/EqualPowerPanner.h"
30 30
31 #include <algorithm> 31 #include <algorithm>
32 #include "platform/audio/AudioBus.h" 32 #include "platform/audio/AudioBus.h"
33 #include "platform/audio/AudioUtilities.h" 33 #include "platform/audio/AudioUtilities.h"
34 #include "wtf/MathExtras.h" 34 #include "wtf/MathExtras.h"
35 35
36 // Use a 50ms smoothing / de-zippering time-constant. 36 // Use a 50ms smoothing / de-zippering time-constant.
37 const float SmoothingTimeConstant = 0.050f; 37 const float SmoothingTimeConstant = 0.050f;
38 38
39 using namespace std;
40
41 namespace blink { 39 namespace blink {
42 40
43 EqualPowerPanner::EqualPowerPanner(float sampleRate) 41 EqualPowerPanner::EqualPowerPanner(float sampleRate)
44 : Panner(PanningModelEqualPower) 42 : Panner(PanningModelEqualPower)
45 , m_isFirstRender(true) 43 , m_isFirstRender(true)
46 , m_gainL(0.0) 44 , m_gainL(0.0)
47 , m_gainR(0.0) 45 , m_gainR(0.0)
48 { 46 {
49 m_smoothingConstant = AudioUtilities::discreteTimeConstantForSampleRate(Smoo thingTimeConstant, sampleRate); 47 m_smoothingConstant = AudioUtilities::discreteTimeConstantForSampleRate(Smoo thingTimeConstant, sampleRate);
50 } 48 }
(...skipping 14 matching lines...) Expand all
65 63
66 const float* sourceL = inputBus->channel(0)->data(); 64 const float* sourceL = inputBus->channel(0)->data();
67 const float* sourceR = numberOfInputChannels > 1 ? inputBus->channel(1)->dat a() : sourceL; 65 const float* sourceR = numberOfInputChannels > 1 ? inputBus->channel(1)->dat a() : sourceL;
68 float* destinationL = outputBus->channelByType(AudioBus::ChannelLeft)->mutab leData(); 66 float* destinationL = outputBus->channelByType(AudioBus::ChannelLeft)->mutab leData();
69 float* destinationR = outputBus->channelByType(AudioBus::ChannelRight)->muta bleData(); 67 float* destinationR = outputBus->channelByType(AudioBus::ChannelRight)->muta bleData();
70 68
71 if (!sourceL || !sourceR || !destinationL || !destinationR) 69 if (!sourceL || !sourceR || !destinationL || !destinationR)
72 return; 70 return;
73 71
74 // Clamp azimuth to allowed range of -180 -> +180. 72 // Clamp azimuth to allowed range of -180 -> +180.
75 azimuth = max(-180.0, azimuth); 73 azimuth = std::max(-180.0, azimuth);
76 azimuth = min(180.0, azimuth); 74 azimuth = std::min(180.0, azimuth);
77 75
78 // Alias the azimuth ranges behind us to in front of us: 76 // Alias the azimuth ranges behind us to in front of us:
79 // -90 -> -180 to -90 -> 0 and 90 -> 180 to 90 -> 0 77 // -90 -> -180 to -90 -> 0 and 90 -> 180 to 90 -> 0
80 if (azimuth < -90) 78 if (azimuth < -90)
81 azimuth = -180 - azimuth; 79 azimuth = -180 - azimuth;
82 else if (azimuth > 90) 80 else if (azimuth > 90)
83 azimuth = 180 - azimuth; 81 azimuth = 180 - azimuth;
84 82
85 double desiredPanPosition; 83 double desiredPanPosition;
86 double desiredGainL; 84 double desiredGainL;
87 double desiredGainR; 85 double desiredGainR;
88 86
89 if (numberOfInputChannels == 1) { // For mono source case. 87 if (numberOfInputChannels == 1) { // For mono source case.
90 // Pan smoothly from left to right with azimuth going from -90 -> +90 de grees. 88 // Pan smoothly from left to right with azimuth going from -90 -> +90 de grees.
91 desiredPanPosition = (azimuth + 90) / 180; 89 desiredPanPosition = (azimuth + 90) / 180;
92 } else { // For stereo source case. 90 } else { // For stereo source case.
93 if (azimuth <= 0) { // from -90 -> 0 91 if (azimuth <= 0) { // from -90 -> 0
94 // sourceL -> destL and "equal-power pan" sourceR as in mono case 92 // sourceL -> destL and "equal-power pan" sourceR as in mono case
95 // by transforming the "azimuth" value from -90 -> 0 degrees into th e range -90 -> +90. 93 // by transforming the "azimuth" value from -90 -> 0 degrees into th e range -90 -> +90.
96 desiredPanPosition = (azimuth + 90) / 90; 94 desiredPanPosition = (azimuth + 90) / 90;
97 } else { // from 0 -> +90 95 } else { // from 0 -> +90
98 // sourceR -> destR and "equal-power pan" sourceL as in mono case 96 // sourceR -> destR and "equal-power pan" sourceL as in mono case
99 // by transforming the "azimuth" value from 0 -> +90 degrees into th e range -90 -> +90. 97 // by transforming the "azimuth" value from 0 -> +90 degrees into th e range -90 -> +90.
100 desiredPanPosition = azimuth / 90; 98 desiredPanPosition = azimuth / 90;
101 } 99 }
102 } 100 }
103 101
104 desiredGainL = cos(piOverTwoDouble * desiredPanPosition); 102 desiredGainL = std::cos(piOverTwoDouble * desiredPanPosition);
105 desiredGainR = sin(piOverTwoDouble * desiredPanPosition); 103 desiredGainR = std::sin(piOverTwoDouble * desiredPanPosition);
106 104
107 // Don't de-zipper on first render call. 105 // Don't de-zipper on first render call.
108 if (m_isFirstRender) { 106 if (m_isFirstRender) {
109 m_isFirstRender = false; 107 m_isFirstRender = false;
110 m_gainL = desiredGainL; 108 m_gainL = desiredGainL;
111 m_gainR = desiredGainR; 109 m_gainR = desiredGainR;
112 } 110 }
113 111
114 // Cache in local variables. 112 // Cache in local variables.
115 double gainL = m_gainL; 113 double gainL = m_gainL;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 148 }
151 } 149 }
152 150
153 m_gainL = gainL; 151 m_gainL = gainL;
154 m_gainR = gainR; 152 m_gainR = gainR;
155 } 153 }
156 154
157 } // namespace blink 155 } // namespace blink
158 156
159 #endif // ENABLE(WEB_AUDIO) 157 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/platform/audio/DynamicsCompressorKernel.cpp ('k') | Source/platform/audio/HRTFDatabase.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698