Created
August 29, 2012 19:53
-
-
Save jbarrett/3517965 to your computer and use it in GitHub Desktop.
VERY rough prototype for midi control from analogue joystick.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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