Learn creative coding writing simple programs

123. Controlling Processing using MidiBus, part 1

A MIDI controller allows us to change values by turning knobs, moving sliders or pressing buttons on a hardware device. This is a great way to explore visual effects without having to modify programs and re-start them multiple times.

In this episode we use the MidiBus library to receive Control Change messages from a MIDI device. Each message contains three numbers: the channel, which lets you distinguish between devices when you use more than one device, the number of the knob or slider (you probably want different things to happen depending on which knob or slider you touch), and the value, which indicates how much a knob is rotated, how far a slider is moved, or if a button is up or down.

In part 1 we do a simple program that draws either lines or circles depending on which knob we turn.

Tags: midi, controlchange, midibus, controller

Code editor

You can make changes to the code below. Then

Questions and comments

Try to stay close to the topic of this episode. Use the Processing forums for help with unrelated Processing projects (or hire me for help ;-)

To indicate that a word in your comment is code, use the `backtick`. Example
  Do `float` and `int` smell similar?
To highlight code blocks, use ```processing and ``` like this:
  void setup() {
    size(600, 600);