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

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

Issue 2170973002: HRTF panner should handle the case of no loaded HRTF database (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment. Created 4 years, 5 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 <algorithm> 29 #include <algorithm>
30 #include <cmath> 30 #include <cmath>
31 31
32 namespace blink { 32 namespace blink {
33 33
34 EqualPowerPanner::EqualPowerPanner(float sampleRate) 34 EqualPowerPanner::EqualPowerPanner(float sampleRate)
35 : Panner(PanningModelEqualPower) 35 : Panner(PanningModelEqualPower)
36 { 36 {
37 } 37 }
38 38
39 void EqualPowerPanner::pan(double azimuth, double /*elevation*/, const AudioBus* inputBus, AudioBus* outputBus, size_t framesToProcess) 39 void EqualPowerPanner::pan(double azimuth, double /*elevation*/, const AudioBus* inputBus, AudioBus* outputBus, size_t framesToProcess, AudioBus::ChannelInterpr etation)
40 { 40 {
41 bool isInputSafe = inputBus && (inputBus->numberOfChannels() == 1 || inputBu s->numberOfChannels() == 2) && framesToProcess <= inputBus->length(); 41 bool isInputSafe = inputBus && (inputBus->numberOfChannels() == 1 || inputBu s->numberOfChannels() == 2) && framesToProcess <= inputBus->length();
42 ASSERT(isInputSafe); 42 ASSERT(isInputSafe);
43 if (!isInputSafe) 43 if (!isInputSafe)
44 return; 44 return;
45 45
46 unsigned numberOfInputChannels = inputBus->numberOfChannels(); 46 unsigned numberOfInputChannels = inputBus->numberOfChannels();
47 47
48 bool isOutputSafe = outputBus && outputBus->numberOfChannels() == 2 && frame sToProcess <= outputBus->length(); 48 bool isOutputSafe = outputBus && outputBus->numberOfChannels() == 2 && frame sToProcess <= outputBus->length();
49 ASSERT(isOutputSafe); 49 ASSERT(isOutputSafe);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // sourceR -> destR and "equal-power pan" sourceL as in mono case 146 // sourceR -> destR and "equal-power pan" sourceL as in mono case
147 // by transforming the "azimuth" value from 0 -> +90 degrees into th e range -90 -> +90. 147 // by transforming the "azimuth" value from 0 -> +90 degrees into th e range -90 -> +90.
148 desiredPanPosition = azimuth / 90; 148 desiredPanPosition = azimuth / 90;
149 } 149 }
150 } 150 }
151 151
152 desiredGainL = std::cos(piOverTwoDouble * desiredPanPosition); 152 desiredGainL = std::cos(piOverTwoDouble * desiredPanPosition);
153 desiredGainR = std::sin(piOverTwoDouble * desiredPanPosition); 153 desiredGainR = std::sin(piOverTwoDouble * desiredPanPosition);
154 } 154 }
155 155
156 void EqualPowerPanner::panWithSampleAccurateValues(double* azimuth, double* /*el evation*/, const AudioBus* inputBus, AudioBus* outputBus, size_t framesToProcess ) 156 void EqualPowerPanner::panWithSampleAccurateValues(double* azimuth, double* /*el evation*/, const AudioBus* inputBus, AudioBus* outputBus, size_t framesToProcess , AudioBus::ChannelInterpretation)
157 { 157 {
158 bool isInputSafe = inputBus && (inputBus->numberOfChannels() == 1 || inputBu s->numberOfChannels() == 2) && framesToProcess <= inputBus->length(); 158 bool isInputSafe = inputBus && (inputBus->numberOfChannels() == 1 || inputBu s->numberOfChannels() == 2) && framesToProcess <= inputBus->length();
159 DCHECK(isInputSafe); 159 DCHECK(isInputSafe);
160 if (!isInputSafe) 160 if (!isInputSafe)
161 return; 161 return;
162 162
163 unsigned numberOfInputChannels = inputBus->numberOfChannels(); 163 unsigned numberOfInputChannels = inputBus->numberOfChannels();
164 164
165 bool isOutputSafe = outputBus && outputBus->numberOfChannels() == 2 && frame sToProcess <= outputBus->length(); 165 bool isOutputSafe = outputBus && outputBus->numberOfChannels() == 2 && frame sToProcess <= outputBus->length();
166 DCHECK(isOutputSafe); 166 DCHECK(isOutputSafe);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 float inputR = *sourceR++; 203 float inputR = *sourceR++;
204 *destinationL++ = static_cast<float>(inputL * desiredGainL); 204 *destinationL++ = static_cast<float>(inputL * desiredGainL);
205 *destinationR++ = static_cast<float>(inputR + inputL * desiredGa inR); 205 *destinationR++ = static_cast<float>(inputR + inputL * desiredGa inR);
206 } 206 }
207 } 207 }
208 } 208 }
209 } 209 }
210 210
211 } // namespace blink 211 } // namespace blink
212 212
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/audio/EqualPowerPanner.h ('k') | third_party/WebKit/Source/platform/audio/HRTFPanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698