Superdirt SynthDef timing and envelopes

Continuing the discussion from What is tidal doing with SynthDef envelopes?:

I have also noticed the same thing: it can be hard to get the sustain to ring out nicely on note events, and it feels like the synth instance gets freed before its doneAction if the doneAction would come after the end of an event's arc.

Coming back to TidalCycles from Strudel, I also realized this is part of the reason that I (subjectively) prefer the sound of Strudel.

Compare something like this pattern in strudel where the notes resonate nicely

note("<g [d,a] <d!5 g> - <- <g f e>@2>>*8").sound("piano")
.off(3/8, x=>x.add(note("7")).fast(2).gain(0.25).color('red'))

To this in tidal cycles, where the notes don't resonate out:

d1
  $ off (3/8) ((# gain 0.8) . (fast 2) . (+ note 7))
  $ note "<g [d,a] <d!5 g> - <- <g f e>@2>>*8"
  # sound "superpiano"

Of course, it is possible to add # sustain 2, but then how would I go about writing a synthdef
which uses an ADSR envelope? I'd like for legato/sustain to control the S part of the ADSR,
but still let the release play out.

I could maybe do some math on the begin and end arguments in the SynthDef, but this feels awkward compared to just doing the natural thing and letting the event's arc/time act
like a gate, with a different parameter for the release.


I started digging around in SuperDirt to try to understand what the exact behavior is, but I haven't quite figured out what I would need to change if I wanted to customize this behavior.

I see where events get their parameters here:

And how an event calculates its duration here:

But it's not immediately clear to me how this frees/ends sounds that might play out longer.

2 Likes

Hmm, this is the behavior of the dirt_gate synth defined here:

And used here:

If I understand this correctly it limits the sound to the sustain period of the event by explicitly freeing and silencing the output, while also supporting control over the overall gain and amplitude of sounds on a specific orbit.

I see an effort to integrate some of the behaviors from strudel back into superdirt by Jade, and an issue which discusses the differences.

The difference in how superdirt's sustain works is mentioned in the issue, and it seems that adding a dedicated release parameter, changing the name of sustain to sus, and calculating it from the sustain+release(+attack?) could be a decent solution.