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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AudioParam.cpp

Issue 2000423008: Clamp AudioParam automations to the nominal range. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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 * 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 NOTREACHED(); 141 NOTREACHED();
142 return "UnknownNode.unknownAudioParam"; 142 return "UnknownNode.unknownAudioParam";
143 } 143 }
144 144
145 float AudioParamHandler::value() 145 float AudioParamHandler::value()
146 { 146 {
147 // Update value for timeline. 147 // Update value for timeline.
148 float v = intrinsicValue(); 148 float v = intrinsicValue();
149 if (deferredTaskHandler().isAudioThread()) { 149 if (deferredTaskHandler().isAudioThread()) {
150 bool hasValue; 150 bool hasValue;
151 float timelineValue = m_timeline.valueForContextTime(destinationHandler( ), v, hasValue); 151 float timelineValue = m_timeline.valueForContextTime(destinationHandler( ), v, hasValue, minValue(), maxValue());
152 152
153 if (hasValue) 153 if (hasValue)
154 v = timelineValue; 154 v = timelineValue;
155 } 155 }
156 156
157 setIntrinsicValue(v); 157 setIntrinsicValue(v);
158 return v; 158 return v;
159 } 159 }
160 160
161 void AudioParamHandler::setIntrinsicValue(float newValue) 161 void AudioParamHandler::setIntrinsicValue(float newValue)
(...skipping 11 matching lines...) Expand all
173 float AudioParamHandler::smoothedValue() 173 float AudioParamHandler::smoothedValue()
174 { 174 {
175 return m_smoothedValue; 175 return m_smoothedValue;
176 } 176 }
177 177
178 bool AudioParamHandler::smooth() 178 bool AudioParamHandler::smooth()
179 { 179 {
180 // If values have been explicitly scheduled on the timeline, then use the ex act value. 180 // If values have been explicitly scheduled on the timeline, then use the ex act value.
181 // Smoothing effectively is performed by the timeline. 181 // Smoothing effectively is performed by the timeline.
182 bool useTimelineValue = false; 182 bool useTimelineValue = false;
183 float value = m_timeline.valueForContextTime(destinationHandler(), intrinsic Value(), useTimelineValue); 183 float value = m_timeline.valueForContextTime(destinationHandler(), intrinsic Value(), useTimelineValue, minValue(), maxValue());
184 184
185 if (m_smoothedValue == value) { 185 if (m_smoothedValue == value) {
186 // Smoothed value has already approached and snapped to value. 186 // Smoothed value has already approached and snapped to value.
187 setIntrinsicValue(value); 187 setIntrinsicValue(value);
188 return true; 188 return true;
189 } 189 }
190 190
191 if (useTimelineValue) { 191 if (useTimelineValue) {
192 m_smoothedValue = value; 192 m_smoothedValue = value;
193 } else { 193 } else {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 231
232 // The calculated result will be the "intrinsic" value summed with all audio -rate connections. 232 // The calculated result will be the "intrinsic" value summed with all audio -rate connections.
233 233
234 if (sampleAccurate) { 234 if (sampleAccurate) {
235 // Calculate sample-accurate (a-rate) intrinsic values. 235 // Calculate sample-accurate (a-rate) intrinsic values.
236 calculateTimelineValues(values, numberOfValues); 236 calculateTimelineValues(values, numberOfValues);
237 } else { 237 } else {
238 // Calculate control-rate (k-rate) intrinsic value. 238 // Calculate control-rate (k-rate) intrinsic value.
239 bool hasValue; 239 bool hasValue;
240 float value = intrinsicValue(); 240 float value = intrinsicValue();
241 float timelineValue = m_timeline.valueForContextTime(destinationHandler( ), value, hasValue); 241 float timelineValue = m_timeline.valueForContextTime(destinationHandler( ), value, hasValue, minValue(), maxValue());
242 242
243 if (hasValue) 243 if (hasValue)
244 value = timelineValue; 244 value = timelineValue;
245 245
246 values[0] = value; 246 values[0] = value;
247 setIntrinsicValue(value); 247 setIntrinsicValue(value);
248 } 248 }
249 249
250 // Now sum all of the audio-rate connections together (unity-gain summing ju nction). 250 // Now sum all of the audio-rate connections together (unity-gain summing ju nction).
251 // Note that connections would normally be mono, but we mix down to mono if necessary. 251 // Note that connections would normally be mono, but we mix down to mono if necessary.
(...skipping 15 matching lines...) Expand all
267 void AudioParamHandler::calculateTimelineValues(float* values, unsigned numberOf Values) 267 void AudioParamHandler::calculateTimelineValues(float* values, unsigned numberOf Values)
268 { 268 {
269 // Calculate values for this render quantum. Normally numberOfValues will 269 // Calculate values for this render quantum. Normally numberOfValues will
270 // equal to AudioHandler::ProcessingSizeInFrames (the render quantum size). 270 // equal to AudioHandler::ProcessingSizeInFrames (the render quantum size).
271 double sampleRate = destinationHandler().sampleRate(); 271 double sampleRate = destinationHandler().sampleRate();
272 size_t startFrame = destinationHandler().currentSampleFrame(); 272 size_t startFrame = destinationHandler().currentSampleFrame();
273 size_t endFrame = startFrame + numberOfValues; 273 size_t endFrame = startFrame + numberOfValues;
274 274
275 // Note we're running control rate at the sample-rate. 275 // Note we're running control rate at the sample-rate.
276 // Pass in the current value as default value. 276 // Pass in the current value as default value.
277 setIntrinsicValue(m_timeline.valuesForFrameRange(startFrame, endFrame, intri nsicValue(), values, numberOfValues, sampleRate, sampleRate)); 277 setIntrinsicValue(m_timeline.valuesForFrameRange(startFrame, endFrame, intri nsicValue(), values, numberOfValues, sampleRate, sampleRate, minValue(), maxValu e()));
278 } 278 }
279 279
280 void AudioParamHandler::connect(AudioNodeOutput& output) 280 void AudioParamHandler::connect(AudioNodeOutput& output)
281 { 281 {
282 ASSERT(deferredTaskHandler().isGraphOwner()); 282 ASSERT(deferredTaskHandler().isGraphOwner());
283 283
284 if (m_outputs.contains(&output)) 284 if (m_outputs.contains(&output))
285 return; 285 return;
286 286
287 output.addParam(*this); 287 output.addParam(*this);
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 } 496 }
497 497
498 AudioParam* AudioParam::cancelScheduledValues(double startTime, ExceptionState& exceptionState) 498 AudioParam* AudioParam::cancelScheduledValues(double startTime, ExceptionState& exceptionState)
499 { 499 {
500 handler().timeline().cancelScheduledValues(startTime, exceptionState); 500 handler().timeline().cancelScheduledValues(startTime, exceptionState);
501 return this; 501 return this;
502 } 502 }
503 503
504 } // namespace blink 504 } // namespace blink
505 505
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698