Csound Csound-dev Csound-tekno Search About

Responsive Envelopes

Date2016-11-03 19:48
FromZephyr
SubjectResponsive Envelopes
Hello!

I've been learning CSound off and on for about a month, mostly for the purpose of making MIDI controlled instruments.

Here's a shortened version of my current monosynth and its problems:

1. The envelopes take an extra note press to become 'active' after you change a parameter

2. The envelopes won't react to the current MIDI CC value without restarting the envelope. I realize that this is because all of the madsr envelope parameters are set with 'i-time'. Is there some sort of workaround with reinit that will make this possible, or a clever use of looseg?

For example, if you play a note with the release set to max, then shorten the release time, the outputted value should reflect that value as in an traditional analog synth.

3. filter cutoff has to be set before any notes sound, initc7 doesn't work with moogladder as it does elsewhere



Thanks for your help! Excited about this!
Also if anyone can point me to a good example for monosynth note handling (lowest note priority, handling gate triggers etc) I would be forever grateful!





-odac -+rtmidi=virtual -+rtaudio=portaudio  -M1



sr = 48000
ksmps = 32
nchnls = 2
0dbfs = 1

connect "VCO",   "output",     "LPF",     	"input"
connect "LPF",   "output",     "Outputs",     	"input"

alwayson "VCO"
alwayson "LPF"
alwayson "Outputs"

instr noteTrigger
	icps     cpsmidi
	gkcps = icps
	initc7 1, 1, 0.0001
	initc7 1, 2, 1
	initc7 1, 3, 1
	initc7 1, 4, 1
	kFiltAttack ctrl7 1, 1, 0.0001, 1
	kFiltDecay ctrl7 1, 2, 0.001, 1
	kFiltSustain ctrl7 1, 3, 0.001, 1
	kFiltRelease ctrl7 1, 4, 0.05, 1
	gkFiltEnv     madsr  i(kFiltAttack),  i(kFiltDecay), i(kFiltSustain), i(kFiltRelease)
endin

instr VCO
	aosc1 vco2 0dbfs * 0.4, gkcps, 0, 0.6
	outleta "output", aosc1
endin

instr LPF
	initc7 1, 5, 1
	initc7 1, 6, 0.0001
	kCutoff ctrl7 1, 5, 0, 1
	kRes ctrl7 1, 6, 0, 0.96
	ainput inleta "input"
	afilt moogladder ainput, ((gkFiltEnv * kCutoff) * 5000), kRes
	denorm afilt
	outleta "output", afilt
endin

instr Outputs
  ainput inleta "input"
  alimitedL wrap ainput, -0dbfs, 0dbfs
  alimitedR wrap ainput, -0dbfs, 0dbfs
  outs alimitedL, alimitedR
endin









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

Date2016-11-03 20:44
FromVictor Lazzarini
SubjectRe: Responsive Envelopes
Generally, envelope arguments are all i-time. However you can construct your envelope
generators that would work differently. Here’s one example, an ADSD that works
with a trigger (gate) signal. It will allow parameters to be tweaked on the fly.
Envelope parameters are self-explanatory; the trig parameter starts the envelope
when high (1) and sends it into release when low (0).

 opcode ADSD,k,kkkkk
 kmax,katt,kdec,ksus,ktrig    xin 
 ktime init 0
 kv init 0
 iper = 1/kr
 if (ktrig == 1) then
   if ktime <= katt then
     kt = katt 
     kv = kmax
   else 
     kt = kdec
     kv = ksus
   endif
   ktime += iper
 else
   kt = kdec
   kv = 0
   ktime = 0
 endif
 kenv  portk  kv, kt
       xout  kenv
endop

It’s adapted from http://www.csounds.com/udo/displayOpcode.php?opcode_id=131, so
not fully tested but I think it works as expected.

========================
Dr Victor Lazzarini
Dean of Arts, Celtic Studies and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952 




> On 3 Nov 2016, at 19:48, Zephyr  wrote:
> 
> Hello!
> 
> I've been learning CSound off and on for about a month, mostly for the purpose of making MIDI controlled instruments.
> 
> Here's a shortened version of my current monosynth and its problems:
> 
> 1. The envelopes take an extra note press to become 'active' after you change a parameter
> 
> 2. The envelopes won't react to the current MIDI CC value without restarting the envelope. I realize that this is because all of the madsr envelope parameters are set with 'i-time'. Is there some sort of workaround with reinit that will make this possible, or a clever use of looseg?
> 
> For example, if you play a note with the release set to max, then shorten the release time, the outputted value should reflect that value as in an traditional analog synth.
> 
> 3. filter cutoff has to be set before any notes sound, initc7 doesn't work with moogladder as it does elsewhere
> 
> 
> 
> Thanks for your help! Excited about this!
> Also if anyone can point me to a good example for monosynth note handling (lowest note priority, handling gate triggers etc) I would be forever grateful!
> 
> 
> 
> 
> 
> -odac -+rtmidi=virtual -+rtaudio=portaudio  -M1
> 
> 
> 
> sr = 48000
> ksmps = 32
> nchnls = 2
> 0dbfs = 1
> 
> connect "VCO",   "output",     "LPF",     	"input"
> connect "LPF",   "output",     "Outputs",     	"input"
> 
> alwayson "VCO"
> alwayson "LPF"
> alwayson "Outputs"
> 
> instr noteTrigger
> 	icps     cpsmidi
> 	gkcps = icps
> 	initc7 1, 1, 0.0001
> 	initc7 1, 2, 1
> 	initc7 1, 3, 1
> 	initc7 1, 4, 1
> 	kFiltAttack ctrl7 1, 1, 0.0001, 1
> 	kFiltDecay ctrl7 1, 2, 0.001, 1
> 	kFiltSustain ctrl7 1, 3, 0.001, 1
> 	kFiltRelease ctrl7 1, 4, 0.05, 1
> 	gkFiltEnv     madsr  i(kFiltAttack),  i(kFiltDecay), i(kFiltSustain), i(kFiltRelease)
> endin
> 
> instr VCO
> 	aosc1 vco2 0dbfs * 0.4, gkcps, 0, 0.6
> 	outleta "output", aosc1
> endin
> 
> instr LPF
> 	initc7 1, 5, 1
> 	initc7 1, 6, 0.0001
> 	kCutoff ctrl7 1, 5, 0, 1
> 	kRes ctrl7 1, 6, 0, 0.96
> 	ainput inleta "input"
> 	afilt moogladder ainput, ((gkFiltEnv * kCutoff) * 5000), kRes
> 	denorm afilt
> 	outleta "output", afilt
> endin
> 
> instr Outputs
>  ainput inleta "input"
>  alimitedL wrap ainput, -0dbfs, 0dbfs
>  alimitedR wrap ainput, -0dbfs, 0dbfs
>  outs alimitedL, alimitedR
> endin
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 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


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