Not really,
I have a counter which keeps track of all my strings (6).
Each string triggers on a certain condition.
I’m now going the event / score route, where I trigger the strings separately.
If I have a way now to transfer the “p3” to the separate instruments, I can use the “release” and “lastcycle” in those instruments.
Here, a snippet of what I’m trying to make work:
form caption("Note State Example") size(300, 200), guiMode("queue"), pluginId("def1")
keyboard bounds(10, 10, 280, 100), channel("noteState")
-n -d -+rtmidi=NULL -M0 -dm0 --midi-key-cps=4 --midi-velocity-amp=5
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
gkCounter init 0 ; will only iterate through the strings
instr 1
ktime times
kdur = 2
idur = 2
;xtratim idur + .001
iTun = 0
kStringFrequency = p4 / 2 * cent(iTun*100)
kAmp1 = -(10^(-p5))+1.1
ktrigger changed p5
if ktrigger == 1 then
gkCounter += 1
endif
/if giCounter > 6 then
giCounter = 1
endif/
kStringE init 0
kStringA init 0
kStringD init 0
kStringG init 0
kStringB init 0
kStringe init 0
kS1 init 0
kS2 init 0
kS3 init 0
kS4 init 0
kS5 init 0
kS6 init 0
if kStringE == 0 && kStringA == 0 && kStringD == 0 && kStringG == 0 && kStringB == 0 && kStringe == 0 then
kSTrigE trigger gkCounter == 1 ? 1 : 0, 0, 0
endif
/if kStringE == 1 then
kSTrigE init 0
endif/
if kSTrigE == 1 then
konsetE = p2
kStringE = 1
kStringFrequencyE = kStringFrequency
endif
schedkwhen kSTrigE, 0, 1, 4, 0, .001, p4, p5
kInstr4E active 4 ;[,iopt [,inorel]]
;printk2 kStringE
;printk2 kInstr4E
kTrigInstr4E trigger kInstr4E, 1, 1
if kTrigInstr4E == 1 then
kStringE = 0
if gkCounter != 1 then
kSTrigE = ktrigger
endif
gkCounter -= 1
endif
/*if kStringE == 1 then
kdurE = konsetE + p3
iE = rnd(1000)
if release() == 1 then
kS6 = 1
endif
kReleaseE trigger kS6, 0, 0
if kdur > .1 then
kSTrigE1 trighold kReleaseE, kdur - .1 ; kA = trigger segment ;kRelease;kSTrigE1;kA;kTrigRelE;
k6A trigger kSTrigE1, 1, 1 ; trigger
kTrigRelE trighold k6A, .1
kSTrigE12 trigger kTrigRelE, 1, 1 ; trigger
;kSTrigE12 trighold kSTrigE12, .1
;kSTrigE22 trigger kSTrigE12, 1, 1
if kReleaseE == 1 || kSTrigE1 == 1 || k6A == 1 || kTrigRelE == 1 then
k6Q = 1
else
k6Q = 0
endif
else
kSTrigE1 = kS6
k6A = kReleaseE
kTrigRelE trighold kReleaseE, .1 ; kRelease = trigger segment = kA ;kRelease;kTrigRelE;
kSTrigE12 trigger kTrigRelE, 1, 1
;kSTrigE12 trighold kSTrigE12, .1
;kSTrigE22 trigger kSTrigE12, 1, 1
if kReleaseE == 1 || kTrigRelE == 1 then
k6Q = 1
else
k6Q = 0
endif
endif
endif
if kSTrigE12 == 1 then
gkCounter -= 1
kStringE = 0
kS6 init 0
kSTrigE12 init 0
endif
if kStringE == 0 then
if gkCounter != 0 then ; the counter conditon takes all possibilities other than "kSTrigE trigger giCounter == 1 ? 1 : 0, 0, 0 … "
kSTrigE = ktrigger
endif
endif*/
if kStringE == 1 && kStringA == 0 && kStringD == 0 && kStringG == 0 && kStringB == 0 && kStringe == 0 then
kSTrigA trigger gkCounter == 2 ? 1 : 0, 0, 0
endif
if kSTrigA == 1 then
kdurA = p3
kStringA = 1
kStringFrequencyA = kStringFrequency
turnoff2 3, 0, .01
event “i”, 3, 0, 5, p4, p5
endif
kInstr3A active 3
kTrigInstr3A trigger kInstr3A, 1, 1
if kTrigInstr3A == 1 then
kStringA = 0
if gkCounter != 1 then
kSTrigA = ktrigger
endif
gkCounter -= 1
endif
/if kStringA == 1 then
iA = rnd(1000)
if release() == 1 then
kS5 = 1
endif
kReleaseA trigger kS5, 0, 0
if kdur > .1 then
kSTrigA1 trighold kReleaseA, kdur - .1
k5A trigger kSTrigA1, 1, 1
kTrigRelA trighold k5A, .1
kSTrigA12 trigger kTrigRelA, 1, 1
if kReleaseA == 1 || kSTrigA1 == 1 || k5A == 1 || kTrigRelA == 1 then
k5Q = 1
else
k5Q = 0
endif
else
kSTrigA1 = kS5
k5A = kReleaseA
kTrigRelA trighold kReleaseA, .1
kSTrigA12 trigger kTrigRelA, 1, 1
if kReleaseA == 1 || kTrigRelA == 1 then
k5Q = 1
else
k5Q = 0
endif
endif
endif
if kSTrigA12 == 1 then
gkCounter -= 1
kStringA = 0
kS5 init 0
kSTrigA12 init 0
endif
if kStringA == 0 then
if gkCounter != 1 && kStringE == 1 then
kSTrigA = ktrigger
endif
endif/
if kStringE == 1 && kStringA == 1 && kStringD == 0 && kStringG == 0 && kStringB == 0 && kStringe == 0 then
kSTrigD trigger gkCounter == 3 ? 1 : 0, 0, 0
endif
if kSTrigD == 1 then
kStringD = 1
kAmpD = kAmp1
kStringFrequencyD = kStringFrequency
kNoteNumD = round((69 + (12 * log2(kStringFrequencyD / 440))) + 12)
turnoff2 2, 0, .01
event “i”, 2, 0, p3 + kdur, p4, p5
endif
kInstr2D active 2
kTrigInstr2D trigger kInstr2D, 1, 1
if kTrigInstr2D == 1 then
kStringD = 0
if gkCounter != 1 then
kSTrigD = ktrigger
endif
gkCounter -= 1
endif
/if kStringD == 1 then
iD = rnd(1000)
if release() == 1 then
kS4 = 1
endif
kReleaseD trigger kS4, 1, 1
if kdur > .1 then
kSTrigD1 trighold kReleaseD, kdur - .1
k4A trigger kSTrigD1, 1, 1
kTrigRelD trighold k4A, .1
kSTrigD12 trigger kTrigRelD, 1, 1
if kReleaseD == 1 || kSTrigD1 == 1 || k4A == 1 || kTrigRelD == 1 then
k4Q = 1
else
k4Q = 0
endif
else
kSTrigD1 = kS4
k4A = kReleaseD
kTrigRelD trighold kReleaseD, .1
kSTrigD12 trigger kTrigRelD, 1, 1
if kReleaseD == 1 || kTrigRelD == 1 then
k4Q = 1
else
k4Q = 0
endif
endif
endif
if kSTrigD12 == 1 then
gkCounter -= 1
kStringD = 0
kS4 init 0
kSTrigD12 init 0
endif
if kStringD == 0 then
if gkCounter != 2 && kStringE == 1 && kStringA == 1 then
kSTrigD = ktrigger
endif
endif/
;printk2 kSTrigE
kCounterConsole = kStringE + kStringA + kStringD + kStringG + kStringB + kStringe
;printk2 kStringE
;printk2 kSTrigE
;printk2 kS6
;printk2 kReleaseE
;printk2 kSTrigE1
;printk2 kSTrigE12
;printk2 gkCounter
;printk2 kStringFrequencyE
;printk2 k6Q
;printk2 kSTrigA12
;printk2 kStringA
;printk2 kSTrigA
;printk2 kS5
;printk2 kS
;printk2 kdurE
;printk2 kStringD
endin
instr 2 ; D-string
a1 vco2 p5, p4
outs a1, a1
endin
instr 3 ; A-string
a1 vco2 p5, p4
outs a1, a1
endin
instr 4 ; E-string
;xtratim 5
if release() == 1 then
kSE = 1
else
kSE = 0
endif
if lastcycle() == 1 then
kaap = 1
else
kaap=0
endif
printk2 kSE
printk2 kaap
a1 vco2 p5, p4
outs a1, a1
endin
f 0 z
;i4 0 z
The commented out was the previous way I tried without separate instruments;
But now:
~ schedkwhen kSTrigE, 0, 1, 4, 0, … , p4, p5
or
~ event “i”, 2, 0, … , p4, p5
I could use the “lastcycle()” in each instrument in a global variable to trigger the end of it in the main instrument.