Csound Csound-dev Csound-tekno Search About

Re: Responsive Envelopes

Date2016-11-04 17:22
FromZazzy Zeph
SubjectRe: Responsive Envelopes
This is exactly what I was looking for, thanks so much!!

i'm still working on note priority, but I was able to get proper gate-style triggering working!




-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 "Gate"
alwayson "filterEnv"
alwayson "VCO"
alwayson "LPF"
alwayson "Outputs"

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

instr midiIn
	icps     cpsmidi
	gkcps = icps
	iamp ampmidi 1
endin

instr Gate
	kNoteCount active "midiIn"
	if (kNoteCount > 0) then
		gkGate = 1
	else
		gkGate = 0
	endif
endin

instr filterEnv
	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 ADSD 1, kFiltAttack, kFiltDecay, kFiltSustain, gkGate
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