How can i change the MIDI-Channel...? The code-line "if messagechannel ==2:" don't work... What is the correct modification in "samplerbox.py" ?
Regards
Pete
How can i change the MIDI-Channel...? The code-line "if messagechannel ==2:" don't work... What is the correct modification in "samplerbox.py" ?
Regards
Pete
Hello again...
What must be changed in this code below, for using only one midi-channel in Samplerbox...?
def MidiCallback(message, time_stamp):
global playingnotes, sustain, sustainplayingnotes
global preset
messagetype = message[0] >> 4
messagechannel = (message[0] & 15) + 1
note = message[1] if len(message) > 1 else None
midinote = note
velocity = message[2] if len(message) > 2 else None
Kind Regards
Peter
Hi Pete,
You used the correct code-line. Possible pitfalls:
1)
The channel numbering: if you need channel 1 (default=keyboard), the test should be "..==1"; midi sends channel 1-16 as 0-15 in the protocol, hence the "...+ 1" in the code.
2)
Did you indent all statements following it (belonging to this if statement) ?
Python does not have an end-if, the if statements are regocnized by level of indentation, so you need to be precise with that.
I was able to get this working - I set a variable I called MIDI_CHAN = 14 in the LOCAL CONFIG section
then in the AUDIO AND MIDI CALLBACKS section I modified as below:
def MidiCallback(message, time_stamp):
global playingnotes, sustain, sustainplayingnotes
global preset
messagetype = message[0] >> 4
messagechannel = (message[0] & 15) + 1
note = message[1] if len(message) > 1 else None
midinote = note
velocity = message[2] if len(message) > 2 else None
if messagechannel != MIDI_CHAN: # These lines check the MIDI_CHAN variable and discard any messages
return # that don't match the channel
if messagetype == 9 and velocity == 0:
messagetype = 8