Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplemented SetValueCurveAtTime #230
Conversation
|
Hi, We have finished implementing the SetValueCurveAtTime function (https://github.com/JHBalaji/media-1/blob/master/audio/param.rs#L418-L436) and written an example (https://github.com/JHBalaji/media-1/blob/master/examples/set_value_curve.rs) to check the functioning of the same. |
|
Please run |
| let dest = context.dest_node(); | ||
|
|
||
| //Initializing the values vector for SetValueCurve function | ||
| let mut values: Vec<f32> = Vec::new(); |
This comment has been minimized.
This comment has been minimized.
| @@ -324,6 +329,7 @@ impl AutomationEvent { | |||
| match *self { | |||
| AutomationEvent::SetValueAtTime(_, tick) => Some(tick), | |||
| AutomationEvent::RampToValueAtTime(_, _, tick) => Some(tick), | |||
| AutomationEvent::SetValueCurveAtTime(_, _, tick) => Some(tick), | |||
This comment has been minimized.
This comment has been minimized.
| /// https://webaudio.github.io/web-audio-api/#dfn-automation-event | ||
| pub(crate) enum AutomationEvent { | ||
| SetValue(f32), | ||
| SetValueAtTime(f32, Tick), | ||
| RampToValueAtTime(RampKind, f32, Tick), | ||
| SetTargetAtTime(f32, Tick, /* time constant, units of Tick */ f64), | ||
| SetValueCurveAtTime(Vec<f32>, Tick, /* duration */ Tick), |
This comment has been minimized.
This comment has been minimized.
Manishearth
Apr 3, 2019
Member
both these variants should have a comment saying that the first Tick is the start time
| @@ -408,6 +415,25 @@ impl AutomationEvent { | |||
| *value = val + (event_start_value - val) * exp.exp() as f32; | |||
| true | |||
| } | |||
| AutomationEvent::SetValueCurveAtTime(ref values, start, duration) => { | |||
| let time_diff = ((duration.0 as f32) - (start.0 as f32)) as f32; | |||
This comment has been minimized.
This comment has been minimized.
| AutomationEvent::SetValueCurveAtTime(ref values, start, duration) => { | ||
| let time_diff = ((duration.0 as f32) - (start.0 as f32)) as f32; | ||
| let mut progress = ((((current_tick.0 as f32) - (start.0 as f32)) as f32) / time_diff) as f32; | ||
| if progress < 0.0 { |
This comment has been minimized.
This comment has been minimized.
Manishearth
Apr 3, 2019
Member
This should never be negative, perhaps we can add a debug_assert!() to check that instead of silently setting it to zero?
| let next = k + 1. as f32; | ||
| let step = time_diff / (n - 1.); | ||
| if next < n { | ||
| let time_k = (k * step) as f32; |
This comment has been minimized.
This comment has been minimized.
Manishearth
Apr 3, 2019
Member
This is recalculating stuff we already know, an easier way to do this is to calculate k_float with k = k_float.floor(), and then interpolate between v[k] and v[k+1] with progress k_float - k`.
|
(The |
| SetValueCurveAtTime( | ||
| Vec<f32>, | ||
| /* start time, units of Tick */ Tick, | ||
| /* duration, units of Tick */ Tick, |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Akhilesh1996
Apr 3, 2019
Contributor
Hi Manish,
Thank you for the comments, I don't quite understand how to implement the k_float stuff. Do you want me to get rid of the step variable and just store (current_tick.0 as f32) - (start.0 as f32) in t_k (which will be progress * duration) and something else in t_k_next? If so, I don't understand how I can calculate the t_k_next value without using the step value.
Can you help me out with this?
Thanks.
This comment has been minimized.
This comment has been minimized.
Manishearth
Apr 3, 2019
Member
You don't need time_k_next
You already have k_float - k, which is a number 0 to 1 representing where to interpolate.
So you can do something like
if k + 1 < n {
let progress = k_float - k
*value = v[k] * (1 - progress) + v[k + 1] * progress;
} else {
*value = v[n - 1];
}
This comment has been minimized.
This comment has been minimized.
Akhilesh1996
Apr 3, 2019
Contributor
Hi Manish,
Thank you. I have made the changes and ran rustfmt. Is it fine now?
|
Looks good, please squash your commits |
|
Hi Manish, Thank you. We had first cloned the repo and added commits, after that forked the repo again and pushed changes to it. So there are 6 commits made to the original servo/media in-between the commits made by us. How would you advise us to rebase and squash our commits into a single one? Thanks |
|
In general, instead of merging new commits from master you should try to
rebase.
To fix the current situation, rebase over master first, ensure that that's
working fine (you should have all your commits on top), and then squash
your commits with a second rebase. Make sure your master is updated.
Something like:
```
git fetch origin
git rebase -i origin/master
# check commits are on top
git rebase -i origin/master
# squash
```
you can do both rebases as a single step but it's easier to do it as two so
you can ensure it happened correctly
…On Wed, Apr 3, 2019, 7:48 PM Akhilesh1996 ***@***.***> wrote:
Hi Manish,
Thank you.
We had first cloned the repo and added commits, after that forked the repo
again and pushed changes to it. So there are 6 commits made to the original
servo/media in-between the commits made by us. How would you advise us to
rebase and squash our commits into a single one?
Thanks
Akhilesh
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#230 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABivSKk3nMvvg52lTA50vgV8utvHQNrqks5vdWgVgaJpZM4cXCdZ>
.
|
|
Thanks. Would report back and hopefully in a while. |
|
@Manishearth The merge between the repos and branches we did earlier seems to causing trouble with Squashing. However I have synced with upstream now. Could you please advise on how to squash the commits in this situation? |
|
You had some merge conflicts that needed to be worked out. I pushed a fix. In the future, please rebase over master instead of merging in master. |
|
@bors-servo r+ |
|
|
|
Thank you. We would take that note. |
|
|
JHBalaji commentedApr 2, 2019
•
edited by Manishearth
fixes #204