[Csnd] wondering if this can be modernized?

Hi folks, I’m still coming up to speed on all the csound improvements of the last 10 years, and wanted to check whether something I have working in older style code is still the best way to do it, or if there are cleaner options now.

This is my always on envelope, with tigoto branching. It’s using the assembly style jumps and is working, so really asking for purposes of just making the coding more elegant.


; Env1 - env that when retriggered from i event, resumes from where it left off
instr Env1
tigoto tied_init
; first pass only init code
istart init 0.001
kenv init 0.001
igoto continue
; init code for all passes after the first (which are tied)
; capture where kenv left off to be next start point
istart = i(kenv)
kenv linseg istart, 0.01, 1, p3, .8, 0.5, 0.01
; write the output to its patch cord
chnset kenv, “env_1”

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

The tied-note style of tigoto … contin hasn’t changed much over the years as far as I’m aware.
I wonder if it’s necessary to use this as a held instrument though, as you’re setting a channel value which would hold its value after the note expires anyway.

instr Env1
Schan = p4
idestination = p5
kres linseg chnget:i(Schan), p3, idestination
chnset kres, Schan

schedule “Env1”, 0, 3, “env_1”, 0.7

Oh right, I hadn’t thought of that approach of using the channel to get the value it left on. In my old code I wasn’t using channels, and was mostly resurrecting how I made monosynths in the past. I will try that out, thanks for the tip!