Hello,
How is it possible to make an envelope which is midi triggered like the madsr opcode buy with a delay at start.
I would like to use this to bring in a frequency modulation slightly after a note starts.
Any help is welcome.
Envelope question
I think there is a delayk opcode, it might do the trick?
The question reminded me that I had seen this functionality somewhere, and I thought Csound had an opcode for it. As it turns out I did remember the Hadron source, where I have envelopes like this. I used transeg for the first part of the envelope (up to and including the sustain stage), then keep the sustain level for as long as you have the midi note active. Then, on release, use the release opcode to get a flag that allows you to conditionally processs the release segment.
mock-up code
kenv transeg … (generate first part of envelope, including the delay segment)
krelease init 1
xtratim ireleasetime
kreleaseflag release
if kreleaseflag > 0 then
krelease …(generate release segment)
endif
kenv + kenv * krelease
Unfortunately, the delayk opcode has one drawback : it adds a pure delay, meaning that when the note is released, the release is also delayed. I may try to implement @Oeyvind solution. I will post the solution.
it seems that the transegr
opcode is the one fitted for that task.
a2 transegr 0, i(kDelay), 0, 0, i(katt), 2, 1, i(kdec), -3, i(ksus), i(krel), -3, 0
The code above creates a silence of i(kDelay)
seconds, then rises to 1 in i(katt)
sec, decreases to i(ksus)
in i(kdec)
sec and then is released in i(krel)
sec.
It is a lot of fun to experiment with this, including the type of curve this opcode allows.
Should I have made a mistake, please let me know.