Playing MIDI with Perl on Windows

Marty Bell mpjbell at
Fri Aug 15 20:02:18 CDT 2003

Doug, Chris,

I realize this may not be exactly the solution you are looking for.  But here
is a working Perl script that plays a midi file (tested on 2 W2000 PCs I

It requires Windows Scripting Host(free to download, see notes in attached
script), and Windows Media Player (I believe available on all windows OS's, 
although the name of the .exe may change.

Windows Scripting Host is (IMHO) the preferred shell in the Windows OS
world.  It
definitely puts Perl (VB script, etc.) on steroids (hope that not illegal

If nothing else it demonstrates how to load any .exe and pass a parm.  A .ocx 
would be even better for your purposes, I just don't know of any free to
without doing the research.


At 02:58 PM 8/15/2003 -0700, you wrote:
>Chris Krum wrote:
>>>Hey all!
>>>I'm looking for a solution to play MIDI files from Perl on Windows.  I'm
>>>already aware of Win32API::MIDI on CPAN, but it requires Visual C++ to
>>>compile, and I don't have that available.  There are other MIDI modules
>>>on CPAN, but they appear to be concerned with generating/reading/munging
>>>MIDI.  I was wondering if there is a way to do it using Win32::OLE.  I'm
>>>woefully (or blissfully) ignorant of the Windows API, so any ideas are
>>>appreciated.  Thanks!
>> I'm also interested in playing midi from perl. Here are a few questions to
>> help me understand your situation better.
>> Does this have to be a pure perl solution? Could you use a rendering engine
>> like Timidity++ to render the midi to a wave file and output that to the
>> soundcard? Are you restricted to midi or could you use something like SAOL?
>> Is your app generating the midi files or does it pull them from a file
>> system somewhere? Do you need to play the midi notes in realtime (like
>> creating your own midi instrument) or are they stored in files and played
>> back later?
>Unfortunately, I can't answer all of those questions right now.  I 
>should be getting more information soon.  What I did find was 
>Win32::MCI::Basic.  I was excited at first, because it worked fine on my 
>WinME box (boo, hiss :) ), but have since discovered that it doesn't 
>work on Win2000 (and possibly all NT based systems - just a guess).  I'm 
>wondering if the MCI API was removed in NT.  I haven't finished with my 
>research yet.
>All of that being said, I might be able to use mp3 or wav files instead, 
>so if anyone has any suggestions on playing those under windows, feel 
>free. :)
-------------- next part --------------
A non-text attachment was scrubbed...
Type: application/zip
Size: 10568 bytes
Desc: not available
Url :

More information about the Phoenix-pm mailing list