ofxPatchbay - to hookup parameters to different controllers

Available here

Let’s say you want to control the size of a rectangle that you defined somewhere (ofRectangle rect). Register a lambda function with the patchbay, giving it a human-readable name. The closure should accept a parameter value, which will be a float in the range [0,1]

patchbay.registerControllable1f("rect-size", [&] (float value) {
    rect.setHeight(100 * value);
    rect.setWidth(100 * value);    
});

Now you can connect the x-position of the mouse to the registered parameter:

patchbay.connect1f("mouse-x", "rect-size");

You can disconnect them like this:

patchbay.disconnect1f("mouse-x", "rect-size");

And hook it up to a MIDI controller:

patchbay.connect1f("midi-cc-10", "rect-size");

Or even audio:

patchbay.connect1f("audio-rms", "rect-size");

Installation

Define these objects in ofApp.h

ofxPatchbay patchbay;
ofxPatchbayInput input;

And add this line to ofApp::setup()

input.registerInputs(patchbay);

And call update() on ofApp::update()

patchbay.update();

2 Likes