Cabbage Logo
Back to Cabbage Site

Instr1 runs all twelve midi tracks

I have problem with the instrument 1 runs all the midi tracks and the other instruments run nothing. I tried to assign to instruments and midi channels it did not change anything. Instr 1 and channel 1 runs all the music other channels and instruments was useless


This is the picture of midi channels.

This is the code that I used.

form caption("Untitled") size(400, 300), guiMode("queue"), pluginId("def1") keyboard bounds(8, 158, 381, 95) -n -d -a -F a5.mid --midi-key-cps=4 --midi-velocity-amp=5 ; Initialize the global variables. ksmps = 32 nchnls = 2 0dbfs = 1

;instrument will be triggered by keyboard widget
instr 3

idel = 0.5
knum = p3
kfreq line p4, p3, 440
asig shaker p5, p4, 8, 0.999, knum

adp delayr 1/100 // not used, sets max delay time (20 Hz min fo)
aks deltap3 idel // exact delay
delayw asig + (aks + delay1(aks))*0.1 // LP in feedback loop
outs aks, aks

endin

instr 1

ktotamp init p5
kamp1 init .5
kcps1 init 5
kamp2 init .4
kcps2 init 3.5
kamp3 init .5
kcps3 init 4.5
kj2 jitter2 ktotamp, kamp1, kcps1, kamp2, kcps2, kamp3, kcps3
kEnv madsr .1, .2, .6, .4
aOut vco2 p5+kj2, p4
aOut dcblock aOut
outs aOutkEnv, aOutkEnv
endin

instr 2
kEnv madsr .1, .2, .6, .4
aOut vco2 p5, p4
outs aOutkEnv, aOutkEnv
endin

instr 5

idel = 0.5
knum = p3
kfreq line p4, p3, 440
asig shaker p5, p4, 8, 0.999, knum

adp delayr 1/100 // not used, sets max delay time (20 Hz min fo)
aks deltap3 idel // exact delay
delayw asig + (aks + delay1(aks))*0.1 // LP in feedback loop
outs aks, aks

endin

;causes Csound to run for about 7000 years... f0 z

Hi @tfcaafhv, welcome to the forum. I don’t see massign used anywhere in your code. Therefore I’m wondering how you tried to assign instruments to various MIDI channels? Instrument 1 will play all notes coming in on midi channel 1 by default, unless you request otherwise.

Thanks for reply. I tried with the massign and ask a friend he told me you don’t need to use massign and I delete the code. But before I did with the massign. If I do massign 1,0 all sounds gone. My main problem is instrument 1 play all the midi channels 1 to 12. The other eleven instrument is useless. No sound at all. But if opened the midi file other apps there is twelve different channel. I tried with the reaper, pro tools, sibelius, logic and guitar pro. Midi file looks okey.

You can do this, which pretty much ensure that each instrument from 1-12 will only be triggered when messages are received from that channel.

massign, 1, 1
massign, 2, 2
massign, 3, 3
massign, 4, 4
massign, 5, 5
massign, 6, 6
massign, 7, 7
massign, 8, 8
massign, 9, 9
massign, 10, 10
massign, 11, 11
massign, 12, 12

Btw, reading MIDI files in a Csound instrument that is being loaded in a DAW seems odd. Why not simply load the MIDI file into a MIDI track in the DAW and then drop a Cabbage instrument onto it?

Thanks for reply. I need to use like this for my school project. It needs to be run in the cabbage or qt. I did that code already nothing changes. instrument 1 runs all the midi channels. And the other eleven instrument does nothing. if i put instr1 on the shaker all twelve channels run shaker. if i put instr1 vco2 all of them vco2.

Can you share the midi file?

a6.rar (1.5 KB)
Here is the midi file that I used. I couldn’t have upload as mid. Thank you very much

I just tried here and I am seeing the very same problems. It seems to me that Csound doesn’t parse the MIDI channel correctly. If you use the midiin you’ll see it reports all notes arriving on channel 1. When I load the MIDI file into Reaper, it shows a unique channel for each part. I’m not sure how you can get around this. I also created a simple MIDI track with notes output on 3 different channels. Csound still reports everything arriving on the same channel. It seems to me that reading MIDI files has never been much of a priority. reading real time MIDI on the other hand is spot on. Might be worth going back to your teacher and explaining the issues you’re having. FWIW, I’ve only been able to test on Windows. For all we know it might work fine on MacOS.

Thank you so much. I really appreciate your efforts to helping me. I am really glad. Thank you.