How to delay a glissando?

Howdy.

I am not great at making synthdefs, just so you know.

Problem:
I am trying to delay, or offset in time, when a glissando begins.

Below is what I have made, but it is broken, so I am including it here not really knowing if it is of any use to you.

(
SynthDef("sin", {|out = 0, sustain = 1, bnd = 0, bnt = 0.2, bno = 0, freq = 440, 
iph = 0, amp = 1.0, pan = 0, att = 0.0, rel = 1.0, crv = -8.0|
	var env, accel, sig, freqclipped;
	env = Env.perc(att, rel, amp, crv).kr(doneAction: 2);
	accel = TDelay.ar(Line.ar(1, 1 + bnd.clip(-1.0, 1.0), bnt * sustain), bno);
	freqclipped = freq.clip(20, 20000) * accel;
	sig = FSinOsc.ar(freqclipped.clip(20, 20000), iph, 0.75);
	sig = sig * env;
	sig = Pan2.ar(sig, pan);
	Out.ar(out, sig);
}).store;
)

(
Pdef(0,
	Pbind(*[
		instrument: \sin,
		amp: 1,
		dur: 1/8,
		bnd: Pwhite(-1.0, 1.0),
		bnt: Phprand(0.0, 1.0),
		bno: Pwhite(0.0, 1.0),
		freq: Plprand(100, 1000).round(100),
	])
).play
)

I would like to keep communication centered on this general setup of a synthdef and Pdef Pbind combo as I can’t work with Pmonoartic and similar because I always have this other stuff happening around the above slimmed down / vanillified example otherwise.

A friend said to try Tdelay and so that is why that is in there. I got an error when I previously used Line.kr so I changed that to .ar and at that point my code could run and made a sound, but it was not what I expected. I am guessing my thing that I made is not good and proly you can tell.

Maybe this should be an Env based thing instead? That way the glissando could have a curvature as well? I don’t know. I’m rambling here because I’m nervous about asking questions.

Any help would be very much appreciated.

I think that since you’re purpose making some sort of envelope/function for the glissando, and not trying to use an envelope pre-allocated for something else, the simplest way would be an Env.

There’s Env.dadsr. https://doc.sccode.org/Classes/Env.html#*dadsr. It is sustainable, so would work nicely with how it seems you’re currently thinking about implementation.

However, using an Env, delayed or not, will in this way always trigger on instantiation of the Synth. If you want to trigger it later (not retrigger), you’ll need to do some other stuff to mute out the initial envelope values. A simple way to do this might be TDelay and Decay to create a simple Env shape. You can have an argument in your SynthDef for the trig, and set it to 0 or 1 in your Pbind.

	accel = TDelay.ar(Line.ar(1, 1 + bnd.clip(-1.0, 1.0), bnt * sustain), bno);

Maybe this should be an Env based thing instead? That way the glissando could have a curvature as well? I don’t know. I’m rambling here because I’m nervous about asking questions.

yes, an envelope is a great idea. try replacing the line of code above with…

    accel = EnvGen.kr(Env(
        [1, 1, 1 + bnd.clip(-1.0, 1.0)],
        [bno, bnt * sustain],
        [0, 0, 'lin']  //optional curvature
    ));

And to understand what’s going on - here is an envelope that waits for 0.2sec and then ramps 0-1 over 0.1sec…

{EnvGen.kr(Env([0, 0, 1], [0.2, 0.1]))}.plot(0.5);

so when the envelope starts it’ll go from 0 to 0 in 0.2s, and then start ramping up. in this way we can ‘delay’ the start.

Another option is to delay the envelope’s gate somehow…

{EnvGen.kr(Env([0, 1], [0.1]), 1-Trig.kr(1, 0.2))}.plot(0.5);

but that’ll just add complexity.

Yet another variant is a Line that starts directly and is clipped at some lower value (here 0.0). This is a simple technique but it can be more difficult to get the timing right.

{Line.kr(-2, 1, 0.3).max(0)}.plot(0.5);

_f

#|
fredrikolofsson.com musicalfieldsforever.com

1 Like

Oh wow!
redFrik to the rescue!
Thank you so much.
I’ll be making compacti glissandi music for days now.