kstatus -- status byte of MIDI message to be delayed
kchan -- MIDI channel (1-16)
kd1 -- first MIDI data byte
kd2 -- second MIDI data byte
kdelay -- delay time in seconds
Each time that kstatus is other than zero, mdelay outputs a MIDI message to the MIDI out port after kdelay seconds. This opcode is useful in implementing MIDI delays. Several instances of mdelay can be present in the same instrument with different argument values, so complex and colorful MIDI echoes can be implemented. Further, the delay time can be changed at k-rate.
Examples
Here is an example of the mdelay opcode. It uses the file mdelay.csd.
<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform; Audio out Audio in No messages-odac -iadc -d -M0 -Q0
</CsOptions><CsInstruments>sr=44100kr=4410ksmps=10nchnls=2; Example by Giorgio Zucco 2007instr1;Triggered by MIDI notes on channel 1kstatusinit0ifundnotnumivelvelocnoteondur1,ifund,ivel,1kstatus=kstatus+1idel1=.2idel2=.4idel3=.6idel4=.8;make four delay linesmdelaykstatus,1,ifund+2,ivel,idel1mdelaykstatus,1,ifund+4,ivel,idel2mdelaykstatus,1,ifund+6,ivel,idel3mdelaykstatus,1,ifund+8,ivel,idel4endin</CsInstruments><CsScore>; Dummy ftablef060</CsScore></CsoundSynthesizer>