Adding test for envelope class
@therewasaguy can you please! review this :)
This doesn't need to happen as part of this PR, but I would love to see us take testing of this class to the next level.
Under the hood, an Envelope changes the value of a Web Audio API AudioParam) over time, using methods described here that schedule the changes on the Web AudioContext clock https://developer.mozilla.org/en-US/docs/Web/API/AudioParam#methods .
How can we truly test that we are producing this behavior?
One option: use a method like getValueAtTime to get the value of the audio param at some point in the future. Unfortunately there isn't a native way to do this in the Web Audio API. but Tone.JS has implemented this method and we already have a dependency on it, and/or we could introduce a dependency on this library (which I haven't tried)
Another option: we could use a p5.Recorder to record audio output snippets and then compare the values of the resulting audio buffers to make sure they are what we expect. This might be prone to flakiness, I haven't tried it recently but I believe that Tone.JS took this approach for unit tests at some point at least (perhaps before coming up with the getValueAtTime method which is really useful!)
@therewasaguy thank you for the guidance :) will try to resolve all the issues as soon as possible and make this pr mergable :)
@therewasaguy I fixed everything you mention. I will try to use the tone.js library for testing the class as you mentioned. is there anything left in this pr?
@iRohitSingh you can use beforeEach() and afterEach() hook to initiate and dispoe the envelope instance
@therewasaguy i think we should merge this one before #608 it can be used to test that pr
Thanks @Abhijay007! Agreed, looks like this class is pretty well-tested on the main branch right now. I'm going to close this PR, but feel free to open another if you feel like there's something current test suite can benefit from adding!