in reply to /dev/sequencer bad file descriptor

For those who are interested, I finally got it to work!! Yeah. Trail and error methodology....but who cares?

The problem seemed to be the midi_device needs to be 1,2,3,or 4 for my SBlive. Which corresponds to ports 65:0 , 65:1 , 65:2 , 65:3 . The midi_device defaults to 0 which is probably 64:0, and is the kernel MPU. Anyways the following works for my SBlive. :-) (Now to get it to write to my USB midi interface)

UPDATE: Upon further testing, I found that my problem was caused by interference from the usb-hotplug interface for my UM-1 Midikeyboard connector. MIDI::Realtime works as described below, if hotplug is NOT started. If hotplug is started, the "bad file descriptor" error reappears. It was a funny bug, which really threw me off in my troubleshooting.

#!/usr/bin/perl use warnings; use strict; use MIDI::Realtime; use diagnostics; my $midi = MIDI::Realtime->new(dev=>'/dev/sequencer', midi_device=> 1); # 1,2,3 or4 # 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. flash japh