Skip to content

Instantly share code, notes, and snippets.

@jbarrett
Created August 29, 2012 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbarrett/3517965 to your computer and use it in GitHub Desktop.
Save jbarrett/3517965 to your computer and use it in GitHub Desktop.
VERY rough prototype for midi control from analogue joystick.
#!/usr/bin/env perl
use MIDI::ALSA;
use SDL;
use SDL::Joystick;
use Time::HiRes qw( usleep );
SDL::init_sub_system(SDL_INIT_JOYSTICK);
my $joystick = SDL::Joystick->new(0);
my $x;
MIDI::ALSA::client( 'Game Controller MIDI::ALSA Client', 0, 1, 0 );
MIDI::ALSA::connectfrom( 0, 14, 0 );
while (1) {
SDL::Joystick::update();
$x = (SDL::Joystick::get_axis($joystick, 0) / 32768) * 256;
MIDI::ALSA::output(
MIDI::ALSA::controllerevent(0, 1, $x)
);
usleep(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment