ProgramChange to Switch Instrument?
Started by cforster




4 posts in this topic
cforster

4 posts 2 threads Joined: Jun 2021
19-06-21, 15:32 -
#1
Hello (Again) Folks,

If I use the web interface, I can change instruments to those in the Samples directory. I can't, however, change from my midi controller.

I am using an Akai MPK Mini mk3. There is. "Prog Change" toggle button; after pressing that button, the drumpads send "Prog Change" messages. I used the midimon program to check. Here are what the drum pads send when Prog Change is not pressed; and then when it is (in green):


Quote:Started /dev/ttyAMA0 as MIDI device "SERIALPORT"
Opened SERIALPORT for MIDI OUT
Listening on SERIALPORT for MIDI IN

..sensing MIDI ports except serial/UART (dealt with above)..
MIDI in:
  - MPK mini 3 24:0
MIDI out:
  - MPK mini 3 24:0
Open "MPK mini 3 24:0" as MIDI IN 1 
"MPK mini 3 24:0" (3 bytes) Channel 10, NoteOn 36=C2, velocity=38
"MPK mini 3 24:0" (3 bytes) Channel 10, NoteOff 36=C2, velocity=0
"MPK mini 3 24:0" (3 bytes) Channel 10, NoteOn 37=C#2, velocity=25
"MPK mini 3 24:0" (3 bytes) Channel 10, NoteOff 37=C#2, velocity=0
"MPK mini 3 24:0" (3 bytes) Channel 10, NoteOn 38=D2, velocity=23
"MPK mini 3 24:0" (3 bytes) Channel 10, NoteOff 38=D2, velocity=0
"MPK mini 3 24:0" (2 bytes) Channel 10, ProgramChange 0 (=1 for humans)
"MPK mini 3 24:0" (2 bytes) Channel 10, ProgramChange 1 (=2 for humans)
"MPK mini 3 24:0" (2 bytes) Channel 10, ProgramChange 2 (=3 for humans)


So it looks like it the controller is sending the right messages? Is there something I need to do get SamplerBox to recognize that signal?

(I've read about keynotes.csv, but I don't understand its relevant for ProgChange messages; and, to be honest, I've had trouble even getting the pads to register in any capacity.)

Thanks in advance.

Chris
hansehv

168 posts 17 threads Joined: Dec 2020
19-06-21, 23:13 -
#2
Hi Chris,
New possibilities at the horizon ..  Idea
There is quite a complex way to translate the note-on / note-off on channel 10 (the drumpad) into control changes and program-up/downs. It's in the docs when reading creatively, but I'm not going to explain now - please read on....

As you state: it sends the right messages. But on the wrong channel.
And I made the drumpad exception for notes only, because I didn't know keyboards existed with this double use of the drumpads, but still having the fixed channel=10 (that's the culprit, I can reprogram the pads on my keyboards to any channel and send any message).
But shortcomings can be repaired....

In the samplerbox.py from line 891 next lines can be changed:
Code:
    elif gv.drumpad:  # using less compact coding in favor of performance...
        if messagechannel==DRUMPAD_CHANNEL:
            if messagetype==8 or messagetype==9:        # We only remap notes
                for i in xrange(len(gv.drumpadmap)):
                    if gv.drumpadmap[i][0]==message[1]:
                        message[1]=gv.drumpadmap[i][1]
                        messagechannel=0
                        break       # found it, stop wasting time
into:
Code:
    elif gv.drumpad:  # using less compact coding in favor of performance...
        if messagechannel==DRUMPAD_CHANNEL and messagetype in [8,9,12]:
            messagechannel=0
            if messagetype in [8,9]:        # Remap notes if necessary
                for i in xrange(len(gv.drumpadmap)):
                    if gv.drumpadmap[i][0]==message[1]:
                        message[1]=gv.drumpadmap[i][1]
                        break       # found it, stop wasting time
I hope I didn't make a silly mistake and you are able to make this change..
No problem if you cannot do this yourself: then please send me a PM, so we work out a way working that's OK for you.
Please feedback result!
I'm even considering to include message==11 (CC), but have to think about the consequences versus chance such keyboards exist...
Hans
This post was last modified: 19-06-21, 23:15 by hansehv.
cforster

4 posts 2 threads Joined: Jun 2021
20-06-21, 17:39 -
#3
So, I added the code provided, but it doesn't appear to change anything. Indeed, I don't believe the changed code is ever run. 

To test, I added a print statement immediately after elif gv.drumpad: (line 893, or maybe 892... I added a line), and it never got printed.

I added some more print statements, and it seems like gv.drumpad is set to false, so the altered elif block isn't running. I printed out mididev, message, gv.MULTI-TIMBRALS, gv.MIDI_CHANNEL, and dv.drumpad. When the program change toggle is on, message is a two digit number; otherwise the drumpad sends a list with three numbers. I'll paste the output of my debugging print statements below, but I worry a little that in tinkering with config files, maybe I changed something that is preventing the drumpad now from being recognized properly. I don't think so... but I'm not sure. 

I'll return to the docs to see if I can come up with a way to map drumpad to PROGRAM change. I think I am being hampered by being a complete MIDI newb, and so the difference between a note and a CC, etc, is a little tricky to follow.

Thanks,

Chris

Debug statements produced by:


Quote:print '%s -> %s' % (mididev, message)

print 'gv.MULTI_TIMBRALS: %s' % (gv.MULTI_TIMBRALS)
print 'gv.MIDI_CHANNEL: %s' % (gv.MIDI_CHANNEL)
print 'gv.drumpad: %s' % (gv.drumpad)


MPK mini 3 24:0 -> [153, 36, 97]
gv.MULTI_TIMBRALS: {'': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'Midi Through:Midi Through Port-0 14:0': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'Midi Through 14:0': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}
gv.MIDI_CHANNEL: 1
gv.drumpad: False
MPK mini 3 24:0 -> [137, 36, 0]
gv.MULTI_TIMBRALS: {'': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'Midi Through:Midi Through Port-0 14:0': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'Midi Through 14:0': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}
gv.MIDI_CHANNEL: 1
gv.drumpad: False
MPK mini 3 24:0 -> [201, 0]
gv.MULTI_TIMBRALS: {'': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'Midi Through:Midi Through Port-0 14:0': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'Midi Through 14:0': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}
gv.MIDI_CHANNEL: 1
gv.drumpad: False
hansehv

168 posts 17 threads Joined: Dec 2020
20-06-21, 19:05 -
#4
(20-06-21, 17:39)cforster Wrote:  ..it seems like gv.drumpad is set to false, so the altered elif block isn't running...
Hi Chris,
That's right, didn't think of mentioning / questioning this in my last post, sorry for that  Blush

The gv.drumpad is set when there is a note remapped like drumnote.
And I assumed you had some notes mapped as drumnotes (using the third "Optional drum column ).

For the testing it will work when changing elif gv.drumpad: into a plain else:.
You will now also hear notes if you play your drumpads as normal pads.

To make a long story short: this is a quick'ndirty fix, so if this works I'll write a a permanent fix, because above creates side effects that&should can be avoided.

Thanks for this feedback and regards, Hans
hansehv

168 posts 17 threads Joined: Dec 2020
03-11-21, 23:09 -
#5
(20-06-21, 19:05)hansehv Wrote: The gv.drumpad is set when there is a note remapped like drumnote.
I'll write a permanent fix

Hi Chris,
It's in the new release (in beta, to be published before year-end).
Drumpad behavior will be controlled from the configuration.txt only.

Two extra options are added for (not) allowing program changes and control changes (CC-messages). 
This was needed, because setting them on is typical for integrated pads, while external drumpads should typically have them off. Since "typical" isn't absolute, I refrained from autodetecting.

Forgot to feedback as the new release is an extreme make over to get the system more up2date (e.g. PI4 support) and this was "just" one of the improvements piggy backing on the migration  Rolleyes
Hans
This post was last modified: 03-11-21, 23:10 by hansehv.