I have a few queries.
instr 1
is triggered by MIDI notes but it is also triggered from the score. I’m not sure if this is the best strategy as things like cpsmidi
will only output zero when triggered from the score. You also use midiin
, which makes more sense in the context of an instrument that is triggered from the score but not from MIDI notes. I would use cpsmidi
or midiin
in a single instrument, but probably not both.
ktrigger changed icps
seems like a bad idea because the input argument is i-rate so will never change at k-rate - the output rate of the opcode. ktrigger
will be 1 and then zero on the first and second k-rate passes and maybe this is the output that you want but it has more to do with changed
's slightly odd behaviour which was discussed recently in a different thread.
I would be inclined to forget about ktrigger
and instead do everything within the conditional at i-time. This is because iNoteOnMIDI
is created at i-time and does not change thereafter. Maybe then you could make gkCounter
i-rate and increment is at i-time in the instrument like this:
giCounter = (giCounter + 1) % 4
You can replace:
icps cpsmidi
iNoteOnMIDI ftom icps
with a single line
iNoteOnMIDI notnum
With
if (kvel == 0 || kstatus == 128) then
you seem to be sensing the note release. If you were to get rid of midiin
, you can replace this with something that uses the release
opcode.
These are just a few random thoughts. I hope they are useful.