We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › Midi libraries and OpenGL
Page Index Toggle Pages: 1
Midi libraries and OpenGL (Read 923 times)
Midi libraries and OpenGL
Sep 13th, 2009, 9:27am
 
Hi,

I'm trying to draw some 3D graphics with OpenGL while using Midi controllers. Unfortunately, it seems that neither of the two libraries I'm using (ProMidi and RWMidi) like rendering with OpenGL. Although they work without a problem with P3D, I can't really do without the added speed and quality offered by OpenGL.

I've scoured discussion boards, but I didn't find anyone faced with that issue.
Any suggestions, anyone? any ideas where the problem might come from?

Cheers
Re: Midi libraries and OpenGL
Reply #1 - Sep 13th, 2009, 9:46am
 
I just realized that when placing all the drawing commands within draw() (as opposed to noteOn, or ControllerIn - these Midi specific handlers), the problem disappears...
Pardon me if I'm wrong, but I guess that's the only way to draw using OpenGL ??
Re: Midi libraries and OpenGL
Reply #2 - Sep 15th, 2009, 7:13pm
 
I'm making my own MIDI triggered/controlled app myself, it is drawed in OPENGL but the library I'm using is TheMidiBus.

You should use Midi controllers as boolean toggles and parameter control for the sketches.
If you have drawings triggered by a Note you can use a diferent approach, which is using the note to toggle a boolean variable and so toggle on and off the drawing algorithm.

So the drawing algorithm should look something like this:

Code:

void theDrawingAlgorithm() {
 if (thisAlgorithmBoolean == true ) {
   // Do some drawings
 }
}


Then you can call the algorithm from draw() like this.
Code:

void draw() {
 theDrawingAlgorithm();
}


your Midi event handler should be linked to the boolean varable. The boolean variable shoud be created before/outside setup(). When you pres the note the asignation should look like this

Code:

void your MidiEventHandler() {
 if (aSpecificNoteIsPressed) {
   thisAlgorithmBoolean = !thisAlgorithmBoolean;
 }
}


This means that the current state in the boolean variable will be inverted and assigned back to the variable.

It's even better if you abstract the code into classes and make those drawings objects, they become more versatile, you can create new objects onscreen and do lots of things with them different from just draw them.

Hope this is useful Smiley
Page Index Toggle Pages: 1