Is there any opcode, or another way to count the number of concurrent midi notes playing?
Counting number of concurrent midi notes
No opcode I’m aware of. you’ll just have to keep track of these yourself. It wouldn’t be a difficult opcode to write. Hmm,
I just pushed a new midi opcode, well a pair of them actually. cabbageMidiSender
and cabbageMidiListener
. You can see how they work below. It should give you all the info you need. It also makes it simple to build an arpeggiator.
cabbageMidiListener.csd (1.1 KB)
The windows build is broken at they moment. I’ll check this out later…
https://csound.com/docs/manual/active.html
While it’s actually counting the number of instances of an instr that are active, I’ve seen people use it to write midi controllers, using it to detect when all the keys (midi notes) have been released.
Thank you both, these are really useful.
You should check out Iain McCurdy’s collection of midi instruments. He’s got a wealth of valuable techniques using ‘active’.
That reminds me, Iain has some new instruments. I must grab them and get them into the examples.
Could you give a short explanation of cabbageMidiListener
and cabbageMidiSender
, à la Csound-manual?
I haven’t written a manual page for them just yet, but I thought the example I posted was fairly detailed? Put cabbageMidiSender
in an instrument that will receive midi. Add a cabbageMidiListener
to an always on instrument that doesn’t receive any midi data. It will listener and output all midi messages sent to any instruments with a cabbageMidiSender
opcode.
Feel free to ask for help with it. I’ll try to write up a man page for them shortly. I was just waiting for them to get some testing first.