Envelope in Synth, Arbitrary Start

Suppose my synth is:

SynthDef(\envSynth, {
    var sig, freqEnv, freq;
    freqEnv = Env.newClear(20, 1);
    freq = \freqEnv.kr(freqEnv.asArray);
    sig = SinOsc.ar(freq);
    Out.ar(0, sig);
}

and the envelope that is passed in is some arbitrary envelope of some long length. Then suppose I edit a node in the envelope that is pretty far out, say 1min. Now I want to hear what I’ve done but I don’t want to always wait 1min to hear my edit.

Is there a way to “skip” in the envelope to some arbitrary starting point?

See IEnvGen, this should allow what you’re looking for.

1 Like

The env in IEnvGen is not modulatable at all though. All its env values are treated as ir. So it won’t really work for the proposed purpose here (“suppose I edit a node in the envelope”) unless the synth is rebuilt seamlessly replacing the running one. One solution is to create a 2nd synth with the new env and cross fade between the synths for a couple of seconds . If there are no changes in the region being played, noting will be noticeable right now between the old env synth and its replacement, but since only the replacement will be playing at some point further in the future, you’ll get the desired change.

Even for the regular EnvGen care needs to be taken that the current segment is immutable once it has been entered. Only changes to subsequent segments take effect. So if you have a 1min ramp as one Env segment, you can’t change its end while it is being played. (For something simple like an instantly modifiable long ramp, you can use Sweep and change its rate i.e. slope.)

Frankly it’s easier to use a buffer as the envelope for such purposes, if they need to be modified during playback. You can change an arbitrary part of a buffer while it’s being read by another synth. (And you can also index to arbitrary points in a buffer.) The annoying part is that the time base for buffers is samples not seconds. And you’ll have to deal with potentially instantaneous jumps somehow (e.g. xfade) if you modify a region that overlaps the one being played.