Keyboard notes to Drum Pad notes translation

I wonder if it is possible in OSC to create widget like on my video to translate notes from keyboard to drum pads connected to DAW (im my case CUBASE 12).
Explanation: keyboard in OSC play notes (drum sounds) in the Cubase vst instrument. Pads below (button 1, button 2 etc) play the same midi notes as my drum pad (real machine) connected to the Cubase. But because I have only 8 pads I want to quickly to set chosen drum sound from keyboard to my drum pad. I woudlike to create quick translator for this. So I press keyboard in OSC to find correct sound, next I press pad (to select pad) and next I press again key with chosen sound on the keyboard to aply to pad . Is it possible ?

Open Stage Control v1.16.3 (My PAds.json) 2022-06-13 17-16-13

Hi,

Yes, it's possible, but quite tricky.
This is how it works:

  • press and hold the note you like to map on the keyboard;
  • press select_note button (the note number will appear in the label);
  • press and hold map_note button;
  • press the pad you want to assign the new note.

This is a basic approach and can be improved.
Pads can only send a fixed velocity. I've set it to 100.

EDIT: I forgot to mention that you need to change the midi port in the script of each pad

//...
  send("midi:yourMIDIPort", "/note", 1, value, 100)
} else send("midi:yourMIDIPort", "/note", 1, locals.playedNote, 0)

Hope you enjoy it.
drum_pad_mapper.json (17.9 KB)

Ok, here is an improved version. I'll keep the old post, so it can be a good study case, comparing to this new version.

Basically the workflow is the same, but this one is more concise and flexible, using the matrix widget. You can set how many pads you want just setting the quantity prop of the matrix and it automatically adjusts. Also, the MIDI configuration is much more friendly. Set all the parameters in the OSC section of the matrix, but keep it bypassed, because all the magic happens in the onValue script.

Have fun!
drum_pad_mapper_v2.json (6.7 KB)

Thank you for this. I don't know if I undrestant your solution well or my explanation was not too clear.
Here is what I have:


Real drum pad connected via midi to Cubase with vst instruments. I want to have quick translator from the vst keys of keyboard to my real drum pad. I choose drum sounds and I easy assing them to my drumpads. (On the picture is 8 pads, but I have also real midi drum with more pads and some more mashines with pads) . I see two difficulties in your OSC template. One is: How does are connected OSC pads with my real drum pads an how real drum pads react (respond) on tranlation made with OSC script ?
Second thing is: I forgot to write that I have one touch monitor (capacitive), so press and hold and press another at the same time rather falls off.
I checked it on my laptop with multitouch screen, but I dont know how to syncronize it with my real drum pads and I notice that in osc script "Keyboard" "ON" should be set "1" insted "127" , because Cubase react only from time to time when keyboard keys are pressed.

Sorry, now I've got it right.

So, it's a bit more complex than before, and it needs a custom module.

Instructions for this version:

  1. OSC
  • set the default prop of the midi_port_name widget variable to the MIDI port name to send note messages to Cubase (the port name is referenced in many places, so this makes it easier to set) ;

  • to map a note in the OSC drumPad, play a note on the keyboard; a button turns orange saying "map note"; press this orange button; now it turns green and says "press a pad"; do so and it's done (this approach avoid simultaneous touch on the screen);

  • now you need to set the start note of the note_hardware_transformer variable to match the starting note of your hardware pad. Go to its onCreate prop and change the 'startNote variable (default is 36);

  • copy the custom-module.js file to a folder of your choice;

  • in the OSC server gui, click the folder icon of the custom-module and select the previous file;

  • The custom module will handle the incoming notes from your hardware. I used my MPD232 to test it, so change the port name to your corresponding hardware. To do this, open the custom-module.js in any text editor:

//replace MPD232 to your hardware port name (between quotes)
...
if (address == "/note" && port === "MPD232") {
...
  1. Cubase
  • make sure Cubase is not receiving MIDI from your hardware drum pad, otherwise you'll get 2 notes. Go to Studio Setup > MIDI Port Setup and uncheck the box In All MIDI Inputs column. Alternatively, you can set the MIDI input port of your track to receive MIDI only from OSC.
  1. Files

drum_pad_mapper_v3.json (8.3 KB)
custom-module.js (367 Bytes)

what's inside `custom-module.js`
module.exports = {

    oscInFilter: function (data) {

        var { address, args, host, port } = data
        
        if (address == "/note" && port === "MPD232") {
            const note = args[1].value
            const vel = args[2].value

            receive("/SET", "note_hardware_transformer", note, vel )
        }
        return
    }
}

Hope I didn't miss anything ^.^

Hi, Thank you for your big help!
I still can't manage to stear my device Drumpad with osc widget drum pad. I don't know if I do everything ok?
I want to add info that my device drumpad ( DP-2000) have no possibility to change it's midi notes assigned to the pad. So Pad 1 has note 20, Pad 2 - note 22, Pad 3- note 24. etc.
My connection looks like this.

  1. I changed custom-modules.js and I wrote "HDP-1" instead "MPD232" : >>if (address == "/note" && port === "HDP-1")<<
  2. I changed osc target to: midi: oscboom (for both widgets: matrix drum pad and keyboard
  3. I don't see note_hardware_transformer in onCreate to change the 'startNote.
    onCreate
  4. What midi port should be used in Cubase to play/record from my Device (DP-2000)? I undrerstand that it should be the same what my OSC loopMIDI Port, but I can hear my device only via HDP-1 midi port . When I play on widgets Keboard or Matrix Pads I see reaction in the Cubase correctly, but not when I'm playing on my devce.
    Here are my connections

    I don't know what i'm doing wrong?

EDIT:
I noticed script "note hardware transformer" (sorry) , but I don't see reaction with my device still despite of startNote is changed to 20

Perhabs I don't understand this: set the default prop of the midi_port_name widget variable to the MIDI port name to send note messages to Cubase (the port name is referenced in many places, so this makes it easier to set) ; ?

EDIT2:
I see some of my mistakes, but still don't know why it not works with my device. First, of course, i did not see some of the scripts , because I did not have open PROJECT TREE :frowning:
Second: My midi port in osc server is named oscboom as you can see. So shoud I change it in the script midi_port_name like below on screen shot ?:
midi port name
But this way OSC not send any midi notes to CUbase and I have info in the OSC server (ERROR, MIDI) unknown device "oscCOMMON"

Oh, I forgot some vital information. Sorry about that.

So, MIDI ports. You'll need to configure 2 MIDI ports in OSC: one to receive notes from your DP-2000 and another one to send MIDI from OSC to Cubase. The way it works is: your DP-2000 device send notes to OSC; OSC transform and send them to Cubase.

(I'm answering based on your first reply, but I know you figured some things on your EDITs)

For this. I'd set up the midi prop in server like so:

HDP:HDP-1,-1 midiToCubase:-1,anyLoopMIDIPort

Note about this approach: using -1 as input/output bypass it. So in HDP OSC is not sending notes to your hardware and in midiToCubase OSC is not receiving from Cubase. Also, this avoid errors if any port is disconnected and change the port numbers.

This is not right. As I said before, change the value of the midi_port_name widget (find it in the tree). And now, it should be named after the new midi server configuration (in this example anyLoopMIDIPort)

The picture is showing drum_pad.onCreate. It should be note_hardware_transformer. Find it in the tree as well. It's a variable. But since your DP-2000 can't change the notes, use just this line of code instead:

locals.hardwareNotes = [20, 22, 24, 26, 28, 30, 32, 34]

The correct port name now would be HDP (the same name used in the midi server config)

Hope it works this time. Let me know if you have any issues.
Cheers

I don't know what I'm doin wrong still. Here are my files with changes:
drumPadMapper.js (364 Bytes)
KEY To DRUM test 3.json (8.4 KB)


midi port name

In Cubase no reaction. What midi port should react in the Cubase? loopMIDI Port ?
Why is it named anyLoopMIDIPort in the server - midi?

Sorry, this is meant to be any other midi port you were already using to send MIDI to Cubase. But keep it and create a loopMIDI port with this exact name.

Delete lines 1 and 2. Only line 3 is needed

I'm fighting, but nothig. I changed name of midi port in the loopMIDI to anyLoopMIDIPort, but OSC sending info: (ERROR, MIDI) unknown device "anyLoopMIDIPort" . I noticed also, that when I change value-default of midi_port_name from different name of port to anyLoopMIDIPort then server showing error with previous written name of port. To see change I have to write in the line value-value correct midi port name and only then server see error with correct port name even if I delete it from value-value and I will leave it only in the value-default.


OSC do not send notes outside when I play/touch keyboard widget or pads widget.
Should I give up :sob: ?

hi,

Welcome to headhache configuration hell :slight_smile:

  1. first create a loopMidi port named loopMidi-01

image

  1. then list the midi devices

image

  1. post a lovely screenshot here to help us to try to help you :slight_smile:

So
loop midi


I want to add what I noticed.
When I set on the server midi like this: anyLoopMIDIPort:14,15 Then OSC is sending notes outside (to Cubase)
also it works anyLoopMIDIPort:13,14 (but then notes go via loopMIDI-01)
it not works withloopMIDI-01:13,14
Of course I mean that it sent notes touching Keyboard widget or Pad widget only. We have to connect my device DP -2000 (HDP-1) still.

EDIT:
My current files:
drumPadMapper.js (364 Bytes)
KEY To DRUM test 3.json (8.3 KB)

Thanks for your lovely screenshot

Put this on the midi field :

HDP:11,-1 midiToCubase:-1, 15

you mix the loopMidi name and the name to be used by OSC (here HDP and midiToCubase)

Note that if you choose to use the port name listed, write it fully : loopMIDI-01 14 not only loopMIDI-01

Next, I think you have to set

image

Hope it helps you.


It does not work

oupsss i made a typo
so the good syntax is :

HDP:11,-1 toCubase:-1, 15

OK. Below It is correct:
HDP:11,-1 toCubase:-1,15
because of space after the last comma in your line.
Thanks a lot. It works with Keyboard and Pads widgets now.

I'm looking for now why it not works with my device DP-2000 ?
I don't know if the notes go to the OSC or go out from OSC when I hit the pads.
I don't know how to check if the midi notes go to OSC from my device? Anyway they don't go out
from the OSC when I hit pads on the device.

EDIT:
When my device port is open in the Bome MIDI Translator Pro (HDP-1) then I have such info in the serwer:
"(ERROR, MIDI) failed to connect "HDP" to input port 11
(ERROR, MIDI) Traceback (most recent call last):
*** File "midi.py", line 71, in ***
*** File "src/_rtmidi.pyx", line 589, in rtmidi._rtmidi.MidiBase.open_port***
*** File "src/_rtmidi.pyx", line 223, in rtmidi._rtmidi._cb_error_func***
*** File "src/_rtmidi.pyx", line 411, in rtmidi._rtmidi._default_error_handler***
rtmidi._rtmidi.SystemError: MidiInWinMM::openPort: error creating Windows MM MIDI input port.

But when I close this port in the Bome Midi Translator pro then all seems OK in the OSC server. (only I don't have reaction with my device )

you're right !
Cool it works for this part. Bravo @ClelsonLopes tu code this solution.
Next step :slight_smile:

If you hit your HDP-1, you should see inputs into the console of OSC.

I just checked but I don't see any reaction in the console:( Anyway I don't see also when I play/touch widgets, but in this case I see in the Cubase and in the Boome midi translator.

i suggest to resolve one issue separately.

What do you mean?