Tag Archive for 'Control'

Controlling a Mouse with a MIDI Controller

I’ve been doing a lot of editing of large documents recently and some of them require lots of scrolling in either horizontal or vertical directions. Scrolling vertically is pretty easy thanks to my Logitech MX Revolution, which has an inertial scroll wheel — quite possibly the best invention ever. But quickly scrolling horizontally is basically impossible because it just has a rocker.

I glanced over at my MIDI controller and thought that it would be pretty great if I could use it to emulate scrolling. The Numark TotalControl has two jog wheels that can spin freely in an inertial manner.

I then discovered PyMouse and PyGame’s MIDI module. Using these two libraries, I cooked up this example, which uses the left wheel to scroll vertically and the right wheel to scroll horizontally.

The script simply initializes and finds a suitable MIDI controller. Then, it connects to that controller and periodically polls to see if there have been any events. If so, it processes the event to see if it’s something to scroll with. I implemented an overly-simple “low pass filter” which doesn’t even take advantage of the fact that the TotalControl outputs a number that increases as you scroll faster on the jog wheels, but it works well enough. Future iterations will have more complicated algorithms. Theoretically, this script is cross-platform since the libraries it uses are.

At any rate when you run this script, you can use the jog wheels to scroll. You need to patch PyMouse though. The developer forgot to include support for horizontal scrolling, but this patch changes a whopping two lines to add it (in reality, all of that code needs to be redone because it isn’t very well designed, but I’m lazy).

I’m sure MIDI mappers have been made before, but I’d like to make one where you can just script the controller in Python. You would just register a bunch of hooks (functions based on controller and control number) with calls to whatever functions you want to design. A project for when I’m bored and without internet access, I guess.

Numark Total Control and M-Audio X-Session Pro Mappings for Mixxx

Mixxx’s MIDI scripting engine is amazing. It lets you customize your MIDI controller to a level lower than almost every other DJ software.

A while ago, I made a pretty complex mapping for my M-Audio X-Session Pro. Buttons can perform different actions based on context. For example, holding the headphone button and then pressing another button will perform a different function than just pressing that button in the first place. If you press the headphone button without pressing another button, it will act as a normal PFL toggle button.

I then bought a refurbished Numark Total Control. It has lots of controls and status lights. The existing mapping that was in Mixxx was a bit old, so I decided to write a completely custom mapping. This mapping has a variety of interesting features. Buttons generally have two functions (press the “Key” button to activate the other function). There’s some good looping and hotcue support in there too. Furthermore, depending on whether you have vinyl control enabled or not, some of the controls will behave slightly differently to maximize functionality.

There’s a full table of the features on my Mixxx project page.

Lastly, I started designing a mapping for the X-Session Pro that would allow it to act as an auxiliary controller. This mapping primarily uses all of the buttons as hotcues, again with left and right shift buttons. It also has hotcues for the sampler. There’s a table describing all the features on the page.