Midi Integrator‎ > ‎

Setting up Midi Integrator

Example uses:

A.  Pitch-Bending and modulation with a mouse

Suppose one wants to add pitch-bend and modulation controls to a regular keyboard.

To do so, one just uses a mouse, or even better, a touchpad or two:
             (see:
http://www.ergonomictouchpad.com/)

and plugs it in to a USB port, sticks it on your keyboard in a handy spot with velcro,. Then one fires up Keyboard Integrator (Keyint), maximizes Keyint to fill the screen, and that’s about it: one has a midi touchpad surface in easy reach.

By default x-cursor (side-ways) moves are converted to pitch-bend and y-cursor (up-down) to modulation signals and sent to the “Left” keyboard. Caveat it only works if your mouse cursor is over Keyint and the mouse is clicked on. I recommend making Keyint full screen for this.

B. More on Pitch-Bending and modulation with a mouse.

To change the mapping rules, one clicks on midiHID object within Keyint, and clicks on the “Coll” table object. By default it contains:

1, L C BND 0 1.0;

2, L C MOD 0 1.0; 

 

Where the first number of the row is the Human Interface Device (HID) input number:  1 is the mouse x-axis; and 2 is the mouse’s y-axis. Joysticks map to various manufacturer-defined numbers.

The mapping rule defined by the first row above is:

            HID input 1 (mouse-sideways) is:

·         sent to Left keyboard,

·         as a Command

·         to Bend-pitch, with offset 0 and multiplier 1.0)

Thus you can scale the amount of pitch bend the mouse causes by changing the “1.0”: making it 2.5 will increase it by 250%; and making it 0.25 will reduce it to 25%.

Changing the L to an R will change the pitch bend message to be directed at the “Right” instrument, instead of the “Left” one.

 

Setting up Keyboard Integrator

Simple setup

All inputs, whether from PC-keyboard, midi-keyboards (including note, control, or velocity), mouse, touch-pad, joystick or iPhone (planned), are converted to the same simple, human-readable instrument command.

Input translation

Each input delivers a simple key number, n, and sometimes an associated velocity,  v or a control amount, a. We translate the n, v, and a using table lookups to find the row that says what we really want that key to mean musically*.

Thus we can have the letter “D” on the PC-keyboard (keyboard key # 103 to the computer), map to midi note 60(“middle C” to you) on our “Left” instrument, using the row containing “103, L N 60;” in file KeyInt PcKeys Lefthand.txt.

This may sound complicated, but is easy to set up once (or copy an already set up table) and easy to fine-tune. Once done, it’s done, and with automatic table loading, you can set it up so that you plug in your devices to your netbook or computer, turn it on, and in 30 seconds begin playing.

For a variation on this, we can similarly map the space bar (key # -2 to the Max/MSP development system used to create this product) to the Command Sustain. The table entry is:

-2, L C SUS;    - this commands all notes played on the Left instrument to be held while the
                                space bar is held down.

And if you want your Right or both instruments to sustain when you hold down the space bar, you can have the following rows, respectively.

-2, R C SUS;    - cause the any note played on the “Right” instrument to be held

-2, B C SUS;    - cause the any note played on Both R & L instruments to be held

*HiD devices like the mouse, touchpad, and joystick are mapped to the key numbers 1 and 2, and we tweak the velocity a bit, but the principle is the same.

Instrument Command

 The conversion is configured by a simple set of instrument command tables that can be edited and tweaked easily. To make things simpler, tables can be shared amongst musicians, so that cool setups can be refined and enhanced.

Instrument Command breakdown

This instrument command contains a blend of information; it contains all the information of the input, and can be enhanced by other inputs. It is set to the desired instrument (or all instruments), which read(s) it and performs it.

Instrument Command breakdown

The instrument command contains 3 essential parts: Destination instrument(s), Instrument command Type, and details that depend on type.

Destination Instrument

For convenience, the destination instrument is called the Side, and I’ve mapped to the concepts Left and Right, use the letter codes “L” and “R” in my tables. At least 2 more instruments are available, and I call them Left-extension and Right-extension, or “Lx” and “Rx” (note capitalization) for short. The letters picked are to make this human friendly; the program does not care, but the capitalization must match. If it does not, a message will display in the Max/MSP log.

Concept

Instr. Code

Result

“Left” instrument, or instrument 1

L

Routed to Keyboard integrator’s “Left” instrument, which deals with it in various ways and sends it to the midi output ‘l’ (lower case L)

“Right” instrument, instrument 2

L

 “Right” instrument processor, tweaks it & sends to the Max/MSP midi output ‘r’

Extra instrument 3

Lx

Extra  “Left” instrument, sent to midi output ‘m’

Extra instrument 4

Rx

Extra “Right” instrument processor, tweaked & sent to midi output ‘s’

Command Type Details

Once the instrument command gets to the virtual instrument, it must get acted on. The next consideration is the command code type. The command code types thus far are:

·         “N” – Note

·         “C” – instrument instruction/command

·         “P” for triggering preset action, currently, just loading a new set of tables.

Once routed to the right spot in our virtual instrument, the command get done.

Note Creation

The “N” (Note) command is pretty simple: it gets mapped to a note value, and the velocity (which may also have been tweaked) gets added on. In addition, for future use, I add on a value called the Accent, currently just kept at the value of 64. The velocity of a note originating at the PC-keyboard has a default of 64, but this is adjustable with a little slider.

Here’s a sample of the file KeyInt PcKeys Lefthand.txt I use:

101, L N 61;      (e mapped to C#)

103, L N 60;      (g mapped to middle C)

104, L N 62;      (h mapped to D)

Command interpretation

The “C” (Command) instruction is more complex: it has a number of possible 3-character mnemonics,

Command

Effect

 

MOD m*

Modulate by amount m*

m*=number from -16384 to +16383, 0 = no modulation

BND  b*

pitch-bend by amount b*

b* =number from -16384 to +16383, 0 = no bend

CC   x* y

raw Channel Control message

see midi documentation

 

 

x* = channel  command
(does not have to be the same as input CC value).

 

 

y = value from 0 to 127, 64 can mean 0
note: output is the same as the input cc value

FLU -

Flushes this instrument’s notes

any following parameters are ignored

SUS -

Sustain this instrument’s notes

any Following parameters ignored

 

 

 

OCT xxx

xxx = UP1 UP2 DN1 or DN2

Shift the instrument Up or Down this amount,   in octaves

OCT n

n = 2   1   0   -1   or  -2

Shift the instrument to this relative octave

CHA xxx

xxx = UP1 UP2 DN1  or  DN2

Shift the instrument channel this amount

CHA n

n = 1 through 12

Shift the instrument to this channel

KEY xxx

xxx = UP1 UP2 DN1 or DN2

Global - Shifts the instrument Up or Down this amount, in semitones

KEY n

n = 2   1   0   -1  or  -2

Shift the instrument to this relative key:

e.g. 1 shifts C to C#

 

 

 

RST n

Planned for future

Global Reset

 

Note: some of the commands above have an additional Offset and Multiplier parameter which can allows us to adjust the mapping factor. For example, allowing a mouse movement conversion to a pitch bend to be controlled.

Preset

The Preset is largely for the future. If I have the time, I will have it switch the loaded tables. Presets planned are:

·         1 – load Table set 1 - KeyInt Axis49 Righthand.txt

·         2 – Load Table set 2

O   P    1

O P 1  vel* acc*

Overall  Preset 1 fires – loads table set 1

 

 

Tables … listed here

O   P    2

O P 2  vel* acc*

Overall  Preset 2 fires – loads table set 2

 

 

 

 

Input mapping

Mapping the PC keyboard to midi

The subroutine, called a patcher is called MapPCKeys. Double click on it to see it.

Layout: the red items are the tables that can be loaded.

Double-Click on the “coll ‘KeyInt PcKeys Lefthand’ “ item to open it and see the rows it contains. You may edit it and save it. Warning: you must get the format exactly right, of Max/MSP will blank out the table. Watch to include the comma and the semicolon in the right place.

Coll is short for ‘Collection’; this is a collection of rows.

Click on the “read” items to load a new table into the “collection” – it won’t warn you, it will just do it.

The blue slider sets the volume of midi notes created by this routine.  Default is 64.

Of huge usefulness to setting up the midi conversion the way you want it is the blue area.

It shows what key you’ve struck, the internal code number that Max/MSP and I like - it ignores shifting, the effect of caps-lock, ctrl buttons and alt keys, and other stuff that might distract from the production of music. – imagine that you are in a concert and press the cap-lock in the excitement; it’s not a good thing for all your keys to instantly stop working! - With this mapping, a key’s value is consistent.

To adjust the mapping, note down what key maps to what index value, eg. Page-Down & Page-Up maps to -14 and -13, respectively.

In the table of your choice, insert your new mapping:

Old:

-18, L C CHA UP1; (F2 maps to Left instrument channel up 1)

-17, L C CHA UP2; (F1 è to Left instrument channel up 1)

-3, L C FLU; (Esc è to Left instrument Flush note)

-2, L C SUS; (Space-bar è to Left instrument Sustain notes)

added:

-18, L C CHA UP1; (F2 maps to Left instrument channel up 1)

-17, L C CHA UP2; (F1 è to Left instrument channel up 1)

-14, O C KEY DN1; (F1 è to Overall instruments shift DowN 1 semitone)

-13, O C KEY UP1; (F1 è to Overall instruments shift UP 1 semitone)

-3, L C FLU;      (Esc è to Left instrument Flush note)

-2, L C SUS;      (Space-bar è to Left instrument Sustain notes)

Note that the rows can be in any order, but ascending makes it easy to find a value

How the mapping works

It’s pretty straightforward: the value of the pressed key’s index number, say -13 for PageUp, gets looked up in the table, which looks at the number before the comma.  If an row is found, everything after the comma and optional space up to the semi-colon “;” is scooped up and becomes the midi message.

 Side note: text after the semi colon confuses Max/MSP, so you can’t put in comments like above, alas.

The scooped-up part gets the velocity and accent values (with default values of 64) stuck on as a suffix, and the hold message gets sent out the MapPCKeys outlet, thus a Page-Down press gets converted to:
                “O C KEY DN1 64 64”.

The two 64 64 (velocity and accent) is ignored – they are for when you map the keys to a N(ote) command.

Remapping Midi Keyboards

The subroutine, is called MapKeyBoard??. Double click on it to see it.

Layout: the red items are the tables that can be loaded.

Double-Click on the “coll ‘KeyInt Axis49 Righthand’ “ item to open it and see the rows it contains. You may edit it and save it. Warning: you must get the format exactly right, or Max/MSP will blank out the table. Take care to include the comma and the semicolon in the right place.

Coll is short for ‘Collection’; this is a collection of rows.

Click on the “read” items to load a new table into the “collection” – it won’t warn you, it will just do it.

The blue slider sets the volume of midi notes created by this routine.  Default is 64.

Of huge usefulness to setting up the midi conversion the way you want it is the blue area.

It shows what key you’ve struck. So, to adjust the mapping, note down what key maps to what index value,  eg. Middle C on a keyboard maps to the number 60.

In the table of your choice, insert your new mapping:  

Old:

11, L N 11;       (we translate the note to itself)

12, L N 12;      

13, L N 13;      

14, L N 14;      

New:

11, R N 11;       (we translate the note to itself)

12, R N 12;      

13, O C KEY DN1;  (F1 è to Overall instruments shift DowN 1 semitone)

14, O C KEY UP1;  (F1 è to Overall instruments shift UP 1 semitone)

Note that the rows can be in any order, chose a system makes it easy to find a value.

Remapping  Midi Controls

The subroutine for this is Map???. Double click on it to see it.

Layout: the red items are the tables that can be loaded.

Double-Click on the “coll ‘KeyInt ??’” item to open it and see the rows it contains. You may edit it and save it. Warning: you must get the format exactly right, of Max/MSP will blank out the table. Watch to include the comma and the semicolon in the right place.

Coll is short for ‘Collection’; this is a collection of rows.

Click on the “read” items to load a new table into the “collection” – it won’t warn you, it will just do it.

In the table of your choice, insert your new mapping:

. By default it contains:

1, L C BND 0 1.0;

2, L C MOD 0 1.0; 

 

Where the first number of the row is the Human Interface Device (HID) input number:  1 is the mouse x-axis; and 2 is the mouse’s y-axis. Joysticks map to various manufacturer-defined numbers.

The mapping rule defined by the first row above is:

            HID input 1 (mouse-sideways) is:

·         sent to Left keyboard,

·         as a Command

·         to Bend-pitch, with offset 0 and multiplier 1.0)

Remapping  HID input to Midi

The subroutine for this is Map???. Double click on it to see it.

Comments