-
Notifications
You must be signed in to change notification settings - Fork 72
Description
This is related to #500
Another feature that would be nice to have with the sample playback is the ability to have envelopes to control the volume and possibly pitch of the sound as an audio file is played. I'm mostly envisioning surfacing this to users as a typical ADSR envelope.
The way that @mmoskal implemented this in arcade for our synthesizer engine was to allow the user to pass in a buffer that contains instructions about changes to pitch and volume over time. Each instruction in the buffer has the following parameters:
- Start Volume
- End Volume
- Start Frequency
- End Frequency
- Duration
I like this approach because its flexible and let me implement lots of envelope shenanigans on top of it. For example, here's some code I wrote for Arcade that supports instruments with an amp envelope, pitch envelope, amp LFO, and pitch LFO: https://github.com/microsoft/pxt-common-packages/blob/master/libs/mixer/instrument.ts#L532