Cabbage Logo
Back to Cabbage Site

Counting number of concurrent midi notes

Is there any opcode, or another way to count the number of concurrent midi notes playing?

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, :thinking:

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. :slight_smile:

cabbageMidiListener.csd (1.1 KB)

1 Like

The windows build is broken at they moment. I’ll check this out later…

@hdale94 A new build is underway, should work now for Windows too.

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.

1 Like

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. :muscle:

1 Like

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.