schedkwhen vs event vs event_i in 'master MIDI instruments'
Date | 2016-08-22 16:49 |
From | Aaron Krister Johnson |
Subject | schedkwhen vs event vs event_i in 'master MIDI instruments' |
I have the following task: split a live keyboard into several regions, or even have carefully chosen individual keys triggering separate instruments. The FLOSS manual examples didn't work in my case, I suspect because the kayboard I'm using doesn't use note_off messages, but uses noteon plus 0 volume in place of note_off (a common thing), and I think, based on the failure, it has to do with the 'release' opcode not working without note_off messages? Someone else can verify... No matter, this is a job for getting down to the raw bytes and diving in with midiin, correct? The following csound code works as a 'master MIDI instrument' to a pair of 'slave' instruments. But, I was banging my head against the wall for quite some time trying to get this code to work at all with event_i (plus i() wrapped k-rate parameters) instead of the schedkwhen you now see. Would 'event_i' work well with 'midiin' if this code were somehow modified? I failed, anyway. Is it b/c midiin is krate, and won't ever play nice with irate stuff like event_i with i() parameters? I even tried init/reinit, but maybe I didn't do it correctly.... instr 1 ;global MIDI instrument, calling instr X.nnn kstat, kchn, kdata1, kdata2 midiin ;; for noteon and noteoff !! if (kstat == 144) then ktrig = 1 ;; use key # 46 to trigger a drum instead of organ if (kdata1 == 46) then kbase = 10 ; instr 10 is a big drum sample kadd = 0 else kbase = 2 ; instr 2 is a synth organ kadd = kdata1 * .0001 endif ;; we wrap pitch info into the instrument number this way: kinstr = kbase + kadd if (kdata2 > 0) then schedkwhen ktrig, 0, -1, kinstr, 0, -1, kdata2 else turnoff2 kinstr, 4, 1; then turn this instance off endif else ktrig = 0 endif endin |
Date | 2016-08-22 20:18 |
From | Arthur Hunkins |
Subject | Re: schedkwhen vs event vs event_i in 'master MIDI instruments' |
Comments: 1) Yes, you need midiin. 2) You need event rather than event_i. Event_i only runs at your instr 1 i-time. 3) I've had no problem doing note-off with a combination if-statement that includes: if ("noteoff") or ("noteon" == 0). Art Hunkins On Mon, Aug 22, 2016 at 11:49 AM, Aaron Krister Johnson <akjmicro@gmail.com> wrote:
|
Date | 2016-08-23 09:52 | ||
From | Iain McCurdy | ||
Subject | Re: schedkwhen vs event vs event_i in 'master MIDI instruments' | ||
Csound's built-in MIDI mechanism will respond to both note-offs (status=128) and note-offs expressed as note-ons with zero velocity (status=144, data2=0), so perhaps your initial problem was due to something else? midiin is indeed k-rate. You could just run midiin in an always-on instrument and share its outputted values as global variables. event_i is i-time, event is its k-rate counterpart (normally placed in some sort of conditional branch). schedkwhen also runs at k-rate but with more bells and whistles. Iain. From: A discussion list for users of Csound <CSOUND@LISTSERV.HEANET.IE> on behalf of Aaron Krister Johnson <akjmicro@GMAIL.COM>
Sent: 22 August 2016 15:49 To: CSOUND@LISTSERV.HEANET.IE Subject: [Csnd] schedkwhen vs event vs event_i in 'master MIDI instruments' I have the following task: split a live keyboard into several regions, or even have carefully chosen individual keys triggering separate instruments. The FLOSS manual examples didn't work in my case, I suspect because the kayboard I'm using doesn't use
note_off messages, but uses noteon plus 0 volume in place of note_off (a common thing), and I think, based on the failure, it has to do with the 'release' opcode not working without note_off messages? Someone else can verify...
No matter, this is a job for getting down to the raw bytes and diving in with midiin, correct?
The following csound code works as a 'master MIDI instrument' to a pair of 'slave' instruments. But, I was banging my head against the wall for quite some time trying to get this code to work at all with event_i (plus i() wrapped k-rate parameters) instead
of the schedkwhen you now see. Would 'event_i' work well with 'midiin' if this code were somehow modified? I failed, anyway. Is it b/c midiin is krate, and won't ever play nice with irate stuff like event_i with i() parameters? I even tried init/reinit, but
maybe I didn't do it correctly....
instr 1 ;global MIDI instrument, calling instr X.nnn
kstat, kchn, kdata1, kdata2 midiin
;; for noteon and noteoff !!
if (kstat == 144) then
ktrig = 1
;; use key # 46 to trigger a drum instead of organ
if (kdata1 == 46) then
kbase = 10 ; instr 10 is a big drum sample
kadd = 0
else
kbase = 2 ; instr 2 is a synth organ
kadd = kdata1 * .0001
endif
;; we wrap pitch info into the instrument number this way:
kinstr = kbase + kadd
if (kdata2 > 0) then
schedkwhen ktrig, 0, -1, kinstr, 0, -1, kdata2
else
turnoff2 kinstr, 4, 1; then turn this instance off
endif
else
ktrig = 0
endif
endin
Aaron Krister Johnson
http://www.untwelve.org
|