Control Max with a Midi Controller using Javascript – Evolution UC-33e

Max can be connected to hardware midi devices by configuring midi control objects to exchange data with hardware like the UC-33e.

For this implementation the [ctlin] object is used:
Left outlet = midi device CC controller value
Middle outlet = midi device CC controller number

This CC data is channelled to the JavaScript API via message boxes, processed and sent to other patcher objects.


  1. Midi data sent to max
  2. JavaScript processes data
  3. Data passed back

JavaScript concatenation and iteration logic sends one message to multiple objects with different variable names.

Getting Midi data from Evolution UC-33e controller

The uc-33_midicontrol.pat fully implements connection between Max 5 and the Evolution UC-33 controller.

Place both [uc-33_midicontrol.maxpat] and [js uc-33.js] into the Max 5 directory and open the patcher.

Moving sliders and knobs controls UI objects and posts CC control names and values in the stderror.
Data is posted in the Max stderror. Data posts are created in the [js uc-33.js] object (using ‘post()’ method).


  1. [ctlin] controls midi input data and parses into two streams: CC number and CC value
  2. Data pairs are sent to message boxes [value $1] and [number $1]
  3. CC data messages are processed in JavaScript in [js] object
  4. Data sent to the patcher UI objects

Javascript file: js uc-33.js
inlets= 2;
outlets =2;

// automatically lock ctlin/out to UC-33 midi controller
var p = this.patcher;
var ctlNum;
var ctlValue;

var controller;

//executes first because [number] is on the right
function number(val)
            ctlNum = arguments[0];            //get the cc number of control
            controller = p.getnamed ("midictl" + ctlNum); //prepend cc number
                                            //'controller' is named patcher UI dial
            if (ctlNum >19 && ctlNum <28 || ctlNum == 116)
                post("control: "+ "SLIDER_" + "midictl" + ctlNum);
                post("control:"+ "KNOB_" + "midictl" + ctlNum);

//Executes second because on the left
//sends val to controller defined in [number(val)]
function value(val)
            ctlValue = arguments[0];        //get the cc control value    
            controller.message(ctlValue)    //send value to 'controller' dial
            post("value: " + ctlValue);
Max Patcher: uc-33_midicontrol.maxpat


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: