Getting bored in the office? A few of your officemates can drive the boss crazy by starting your own "cubicle rock band". This is an simple script, to help waste "many many man-hours". :-) It probably works on linux only. Windows users already waste enough time. :-)

Press a key and a midi note is sounded. My favorite is "r".

#!/usr/bin/perl use warnings; use strict; use MIDI::Realtime; use Term::ReadKey; ReadMode('cbreak'); #this works on linux with an SBlive, Alsa 1.0.4, kernel 2.4.22 # on my system, it has a bug when usb-hotplug and usb-midi are used my $midi = MIDI::Realtime->new(dev=>'/dev/sequencer', midi_device=> 1); #1,2,3,4 while(1){ my $char; if (defined ($char = ReadKey(0)) ) { print ord($char),"\n"; # input was waiting and it was $char + $midi->patch(ord($char)); #change instrument, 127 gives "exploding keyboard" :-) $midi->note(50,1,127); #play note } else { # no input was waiting } } ReadMode('normal'); # restore normal tty settings __END__

Replies are listed 'Best First'.
Re: qwerty-keyboard realtime midi
by Juerd (Abbot) on Jun 21, 2004 at 20:53 UTC

    How exactly is this QWERTY related? As far as I can tell, it works with QWERTZ, AZERTY, Dvorak, etcetera too.

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

      Yes, I guess qwerty was a bad choice of words, but I asked my self what was the shortest way I could convey the concept of the console keyboard so it would fit in the title. Qwerty popped into mind, and I went with it over "console".

      I'm not really a human, but I play one on earth. flash japh
      I would assume he meant text keyboard as opposed to a synthesizer keyboard, a pour choice of qualifiers, but it made instant sense to me.
      A reply falls below the community's threshold of quality. You may see it by logging in.