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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.h

Issue 2391893005: Implement clamping of AudioParam time. (Closed)
Patch Set: Address review comments 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 static ParamEvent createSetTargetEvent(float value, 120 static ParamEvent createSetTargetEvent(float value,
121 double time, 121 double time,
122 double timeConstant); 122 double timeConstant);
123 static ParamEvent createSetValueCurveEvent(const DOMFloat32Array* curve, 123 static ParamEvent createSetValueCurveEvent(const DOMFloat32Array* curve,
124 double time, 124 double time,
125 double duration); 125 double duration);
126 126
127 Type getType() const { return m_type; } 127 Type getType() const { return m_type; }
128 float value() const { return m_value; } 128 float value() const { return m_value; }
129 double time() const { return m_time; } 129 double time() const { return m_time; }
130 void setTime(double newTime) { m_time = newTime; }
130 double timeConstant() const { return m_timeConstant; } 131 double timeConstant() const { return m_timeConstant; }
131 double duration() const { return m_duration; } 132 double duration() const { return m_duration; }
132 Vector<float>& curve() { return m_curve; } 133 Vector<float>& curve() { return m_curve; }
133 float initialValue() const { return m_initialValue; } 134 float initialValue() const { return m_initialValue; }
134 double callTime() const { return m_callTime; } 135 double callTime() const { return m_callTime; }
136 bool needsTimeClampCheck() const { return m_needsTimeClampCheck; }
137 void clearTimeClampCheck() { m_needsTimeClampCheck = false; }
135 138
136 private: 139 private:
137 ParamEvent(Type type, 140 ParamEvent(Type type,
138 float value, 141 float value,
139 double time, 142 double time,
140 double timeConstant, 143 double timeConstant,
141 double duration, 144 double duration,
142 const DOMFloat32Array* curve, 145 const DOMFloat32Array* curve,
143 float initialValue = 0, 146 float initialValue = 0,
144 double callTime = 0); 147 double callTime = 0);
145 148
146 Type m_type; 149 Type m_type;
147 float m_value; 150 float m_value;
148 double m_time; 151 double m_time;
149 // Only used for SetTarget events 152 // Only used for SetTarget events
150 double m_timeConstant; 153 double m_timeConstant;
151 // Only used for SetValueCurve events. 154 // Only used for SetValueCurve events.
152 double m_duration; 155 double m_duration;
153 Vector<float> m_curve; 156 Vector<float> m_curve;
154 // Initial value and time to use for linear and exponential ramps that don't 157 // Initial value and time to use for linear and exponential ramps that don't
155 // have a preceding event. 158 // have a preceding event.
156 float m_initialValue; 159 float m_initialValue;
157 double m_callTime; 160 double m_callTime;
161 // True if the start time needs to be checked against current time
162 // to implement clamping.
163 bool m_needsTimeClampCheck;
158 }; 164 };
159 165
160 void insertEvent(const ParamEvent&, ExceptionState&); 166 void insertEvent(const ParamEvent&, ExceptionState&);
161 float valuesForFrameRangeImpl(size_t startFrame, 167 float valuesForFrameRangeImpl(size_t startFrame,
162 size_t endFrame, 168 size_t endFrame,
163 float defaultValue, 169 float defaultValue,
164 float* values, 170 float* values,
165 unsigned numberOfValues, 171 unsigned numberOfValues,
166 double sampleRate, 172 double sampleRate,
167 double controlRate); 173 double controlRate);
168 174
169 // Produce a nice string describing the event in human-readable form. 175 // Produce a nice string describing the event in human-readable form.
170 String eventToString(const ParamEvent&); 176 String eventToString(const ParamEvent&);
171 Vector<ParamEvent> m_events; 177 Vector<ParamEvent> m_events;
172 178
173 mutable Mutex m_eventsLock; 179 mutable Mutex m_eventsLock;
174 180
175 // Smoothing (de-zippering) 181 // Smoothing (de-zippering)
176 float m_smoothedValue; 182 float m_smoothedValue;
177 }; 183 };
178 184
179 } // namespace blink 185 } // namespace blink
180 186
181 #endif // AudioParamTimeline_h 187 #endif // AudioParamTimeline_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698