# Adding a release tail to a sample

**URL:** <https://forum.toplap.org/t/adding-a-release-tail-to-a-sample/1197>\
**Category:** TidalCycles\
**Created:** [29 March 2020 07:16 UTC](https://forum.toplap.org/t/adding-a-release-tail-to-a-sample/1197 "2020-03-29T07:16:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tedthetrumpet](https://forum.toplap.org/user_avatar/forum.toplap.org/tedthetrumpet/32/38_2.png) [@tedthetrumpet](https://forum.toplap.org/u/tedthetrumpet)\
**Post date:** [29 March 2020 07:16 UTC](https://forum.toplap.org/t/adding-a-release-tail-to-a-sample/1197/1 "2020-03-29T07:16:24Z")

</div>

I’m still struggling with how to neatly use sections from a longer cycle. If I do as below, the envelope at the end of the sample is very short indeed, and you get a distinct click at the end:

`d1 $ s "bev" # n 0 # begin (0/16) # end (1/16)`

If I do as below, then it does not do what I would expect, which would be to play up to the ‘end’ and then add a release tail. Instead of being a ‘release’, it’s more like the ‘decay’ of an up-and-down a/d envelope:

`d1 $ s "bev" # n 0 # begin (0/16) # end (1/16) # release 0.5`

In the slicing sampler I use in SC, I have a fast attack but a release tail at the end of the sample of 0.1, which I find works well. How can I do that in Tidal? Do I need to hack SuperDirt?

Let’s see… in core-synths.scd I found a SynthDef called dirt\_gate with an argument fadeTime. So… where does that value come from? An Event presumably?

Yes, looks like fadeTime comes from DirtEvent.scd but I can’t understand how it is defined there:

`~fadeTime = min(~fadeTime.value, sustain * 0.19098);`

But… unless I’m missing something here, it seems to me that SuperDirt is just not doing what most digital musicians would call a ‘release’. Adding a ‘release’ to a note should lengthen it: in SuperDirt, it (kind of) shortens it.

---

<div class="post-metadata">

**Author:** ![telephon](https://forum.toplap.org/user_avatar/forum.toplap.org/telephon/32/209_2.png) [@telephon](https://forum.toplap.org/u/telephon)\
**Post date:** [29 March 2020 12:51 UTC](https://forum.toplap.org/t/adding-a-release-tail-to-a-sample/1197/2 "2020-03-29T12:51:52Z")

</div>

This terminology comes from SuperCollider. The standard there is: `sustain` is the total duration of a sound.

The `release` parameter is just an envelope effect, it doesn’t affect the total sustain.

The `fadeTime` parameter doesn’t affect the total sustain either, it is subtracted from it. I suppose for adding an extra tail, you’d have to modify DirtEvent a little:

Untested, maybe like this:

```auto
~fadeInTime = ~fadeInTime ?? { if(~begin != 0) { ~fadeTime } { 0.0 } };
~sustain = sustain - (~fadeTime + ~fadeInTime) + (~tail ? 0);

```

Then you can then send a tail from tidal that matches `fadeTime`, and also a `fadeInTime` sepeately.

---

<div class="post-metadata">

**Author:** ![tedthetrumpet](https://forum.toplap.org/user_avatar/forum.toplap.org/tedthetrumpet/32/38_2.png) [@tedthetrumpet](https://forum.toplap.org/u/tedthetrumpet)\
**Post date:** [29 March 2020 14:22 UTC](https://forum.toplap.org/t/adding-a-release-tail-to-a-sample/1197/3 "2020-03-29T14:22:14Z")

</div>

I will try the code you suggest.

It’s true that in SC the sustain is the length of the event, like the gate time in an analog synth. But, if you add a release to an SC envelope, the sound gets longer:

```
(
SynthDef(\blip, { |out= 0, freq = (60.midicps), nharm = 10, gate = 1, amp = 0.1, pan = 0.0, release = 0.01|
	var sig = Blip.ar(freq * ((-2..2)/500 + 1), nharm); // five channels, detuned
	var env = EnvGen.kr(Env.adsr(releaseTime: release), gate, doneAction:2);
	sig = sig * env;
	Out.ar(out, Splay.ar(sig, center:pan) * amp)
}).add;
)

// sound lasts for two beats
(instrument: \blip, sustain: 2, dur: 2, release: 0).play
// sound lasts for four beats
(instrument: \blip, sustain: 2, dur: 2, release: 2).play
```

---

<div class="post-metadata">

**Author:** ![jamshark70](https://forum.toplap.org/letter_avatar_proxy/v4/letter/j/47e85d/32.png) [@jamshark70](https://forum.toplap.org/u/jamshark70)\
**Post date:** [31 March 2020 22:45 UTC](https://forum.toplap.org/t/adding-a-release-tail-to-a-sample/1197/4 "2020-03-31T22:45:50Z")

</div>

> [@tedthetrumpet](#):
>
> It’s true that in SC the sustain is the length of the event, like the gate time in an analog synth.

Yes – release time is not subtracted from the gate.

In SC, `sustain` in an event means the number of beats between the note’s onset and the time when the gate is set to zero. The release phase happens _after_ this time, and the release duration is _added_.

It’s possible that SuperDirt implements its envelopes differently (I do have SynthDefs in my setup that subtract the release time, but those are non-gated envelopes so they aren’t related to the Event meaning of `sustain`).

hjh
