Game Controller MIDI

June 20th, 2018
music
Expression controllers can make synthesized instruments sound much better, but they're generally pretty expensive. For example, the breath controller I've been playing with cost me EUR 132. There's nothing fundamentally expensive about it, just a low volume product. Which got me thinking: is there some commonly mass produced device that gives a smooth range of outputs? What about a game controller?

I've never been into console gaming so I don't know much about controllers, but after looking at some pictures it looked like the PS4 one is well laid out for joystick use, so I ordered one ($26, shipped):

It connects via USB, and pygame can read from it out of the box:

>>> import pygame
>>> pygame.init()
(6, 0)
>>> j = pygame.joystick.Joystick(0)
>>> j.init()
>>> while True:
...   for event in pygame.event.get():
...      print(event)
...
<Event(7-JoyAxisMotion {
  'joy': 0,
  'value': 0.003906369212927641,
  'axis': 0})>
<Event(7-JoyAxisMotion {
  'joy': 0,
  'value': -1.000030518509476,
  'axis': 4})>
...

Since music is so latency sensitive (though maybe not for expression controllers?) I didn't want to have to go via python, so I decided to write something small against the OSX native API. The docs for the native API are pretty annoying, so the SDL source was a helpful guide.

It's ready and working, and you can try it out:

  • Build it from source (github):

    $ git clone https://github.com/jeffkaufman/gcmidi.git
    $ cd gcmidi
    $ make run
    
  • Download a binary:

    $ wget https://www.jefftk.com/gcmidi
    $ chmod ugo+x gcmidi
    $ ./gcmidi
    
It presents as a virtual MIDI controller named "game controller" with ten continuous controller outputs on CC-20 through CC-29.

Comment via: google plus, facebook, r/WeAreTheMusicMakers

Recent posts on blogs I like:

Starting With Chords

A lot of people play fiddle. Basically nobody starts by learning chords before learning melodies. But that's actually how I learned. I started with chords. One of the nice things about learning to play violin this way is that you can go busking even…

via Anna Wise's Blog Posts November 15, 2024

Stuffies

I have some stuffies and I just have a bunny. Bunny is a rabbit. Woof is a seal. My favorite stuffie is bun bun. I play with my stuffies. Sometimes I jump up with them and I roll them. I can just throw them in the air when I want to play bthululubp wi…

via Nora Wise's Blog Posts November 15, 2024

You Can Buy A Malaria Net

2024 election takes

via Thing of Things November 6, 2024

more     (via openring)