Re: MIDI::Realtime and sblive with linux
[email protected] (zentara) Sun, 20 Jun 2004 07:11:39 -0400
| Newsgroups | perl.midi |
|---|---|
| Message-ID | <[email protected]> |
On Sat, 19 Jun 2004 11:27:33 -0400, [email protected] (Zentara) wrote: >I'm using kernel 2.4.22 and Alsa 1.0.4., and Perl 5.8.3 > >So the soundcard.h problem dosn't appear anymore, >but when I try to run the module's example code, I get >the error: >"Couldn't write to /dev/sequencer, bad file descriptor >at (....)Realtime.pm line 201. Well I did somemore digging into this, and got some results. I put a die on the sysopen in the Realtime.pm and found out that /dev/sequencer dosn't exist in ALSA. So I looked at how alsa's midiplayer runs with strace, and it seems to write to /dev/snd/seq. I tried to replace /dev/sequencer with /dev/amidi and the sample script runs without error, but there is no sound output from the soundcard. However, I have a nearby FM radio which plays increased "static" for the duration of the script.....so I'm guessing that the script is writing to /dev/amidi. Digging further, it seems likely that the alsa programming interface, dosn't like the &SEQ_MIDIPUTC() map (which is from soundcard.ph). So I will dig somemore, to see how to use that soundcard.ph function. >Line 201 is in this sub: >############################################### >sub send_midi_bytes { > my $self = shift; > > my $device = $self->midi_device; > > my $stuff = pack('C*', > (map {&SEQ_MIDIPUTC(), > $_, > $device, > 0 > } > @_ > ) > ); > > my $bytes = syswrite(SEQ_FH, $stuff); > > if (not $bytes) { > die("Couldn't write to " > . $self->dev > . ": $!" > ); > } > > return $bytes; >} >######################################################### > >The code I'm trying to run is: > >#!/usr/bin/perl >use warnings; >use strict; >use MIDI::Realtime; > >my $midi = MIDI::Realtime->new(); > ># Play note 47 with maximum velocity on channel 1 >$midi->note(47, 127, 1); > ># 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); >} >__END__ >############################################ > > >So I'll dig somemore, but if anyone knows how to setup >the right file descriptor, please edify us. :-) -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html