MIDI 2 OpenGL visualization
Introduction
This program was designed as a demonstration of how to integrate PortMIDI (external link) with OpenGL (external link) 3D visualizations. It takes MIDI input from the default MIDI Input port, outputs that data to the default MIDI output, and translates the note and controller data into various OpenGL parameters. It serves as an example for implementing PortMIDI, and basic OpenGL concepts such as GLU Quadrics and lighting. The OpenGL code is heavily referenced from the great tutorials at NeHe Productions (external link).The APIs implemented are as follows:
Parameter Implementation
The program was designed to be used with an Oxygen8 keyboard controller, so the notes and parameters used are as follows:
| Note C2 .. C4 | Individual size of corresponding sphere |
| Controller | |
| 1 | X-coord of spotlight |
| 7 | Y-coord of spotlight |
| 11 | Diffuse light: Red value |
| 12 | Diffuse light: Green value |
| 13 | Diffuse light: Blue value |
| 15 | Ambient light: Red value |
| 16 | Ambient light: Green value |
| 17 | Ambient light: Blue value |
For Oxygen8 users, these parameters correspond to the Modulation wheel, the data slider, and the 3 right-most rotary knobs in both rows.
To Use
Run midi2opengl.exe . The program relies on your default MIDI input and output ports being the ones you intend for input and output, so other setups will require re-coding in the openMidi function. To trigger the spheres, press C2 .. C4 on your MIDI input controller. The lighting characteristics are modified by the controller parameters listed above.As this is only a quick technology/interfacing demo, some re-coding might be necessary for this to run on your machine. As every MIDI I/O situation is different, you MAY need to change the IN and OUT parameters in openMidi to suit your specific setup. Run the test application packaged with PortMidi to determine the proper parameters to use with your system.
IMPORTANT NOTE! This program does not use threads for video and MIDI updates, and instead runs in an endless loop. Though this makes the code easy to read, it has the side effect of maxing your CPU at 100% usage. Take note of this fact when running the program - it won't harm your computer, but it will heat up the processor quickly!
Requirements
A PC running Windows 98+, a sound card or external audio device with MIDI inputs and outputs
Download
- midi2opengl (application + source)
Links
To Do
- Change OpenGL and MIDI polling to thread-based, to prevent maxing out the processor
- Add support for non-default MIDI devices
- Add support for more MIDI parameters: OpenGL rotation control, others(?)
- Change graphics to a time-based 3D "piano roll" that handles all note values

