MIDI::Realtime works with ALSA
[email protected] (zentara) Sun, 20 Jun 2004 13:29:12 -0400
| Newsgroups | perl.midi |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I was trying to get MIDI::Realtime working, as discussed
in an earlier thread. Well sucess! I got it working by "edu-guessing".
:-)
The problem seemed to be that the midi_device defaults to 0, which
dosn't give output, at least on my SBLive. The midi_device needs to be
1,2,3, or 4. ( for soundcard output, I don't know yet about an external
midi).
So the following script works, (assuming you have successfully run
h2ph, (see man h2ph ) in order to get soundcard.ph.
#!/usr/bin/perl
use warnings;
use strict;
use MIDI::Realtime;
use diagnostics;
#works but no sound out from card
my $midi = MIDI::Realtime->new(dev=>'/dev/sequencer',
midi_device=> 1); #1,2,3, or 4
# Play note 47 with maximum velocity on channel 1
$midi->note(47,1,127);
# Now have some fun with randomness
my @notes = (37 .. 50);
# use all the channels (with extra drums)
my @channels = (1 .. 16, 10, 10, 10);
my @velocities = (70 .. 100);
for (0 .. 127) {
$midi->note($notes[rand(@notes)],
$channels[rand(@channels)],
$velocities[rand(@velocities)]
);
# Wait for a tenth of a second
select(undef,undef,undef, 0.10);
}
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html