Help with alternating notes

Can any provide any guidance to a way to have incoming note on messages alternate between 2 MIDI channels?

1st note goes out CH1
2nd note goes out CH2
3rd note goes out CH1
4th note goes out CH2

Note offs will be sent out both channels to make it easier.

Thanks, Jeff

Please describe your use case. Maybe there are better ways to achieve your goal.

I will be sending midi from a controller (on MIDI channel 1) to two identical sound modules (MIDI channel 1&2).

I want to alternate the note on messages MIDI channel in order to effectively double the polyphony. Doing alternate notes will do this better than just setting a split point.

Note Off messages will be passed through to both modules to simplify the process needed.

What plugin? Many plugins allow you to adjust the maximum polyphony - at a cost of CPU cycles of course. How much polyphony do you need?

Two other possibilities

  1. Sample the sounds and play them back through a sampler - then you can have as much polyphony as you want

  2. Create a GP Scriptlet that would automatically distribute sequential incoming notes to different channels. Unfortunately, that’s something for which we can’t provide official support.

Hardware only live setup. No plugins or sampler.

I never used the MIDI Out block.

But, I would think, if you know the precise notes you want going out on the different midi channels, you can set up multiple Midi Out Blocks to each one has a key range of one note so it goes out on the channel you want. (There might be better ways to accomplish this, but this would be my first thought, specially since I am not “a scripter”).

I doubt it - he just wants to play and get double the polyphony regardless of what he’s playing

Then your only choice is a GP Scriptlet and it actually turns out to be very trivial.

Here’s a gig file demonstrating it - tweak for your own hardware

AlternatingChannels.gig.zip (9.0 KB)

1 Like

It’s a good thing that this scriptlet is trivial for you, because it’s still incomprehensible to my poet’s brain.
On the other hand, thank you for this scriptlet, which is already giving me several ideas for future uses.

1 Like

Thanks

I’ll check it out.

Did you look at it? It’s really pretty straight forward once you understand what’s going on. Here’s a commented version

The identifier channel is a variable that represents an integer value and it starts with the value 0

var
   channel : integer = 0         

This is the beginning of a “callback” event. For this particular case, the code here will be triggered whenever a Note On message arrives at the scriptlet

On NoteOnEvent(m : NoteMessage)

MIDI channels have to be between 1 and 16 but because we started with a 0 (for
reasons I will explain in a minute, we have to add 1 to the channel to make it be valid.
So the line here simply says, send out the Note On message that was received EXCEPT
add one to the channel number.

    SendNow( m.WithChannel(channel + 1))

The % character means to divide by some value and keep the remainder. People do this all the time with clocks. 13:00 is 1 (divide 13 by 12 and you get 1 remainder, divide 14 by 12 and you get 2 remainder)

So here, we now add one to the channel, divide by two and take the remainder. When you divide by two and take the remainder, the result can only be 0 or 1 so here, the channel alternates between 0 and 1. (Remember that when we send it out, we add one to the value so the actual channel sent out will alternate between 1 and 2)

    channel = (channel + 1) % 2   

This just says we have finished with the NoteOnEvent callback

End

Now we define another callback, this one will be called whenever a NoteOff is created, i.e. releasing a key on your keyboard.

On NoteOffEvent(m : NoteMessage)

Here we are declaring another variable, just like we did for the channel above but this time our variable represents a MIDI Note Message. We then assign it the incoming MIDI message but we change the velocity to 0. Actually, now that I write this, I realize we don’t need this line since the incoming message is already a Note Off (serves me right for writing the scriptlet too quickly — this declaration can be removed - it’s not even used)

var
   n : NoteMessage = m.WithVelocity(0)

This basically says, send out the incoming NoteOff message twice, but using channel 1 and then channel 2

   SendNow( m.WithChannel(1))
   SendNow( m.WithChannel(2))        
End

Does this make sense?

4 Likes

Dave, you crack me up!

I would like to thank you sincerely for your efforts in bringing these few lines within my reach, which are indeed very simple and accessible.
Unfortunately I have a real mental block that makes me find computer language off-putting, like many other things like mathematics, physics, etc., things that I don’t actually want to understand at all. And I’ve always found it very difficult to assimilate knowledge because of a lack of concentration and desire to learn.
And having to use an automatic translation into my mother tongue doesn’t help my desire to understand!

Dreams and imagination are my domains, and the efforts I make to use GP are the only ones I concede in order to be able to express my visions and impressions as best I can through music.

I’m a hedonist who stumbled across GP by chance and who does what he can with it (as little as possible, preferably).

Thanks again for all the time you’ve taken to try and interest me in this, and sorry for not reacting as you would have liked.

1 Like

To me music is all about emotions expressed using mathematics and physics :blush:

1 Like

I have a Scriptlet for this if you want to try it. You have to choose the polyphony per synth, the number of synths and filter out the output using MIDI constrainers:

Polyphony_dispatcher.gpfav (4.7 KB)

Please, tell me if it works for you…

1 Like

I haven’t understood how it works, the only Midi output I can see is that of the Polyphony dispatcher block and even connecting 3 different instruments to it has no effect.
Trying to understand all this wears me out very quickly, so I prefer not to insist.

I’ve just discovered by chance that the constrainers have a midi output ! (you have to put the mouse exactly at the furthest point of the circle to see it appear).
So I’ve intuitively worked out how to make the connections.
I feel a bit less stupid and I’m going to explore the possibilities, which seem all the more interesting thanks to the greater number of possible configurations.
Thank you very much!

Don’t tell me you’ve just discovered MIDI channels constrainers? :face_with_monocle: :grinning:

1 Like

I knew of their existence, but nothing more, as I’ve always used PizMIDI plug-ins for MIDI utility applications.
Now it’s one less third part plugin.