MIDI::Simple and CGI
[email protected] ("Sean M. Burke") Sat, 02 Dec 2000 12:35:38 -0700
| Newsgroups | perl.midi |
|---|---|
| Message-ID | <[email protected]> |
At 08:48 AM 2000-12-02 -0000, you wrote: >[...]what I am hoping to do is create a midi file from scratch so that >i can interact with a user on a web site. For example the ask for >notes c-d-a and I build up a midi file in a program and then send >this out to them as if it were a standard midi file.[...] Well, MIDI::Simple is, I hope, the easiest way to assemble an opus. And from there you just write it as CGI output instead of as a file on disk. The result /is/ a standard MIDI file, just one that doesn't hit disk. http://www.speech.cs.cmu.edu/~sburke/midi-perl/scripts/chimes_cgi.pl To be run as a CGI: #!/usr/local/bin/perl ## Time-stamp: "2000-12-02 12:28:59 MST" ## use MIDI::Simple; new_score; patch_change 1, 8; # set Channel 1 to Patch 8 = Celesta noop c1, f, o5; # Setup # Now play n qn, Cs; n F; n Ds; n hn, Gs_d1; n qn, Cs; n Ds; n F; n hn, Cs; n qn, F; n Cs; n Ds; n hn, Gs_d1; n qn, Gs_d1; n Ds; n F; n hn, Cs; # And then write to STDOUT with appropriate MIME header binmode(STDOUT); print "Content-type: audio/midi\n\n"; Self()->make_opus->write_to_handle(*STDOUT); exit; -- Sean M. Burke [email protected] http://www.spinn.net/~sburke/