Last modified 7 years ago Last modified on 2013-02-03 05:18:56

Midi Controller

It is cool to control your simulator with a midi controller. We like Behringer BCF2000. It is cheap and plug n play.

Ubuntu 12.04 screwed up pymidi. Until a fix is commited to the main repository you can get the bug fix here:

sudo add-apt-repository ppa:dr-graef/test
sudo apt-get update
sudo apt-get upgrade

With this python program you can try to read and write midi commands:

import pygame.midi as midi
import math


# find all the devices
instance = False
outstance = False
while midi.get_device_info(i) is not None:
   print i, " ", s
   if s[1] == "BCF2000 MIDI 1" and s[2]==1:
      instance = midi.Input(i)
   if s[1] == "BCF2000 MIDI 1" and s[3]==1:
      outstance = midi.Output(i)
   i += 1

if not instance or not outstance:
   print "No Behringer BCF 2000 Found. Make sure one is plugged directly to computer (not through USB hub)"

print "Found midi controller! Please move slider 1 to see some cool motorized sinus effect"
print "Change period with knob 1"
print "Quit with ctrl+c"

period = 2*3.14
while True:
 if midi.Input.poll(instance):
   r =,1)
   [[[status,data1,data2,data3],timestamp]] = r
   print "Read: ", r
   if data1 == 1:
     period = 6*3.14*data2/127
   if data1 == 81:
     amp = data2-64
     for i in range (1,8):
       o = int(amp*math.cos(i*period/8))+64
       #print o