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

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

Issue 1928163002: Add a name attribute for each AudioParam (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use enum instead of string Created 4 years, 7 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 22 matching lines...) Expand all
33 namespace blink { 33 namespace blink {
34 34
35 const double AudioParamHandler::DefaultSmoothingConstant = 0.05; 35 const double AudioParamHandler::DefaultSmoothingConstant = 0.05;
36 const double AudioParamHandler::SnapThreshold = 0.001; 36 const double AudioParamHandler::SnapThreshold = 0.001;
37 37
38 AudioDestinationHandler& AudioParamHandler::destinationHandler() const 38 AudioDestinationHandler& AudioParamHandler::destinationHandler() const
39 { 39 {
40 return *m_destinationHandler; 40 return *m_destinationHandler;
41 } 41 }
42 42
43 String AudioParamHandler::getParamName() const
44 {
45 // The returned string should be the name of the node and the name of the Au dioParam for
46 // that node.
47 switch (m_paramType) {
48 case AudioBufferSourcePlaybackRate:
49 return "AudioBufferSource.playbackrate";
50 case AudioBufferSourceDetune:
51 return "AudioBufferSource.detune";
52 case BiquadFilterFrequency:
53 return "BiquadFilter.frequency";
54 case BiquadFilterQ:
55 return "BiquadFilter.Q";
56 case BiquadFilterGain:
57 return "BiquadFilter.gain";
58 case BiquadFilterDetune:
59 return "BiquadFilter.detune";
60 case DelayDelayTime:
61 return "Delay.delayTime";
62 case DynamicsCompressorThreshold:
63 return "DynamicsCompressor.threshold";
64 case DynamicsCompressorKnee:
65 return "DynamicsCompressor.knee";
66 case DynamicsCompressorRatio:
67 return "DynamicsCompressor.ratio";
68 case DynamicsCompressorAttack:
69 return "DynamicsCompressor.attack";
70 case DynamicsCompressorRelease:
71 return "DynamicsCompressor.release";
72 case GainGain:
73 return "Gain.gain";
74 case OscillatorFrequency:
75 return "Oscillator.frequency";
76 case OscillatorDetune:
77 return "Oscillator.detune";
78 case StereoPannerPan:
79 return "StereoPanner.pan";
80 };
81 }
82
43 float AudioParamHandler::value() 83 float AudioParamHandler::value()
44 { 84 {
45 // Update value for timeline. 85 // Update value for timeline.
46 float v = intrinsicValue(); 86 float v = intrinsicValue();
47 if (deferredTaskHandler().isAudioThread()) { 87 if (deferredTaskHandler().isAudioThread()) {
48 bool hasValue; 88 bool hasValue;
49 float timelineValue = m_timeline.valueForContextTime(destinationHandler( ), v, hasValue); 89 float timelineValue = m_timeline.valueForContextTime(destinationHandler( ), v, hasValue);
50 90
51 if (hasValue) 91 if (hasValue)
52 v = timelineValue; 92 v = timelineValue;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 226
187 if (m_outputs.contains(&output)) { 227 if (m_outputs.contains(&output)) {
188 m_outputs.remove(&output); 228 m_outputs.remove(&output);
189 changedOutputs(); 229 changedOutputs();
190 output.removeParam(*this); 230 output.removeParam(*this);
191 } 231 }
192 } 232 }
193 233
194 // ---------------------------------------------------------------- 234 // ----------------------------------------------------------------
195 235
196 AudioParam::AudioParam(AbstractAudioContext& context, double defaultValue) 236 AudioParam::AudioParam(AbstractAudioContext& context, AudioParamHandler::ParamTy pe paramType, double defaultValue)
197 : m_handler(AudioParamHandler::create(context, defaultValue)) 237 : m_handler(AudioParamHandler::create(context, paramType, defaultValue))
198 , m_context(context) 238 , m_context(context)
199 { 239 {
200 } 240 }
201 241
202 AudioParam* AudioParam::create(AbstractAudioContext& context, double defaultValu e) 242 AudioParam* AudioParam::create(AbstractAudioContext& context, AudioParamHandler: :ParamType paramType, double defaultValue)
203 { 243 {
204 return new AudioParam(context, defaultValue); 244 return new AudioParam(context, paramType, defaultValue);
205 } 245 }
206 246
207 DEFINE_TRACE(AudioParam) 247 DEFINE_TRACE(AudioParam)
208 { 248 {
209 visitor->trace(m_context); 249 visitor->trace(m_context);
210 } 250 }
211 251
212 float AudioParam::value() const 252 float AudioParam::value() const
213 { 253 {
214 return handler().value(); 254 return handler().value();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 } 296 }
257 297
258 AudioParam* AudioParam::cancelScheduledValues(double startTime, ExceptionState& exceptionState) 298 AudioParam* AudioParam::cancelScheduledValues(double startTime, ExceptionState& exceptionState)
259 { 299 {
260 handler().timeline().cancelScheduledValues(startTime, exceptionState); 300 handler().timeline().cancelScheduledValues(startTime, exceptionState);
261 return this; 301 return this;
262 } 302 }
263 303
264 } // namespace blink 304 } // namespace blink
265 305
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698