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

Unified Diff: third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp

Issue 1485003002: Make setTarget followed by linear or exponential ramp continuous. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comments. Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/audioparam-setTargetAtTime-continuous-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp b/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp
index 4f120b5bb65cceb6e9da08b792a657024302dbe2..6b95a0aa2217fa972ba26b6e2cd572f396ce305a 100644
--- a/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp
@@ -405,6 +405,19 @@ float AudioParamTimeline::valuesForFrameRangeImpl(
continue;
}
+ ParamEvent::Type nextEventType = nextEvent ? static_cast<ParamEvent::Type>(nextEvent->type()) : ParamEvent::LastType /* unknown */;
hongchan 2016/04/27 21:40:09 Are we okay with the comment style here? I've neve
Raymond Toy 2016/04/27 21:43:15 Don't know. I just basically moved this line up f
Raymond Toy 2016/04/27 22:57:03 It means a nextEventType equal to LastType indicat
+
+ // If the current event is SetTarget and the next event is a LinearRampToValue or
+ // ExponentialRampToValue, special handling is needed. In this case, the linear and
+ // exponential ramp should start at wherever the SetTarget processing has reached.
+ if (event.type() == ParamEvent::SetTarget
+ && (nextEventType == ParamEvent::LinearRampToValue
+ || nextEventType == ParamEvent::ExponentialRampToValue)) {
+ // Replace the SetTarget with a SetValue to set the starting time and value for the ramp
+ // using the current frame and value.
+ m_events[i] = ParamEvent::createSetValueEvent(value, currentFrame / sampleRate);
+ }
+
float value1 = event.value();
double time1 = event.time();
@@ -433,7 +446,6 @@ float AudioParamTimeline::valuesForFrameRangeImpl(
size_t fillToFrame = fillToEndFrame - startFrame;
fillToFrame = std::min(fillToFrame, static_cast<size_t>(numberOfValues));
- ParamEvent::Type nextEventType = nextEvent ? static_cast<ParamEvent::Type>(nextEvent->type()) : ParamEvent::LastType /* unknown */;
// First handle linear and exponential ramps which require looking ahead to the next event.
if (nextEventType == ParamEvent::LinearRampToValue) {
@@ -517,6 +529,10 @@ float AudioParamTimeline::valuesForFrameRangeImpl(
value *= multiplier;
++currentFrame;
}
+ // Due to roundoff it's possible that value exceeds value2. Clip value to value2 if
+ // we are within 1/2 frame of time2.
+ if (currentFrame > time2 * sampleRate - 0.5)
+ value = value2;
}
} else {
// Handle event types not requiring looking ahead to the next event.
« no previous file with comments | « third_party/WebKit/LayoutTests/webaudio/audioparam-setTargetAtTime-continuous-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698