I just discovered there is a Perl module that gives access to the ALSA MIDI functionality from within Perl:
MIDI::ALSA http://search.cpan.org/~pjb/MIDI-ALSA/ALSA.pm
Since Perl is the only programming language (apart from bash scripting) that I know quite well, I'm rather pleased about this Perl module and I'm planning to experiment with it (I'm thinking of writing some sysex dump apps for some of my hardware synths).
Has anyone used this Perl module? If yes any experience to share, any tips, tricks?
I found this blog that has an example app that uses this Perl module:
http://showmetheco.de/articles/2011/12/ ... -perl.html
ALSA MIDI programming with Perl
Moderators: MattKingUSA, khz
ALSA MIDI programming with Perl
Last edited by tux99 on Wed Oct 10, 2012 3:46 pm, edited 1 time in total.
Re: ALSA MIDI programming with Perl
Hmm, given the lack of replies I guess there aren't many (Perl) programmers around here.
Ok, I just did the following mini program that sends a sysex dump request to a Yamaha RM50 rhythm sound module and then receives the sysex dump in return. The program is still very basic, you need to adapt the midi ports and the type of dump request directly in the code, but it works and it's a good example of how easy it is to write ALSA MIDI apps with Perl using the MIDI::ALSA Perl module. Maybe this example will encourage some of you to have a go at ALSA MIDI programming with Perl yourself:
Ok, I just did the following mini program that sends a sysex dump request to a Yamaha RM50 rhythm sound module and then receives the sysex dump in return. The program is still very basic, you need to adapt the midi ports and the type of dump request directly in the code, but it works and it's a good example of how easy it is to write ALSA MIDI apps with Perl using the MIDI::ALSA Perl module. Maybe this example will encourage some of you to have a go at ALSA MIDI programming with Perl yourself:
Code: Select all
#!/usr/bin/perl
use strict;
use warnings;
use MIDI::ALSA ('SND_SEQ_EVENT_PORT_UNSUBSCRIBED',
'SND_SEQ_EVENT_SYSEX');
MIDI::ALSA::client('Perl MIDI test client',1,1,1);
MIDI::ALSA::connectfrom(0,28,0);
MIDI::ALSA::connectto(1,28,0);
MIDI::ALSA::start();
# Yamaha RM50 sysex bulk dump request strings
my $channel_setup_req = 'C ~LM 0087ML';
my $system_setup_req = 'C ~LM 0087SY';
my $prg_change_tbl_req = 'C ~LM 0087PC';
my $int_voice_bank_req = 'C ~LM 0087VI';
my $wave_card_voices_req = 'C ~LM 0087VW';
my $variation_voices_req = 'C ~LM 0087EP';
my $int_rhythm_kit_req = 'C ~LM 0087KI';
# define bulk dump request to use
my $req_string = $int_voice_bank_req;
# send bulk dump request delayed by 1 sec
my @alsasysex = MIDI::ALSA::sysex(1,$req_string,1);
MIDI::ALSA::output( @alsasysex );
# sysex data appears to arrive in 256byte chunks so we need
# to loop until we recieve the sysex end byte (F7)
while (1) {
# read next ALSA event
my @alsaevent = MIDI::ALSA::input();
# if the input connection disappears then exit
if ( $alsaevent[0] == SND_SEQ_EVENT_PORT_UNSUBSCRIBED() ) {
last;
}
elsif ( $alsaevent[0] == SND_SEQ_EVENT_SYSEX() ) {
# save event data array
my @data = @{$alsaevent[7]};
# extract sysex data chunk
my $sysexdata = $data[0];
# print sysex data to STDOUT
print $sysexdata;
# if last byte is F7 then sysex dump is complete
if ( substr($sysexdata,-1) eq chr(247) ) {
last;
}
}
}Re: ALSA MIDI programming with Perl
I'm currently working on a full patch editor for the Yamaha RM50 rhythm sound module using Perl, the Perl MIDI::ALSA module and Perl/Tk for the GUI. I knocked this up in a few hours this afternoon:

This still needs a lot of work, it's far from ready yet, but I thought I post a screenshot to show what's possible with Perl and MIDI::ALSA.

This still needs a lot of work, it's far from ready yet, but I thought I post a screenshot to show what's possible with Perl and MIDI::ALSA.
Re: ALSA MIDI programming with Perl
A first 0.1 release of my Yamaha RM50 synth patch editor is now available.
For more details please check out my post about it on the Yamaha Forums:
http://www.yamahaforums.co.uk/forum/vie ... f=9&t=5915
If you own a Yamaha RM50 I highly recommend you to try the patch editor software, it makes editing the sounds soooo much easier!
For more details please check out my post about it on the Yamaha Forums:
http://www.yamahaforums.co.uk/forum/vie ... f=9&t=5915
If you own a Yamaha RM50 I highly recommend you to try the patch editor software, it makes editing the sounds soooo much easier!