[Csnd] Curious Midiin behaviour

I was checking out the midiin opcode and ran into something I don’t quite understand. When I play multiple notes, each new note on adds another event to the stream… In this output there are 5 noteon events followed by 5 noteoff events… But with each added note, there are multiple lines printed, the first note prints one, the second note prints two, etc. And then with each note off, it prints a line for each note still holding and the note just released. I attached the program…

status: 144 channel: 1 d1: 57 d2: 117
status: 144 channel: 1 d1: 59 d2: 94
status: 144 channel: 1 d1: 59 d2: 94
status: 144 channel: 1 d1: 60 d2: 85
status: 144 channel: 1 d1: 60 d2: 85
status: 144 channel: 1 d1: 60 d2: 85
status: 144 channel: 1 d1: 62 d2: 98
status: 144 channel: 1 d1: 62 d2: 98
status: 144 channel: 1 d1: 62 d2: 98
status: 144 channel: 1 d1: 62 d2: 98
status: 144 channel: 1 d1: 64 d2: 69
status: 144 channel: 1 d1: 64 d2: 69
status: 144 channel: 1 d1: 64 d2: 69
status: 144 channel: 1 d1: 64 d2: 69
status: 144 channel: 1 d1: 64 d2: 69
status: 128 channel: 1 d1: 57 d2: 0
status: 128 channel: 1 d1: 57 d2: 0
status: 128 channel: 1 d1: 57 d2: 0
status: 128 channel: 1 d1: 57 d2: 0
status: 128 channel: 1 d1: 57 d2: 0
status: 128 channel: 1 d1: 59 d2: 0
status: 128 channel: 1 d1: 59 d2: 0
status: 128 channel: 1 d1: 59 d2: 0
status: 128 channel: 1 d1: 59 d2: 0
status: 128 channel: 1 d1: 60 d2: 0
status: 128 channel: 1 d1: 60 d2: 0
status: 128 channel: 1 d1: 60 d2: 0
status: 128 channel: 1 d1: 62 d2: 0
status: 128 channel: 1 d1: 62 d2: 0
status: 128 channel: 1 d1: 64 d2: 0

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

midiin_test.csd (716 Bytes)

it looks for me that you have multiple instances of your instr 100. if this is the case, each of them will output.

i think it will be better to have only one instance of midiin in an always-on instrument.

OK, but how are the extra instances of instr 100 getting started? I’ve only got one reference in the score.

Also, I changed the instr by starting it with “alwayson” in the orchestra, but it still gives the same output, for each additional noteon, it prints an extra line of output.

Thanks,

Mike

i think it is started by your midi keyboard.
you can avoid it by writing
  massign 0, 0
after the header.

Thank you, joachim! I guess I didn’t understand how this worked. I thought I suppressed the incoming midi being automatically fed to an instrument. Adding the “massign” did eliminate the multiple instances. I guess that was how there were multiple instance of 100.

Thanks,

Mike

yes each midi note event by default triggers the first csound instance. so another way to get rid of the multiple instances should be to put an empty instr 1 in the code.

i personally never use the midiin opcode when i work with midi notes because it is so handy to pipe the note events to any instrument and then distribute them.

I do the opposite of Joachim (at least in my Implication Organ instrument): I want to handle MIDI messages manually, so I use “massign 0,0”.

I wasn’t looking at midiin because of notes, but it seems to be the only way to capture any pitch bend events unless there is an active midi event. You can read the controllers without there being an event, but there isn’t an opcode that does the same thing for pitch bends. I am hoping to capture the pitch bend info so that I can use it to control the pitch of an automated series of events.

And after playing with the midiin opcode, it has given me some ideas about how to rework one of my projects, but that will have to wait so that I can at least get something working now!!!