Hi, I'm trying to get MIDI::Realtime to work. It's an old but simple module. I'm using Perl 5.8.3. and ALSA 1.0.4

Anyways the module seems to install OK, but when I try to run the module's sample code, I get an error:

"Couldn't write to /dev/sequencer, bad file descriptor at (....)Realtime.pm line 201.
So the code block generating the error is:
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; }
and the sample code I'm trying to run is
#!/usr/bin/perl use warnings; use strict; use MIDI::Realtime; my $midi = MIDI::Realtime->new(dev=>'/dev/sequencer', midi_device=> 0); # 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); }
So anyone know how to get the right file descriptor?

I'm not really a human, but I play one on earth. flash japh

In reply to /dev/sequencer bad file descriptor by zentara

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.