marchingband / wvr

Home of WVR, an open source, Arduino compatible, ESP32-based Sample Player and Audio Framework.
GNU General Public License v3.0
64 stars 9 forks source link

Feature: Add attack and release controls #59

Closed marchingband closed 7 months ago

marchingband commented 1 year ago

Attack and Release will default to 0ms CC72 will be release, the value expressed in units of 50ms, so 0 ~ 127 = 0 ~ 6.35 seconds CC73 will control attack, 0 ~ 6.35 seconds CC22 will become the instant fade-out time, with the same units as it currently has. CC23 will modify the fade-in and fade-out curve:
0 ~ 42 = square root 43 ~ 85 = linear 86 ~ 127 = logarithmic

TheBatmosphere commented 1 year ago

Remind me again how CC22 would work and how CC72 would interact with it? I'm still not clear why it’s necessary to adjust the instant fade-out time. (It wouldn't be instant after adjusting, right? ;-)

Linking the fade curve to the velocity curve is an interesting idea. I wonder if that would cause unexpected behavior.

I was originally thinking of having CC22 switch among several curves, for example:

But I suspect a single curve would be enough. Many ADSR diagrams show convex attack and concave release. That supposedly reflects how we perceive loudness. (Also see "response curve" in this article.)

adsr-exponential-1x (Image from AAS)

marchingband commented 1 year ago

CC22 would work just like CC72 does currently. The default ASAP fade-out is about 1ms, but for some unusual sounds, that is too fast, and still causes a 'pop', so we created CC72 so users can slow it down a little, the slowest is about 50ms IIRC. When a sample is playing in normal mode, this release is used when a note-off happens, in ASR mode, this release is triggered when the voice-stealing algorithm prunes a note.

The square-root curve that WVR uses is similar to exponential (just a little more musical), so that is the 'concave' option, and the logarithmic is the 'convex' option. I will set the default to linear, and then we can use CC23 to modify it ...

0 ~ 42 = square root 43 ~ 85 = linear 86 ~ 127 = logarithmic

I will keep editing the top post in this thread to represent the proposal.

TheBatmosphere commented 1 year ago

Thanks, Andrew. I still can't imagine when I'd need to use CC22, but having attack and release would be great. I'm curious to play with the curve shape too — that may be a first on a hardware sample player.

marchingband commented 1 year ago

I can't remember what kind of sounds required a slower ASAP fade-out, to avoid the pops, it was a while ago, but I ran tests and confirmed that it was indeed needed for some sub-set of sounds.

marchingband commented 1 year ago

beta release here for testing It is compiled on the usb firmware for those who use usb. The branch is called a-r-envelopes-cc if you're curious to see the changes

For now it uses the same curve as the RESPONSE-CURVE for that sound. The only option that sounds great (to me) is inverse-square-root, so my proposal is to set it to always use that curve.

With the attack or release set to 127 (maximum) the time is about 6.5 seconds ... which seems to me like a reasonable maximum.

I also considered using a more complex algorithm where a re-trigger would act on the current state of the VCO for that note, but after some thought I decided against it. Every new note starts its own envelope, regardless of weather its a re-trigger.

TheBatmosphere commented 1 year ago

FYI, I was playing WVR with attack and release knobs last weekend and found them super-useful. Thanks again. I’m not yet sure about the curve.

marchingband commented 1 year ago

Good to hear! Once we decide on the curve I will probably add this to the main firmware.

Atonal-Circuits commented 10 months ago

Attack and release up to 6s would be great... Will this be added to main basic firmware?

marchingband commented 10 months ago

I have pitch-bend, envelopes, WiFi station mode, and a few other features ready to merge into the firmware, they just need rigorous testing, which I havn't had time to do quite yet.

Next chance I get I will make a new "release candidate" firmware and send out a note to request testing of it.

I'll post that in the Google group and in these GH issues as well.

marchingband commented 10 months ago

@TheBatmosphere do you agree with me that inverse-square-root is the only curve that seems useful?

TheBatmosphere commented 10 months ago

Thanks for asking. I’ve been using linear. I’ll go back and compare the others ASAP.

TheBatmosphere commented 10 months ago

I tested attack and release curves by loading the same sample into adjacent notes and setting their velocity response to linear, square root, and inv square root. Inv square root definitely sounded the smoothest. (I tried the fixed response too, but suspect it's using the inv square root curve because it sounded the same.)

One weird thing is that velocity seems to affect the fade duration. Maybe that was just for testing, but I think it would sound more natural if it were decoupled. In other words, velocity would affect just volume and CC 73 and 72 would affect attack and decay with an inverse square root curve. Thanks for considering this feature!

marchingband commented 7 months ago

done in 3.9.0