Loading...
Logo
Processing Forum
So I wanted to start a discussion to get a feel if many people here use Midi keyboards or joysticks to adjust parameters in their sketches?

I have just been using themidibus library and a gamepad library to create a simple controller class for my M-Audio Oxygen 8 keyboard & Logitech Wireless Rumblepad 2, but this seems to be an area that might be better suited for a specialized library that could support several different types of keyboards. Is there something like this that already exists? 

I've read a little about Open Sound Control, but it doesn't sound like this is what I'm talking about.

If there isn't a good alternative out there right now, I'd consider writing the library as it seems like it could be really useful. I'd need some help figuring out the correct mappings for various keyboards and controllers I don't own, though this would probably just be saved in a series of XML files so it's easy to update.

I'd also be interested in hearing other's use-cases for a library like this. One situation I can think of would be for VJing. Using something like the Mother library and writing simple sketches that bind their dynamic parameters and events to key presses and knobs, a VJ artist could queue up sketches and control them real time with the keyboard or joypad. 
In this case however it would be important for the variables to not be bound to any particular key, knob, or slider, and it would be helpful if they could be dynamically assigned to their physical counterparts based on what two sketches are currently active.

This is just a snippet, but It could possibly work something like this:

Copy code
  1. void setup()
  2. {
  3.   controllerLib = new VarController(this);
  4. }

  5. void controlChange()
  6. {
  7.   spotLoc.set( controllerLib.getFloat( "Spot location on X axis", -1.0, 1.0 )
  8.              , controllerLib.getFloat( "Spot location on Y axis", -1.0, 1.0 ) );

  9.   spotRot = controllerLib.getInt( "Rotation", 0, 7 );
  10. }
  11. void controlEvent()
  12. {
  13.   if     ( controllerLib.isEvent( "Next Color Palette"     ) ) nextPalette();
  14.   else if( controllerLib.isEvent( "Previous Color Palette" ) ) prevPalette();
  15. }


It could be fast enough to use strings if mapped a special way:

I would call controlEvent() and return false for every isEvent()callback registering the event name and mapping it to it's call index. Because following this pattern the calls would always happen in the same order, when real events come in I could just call controlEvent() and return false in isEvent() incrementing a counter and only returning true when that counter is equal to the call index of the registered event.

I would do the same for  controlChange() in getFloat() and getInt(), registering the variable names and min/max values passed in to their call index.

This way, I don't have to do any string comparisons at run time and the library would know what each variable is called by an easily understandable description that could be passed to another connecting tool.

The only remaining question is how one would dynamically map the events and variables to knobs, keys and joypads. What I'm picturing here is a separate tool you can open, kind of like how the serial window works in arduino, that would list all the different available events and variables on one side and controllers on the other side. Then the user could drag arrows to map keyboard notes to events and sliders/knobs to variables.

Any other thoughts / ideas?

Jack

Replies(2)

I've done some small experiments, which you can read about here:

http://www.creativeapplications.net/processing/nanokey-experiments-processing-sound


I would definitely like to take this further once I get to it again (working on other stuff right now). As an input device for Processing sketches I feel a midi keyboard has some big advantages. Such as easy simultaneous input, logical order from low to high, tapping strength, works well with audio applications, somehow a more performance feel than with regular input devices and one very basic: a lot of extra keys! Right now I haven't reached the boundaries of what's possible with midibus as I've really only done one fairly straightforward experiment. So I couldn't say what I personally would like to see in a library as you are talking about. But I am interested in what ideas you have and want to develop.
Thanks for your quick response amnon, I really like that visual you made!

I was hoping to hear from a few others as well, but I think I'll move building this library up to the top of my "to do in spare-time list." Right after I finish up my latest update to my caffeine library.