I think it is important that the pull request you make for your assignment include example code that demonstrates that your implementation works as expected.

cheers,
Josh

On 3/30/19 5:22 AM, Akhilesh Venkatasubramanian wrote:
Hi Josh,

I have addressed the same in my code right now. The code compiles and
throws no errors now. This is the version that we have now:
https://github.com/JHBalaji/media/blob/master/audio/src/param.rs#L419-L433

Can you please see if this is fine?

Also, we have a submission for this assignment on Monday so can we submit a
pull request with what we have till now? Also, we will continue to work on
Mozilla for our final semester project and considering that we have a
better hang of how WebAudio works I think we can actively contribute.

Thanks again for your valuable inputs, we are now able to understand the
flow of code much better.

- Akhilesh



On Sat, Mar 30, 2019 at 12:27 AM Josh Bowman-Matthews <j...@joshmatthews.net>
wrote:

Answers inline:

On 3/29/19 7:54 PM, Akhilesh Venkatasubramanian wrote:
Hi Josh,

We went ahead to try to implement the function and are facing some issues
and your insight will be helpful.

1. We have implemented the function here:


https://github.com/JHBalaji/media/blob/master/audio/src/param.rs#L419-L434
<
https://github.com/JHBalaji/media/blob/master/audio/src/param.rs#L419-L434
.

   A)  Can you check if our implementation of interpolating between v[k]
and
v[k+1] is correct? If not, can you give us a heads up as to how to
proceed?

It took me a while to step through it and convince myself that it made
sense, but I think it's right. I'll probably ask one of our Web Audio
experts to double-check it. The naming of x1/x2 and y1/y2 did not help
me; I would suggest using names like v_k and v_k_next as well as time_k
and time_k_next to improve readability.


The above code does give out a few errors as below:

     Compiling servo-media-audio v0.1.0
(/Users/akhilesh/Desktop/media/audio)

error[E0277]: cannot subtract `block::Tick` from `f32`

     --> audio/src/param.rs:432:37

      |

432 |                  *value = (y1 * (x2 - current_tick) + y2 *
(current_tick - x1)) / (x2 - x1) as f32;

      |                                     ^ no implementation for `f32 -
block::Tick`

      |

      = help: the trait `std::ops::Sub<block::Tick>` is not implemented
for
`f32`


error[E0277]: cannot subtract `f32` from `block::Tick`

     --> audio/src/param.rs:432:74

      |

432 |                  *value = (y1 * (x2 - current_tick) + y2 *
(current_tick - x1)) / (x2 - x1) as f32;

      |
      ^ no implementation for `block::Tick - f32`

      |

      = help: the trait `std::ops::Sub<f32>` is not implemented for
`block::Tick`


error: aborting due to 2 previous errors

I was not able to subtract current_tick from the value instance I
generated
to keep track of the expected time for v[k] and v[k+1]. Can you give me
some pointers as to how I can fix the same?

You can find the documentation for block::Tick at
https://doc.servo.org/servo_media_audio/block/struct.Tick.html . If you
click the "Show Declaration", you will see that it wraps a u64 value,
which you can retrieve with `current_tick.0` and can then cast to f32.





B) Should we declare the values vector and duration also somewhere else
in
the program or are the changes made by me enough to handle the function?

2. There was one more modification I had to make to make the code compile
till the previous point. In L259
<https://github.com/JHBalaji/media/blob/master/audio/src/param.rs#L259>
and
L271, if I also had the Copy trait called then it shows the error posted
below, which I believe is because of the values vector in the
SetValueCurveAtTime function. Can I just remove the copy trait or is
there
any other modification that I have to make?

error[E0204]: the trait `Copy` may not be implemented for this type

     --> audio/src/param.rs:259:17

      |

259 | #[derive(Clone, Copy, PartialEq, Debug)]

      |                 ^^^^

...

266 |     SetValueCurveAtTime(Vec<f32>, Tick, /* duration */ f64),

      |                         -------- this field does not implement
`Copy`


error[E0204]: the trait `Copy` may not be implemented for this type

     --> audio/src/param.rs:271:17

      |

271 | #[derive(Clone, Copy, PartialEq, Debug)]

      |                 ^^^^

...

278 |     SetValueCurveAtTime(Vec<f32>, f64, /* duration */ f64),

      |                         -------- this field does not implement
`Copy`


error: aborting due to 2 previous errors


For more information about this error, try `rustc --explain E0204`.

error: Could not compile `servo-media-audio`.

This was apparently a problem for the group which worked with the
Oscillator node last semester and they weren't able to implement the
custom
method
<
https://github.com/servo/media/blob/master/audio/src/oscillator_node.rs#L150

because they weren't able to solve this issue and when I spoke to one
person he said that removing the copy trait started showing up more
errors
later. Can you give us your take on this?

Removing the Copy trait is fine. Any code that relies on it can have an
explicit `.clone()` added to it and it should compile.

Cheers,
Josh
_______________________________________________
dev-servo mailing list
dev-servo@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-servo


_______________________________________________
dev-servo mailing list
dev-servo@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-servo

Reply via email to