Play wav or sound file.

Discussion in 'Perl Misc' started by Cehotec - Tim, Dec 4, 2007.

  1. I use perl script for an application which allows users to include
    their own code to be ran during the application.

    How can I go about creating a sub that you play a wav file. I am not
    looking to open the wav with my default player.. but to actually play
    the wav. any suggestions would be greatly appricaited. THANKS
    Cehotec - Tim, Dec 4, 2007
    #1
    1. Advertising

  2. Cehotec - Tim

    Ben Morrow Guest

    Quoth Cehotec - Tim <>:
    > I use perl script for an application which allows users to include
    > their own code to be ran during the application.
    >
    > How can I go about creating a sub that you play a wav file. I am not
    > looking to open the wav with my default player.. but to actually play
    > the wav.


    Basically: how would you play a wav without Perl? Then get Perl to do
    the the same way.

    You haven't said what OS or desktop system you are using. Most provide
    some means of playing a wav from the command-line; under most Unixes you
    can use sox(1). Under Win32 I guess you could invoke mplayer2.exe,
    though I don't know how you'd go about hiding the window it brings up.

    A quick search of CPAN for e.g. 'audio' or 'sound' brings up lots of
    potentially useful modules, though again you'd need to say what OS you
    were using to know which could help you.

    Ben
    Ben Morrow, Dec 4, 2007
    #2
    1. Advertising

  3. On Dec 4, 1:28 pm, Ben Morrow <> wrote:
    > Quoth Cehotec - Tim <>:
    >
    > > I use perl script for an application which allows users to include
    > > their own code to be ran during the application.

    >
    > > How can I go about creating a sub that you play a wav file. I am not
    > > looking to open the wav with my default player.. but to actually play
    > > the wav.

    >
    > Basically: how would you play a wav without Perl? Then get Perl to do
    > the the same way.
    >
    > You haven't said what OS or desktop system you are using. Most provide
    > some means of playing a wav from the command-line; under most Unixes you
    > can use sox(1). Under Win32 I guess you could invoke mplayer2.exe,
    > though I don't know how you'd go about hiding the window it brings up.
    >
    > A quick search of CPAN for e.g. 'audio' or 'sound' brings up lots of
    > potentially useful modules, though again you'd need to say what OS you
    > were using to know which could help you.
    >
    > Ben


    Thanks for the reply. I am using perl on a windows xp system. It's
    not necessary a large file that I want to play. I just want to play
    something a little more elaborate then a system beep. Say for
    instance a user does something wrong, I would like a sound to play.
    Thanks again.
    Cehotec - Tim, Dec 5, 2007
    #3
  4. Cehotec - Tim

    Ron Bergin Guest

    On Dec 4, 8:57 pm, Cehotec - Tim <> wrote:
    > On Dec 4, 1:28 pm, Ben Morrow <> wrote:
    >
    >
    >
    > > Quoth Cehotec - Tim <>:

    >
    > > > I use perl script for an application which allows users to include
    > > > their own code to be ran during the application.

    >
    > > > How can I go about creating a sub that you play a wav file. I am not
    > > > looking to open the wav with my default player.. but to actually play
    > > > the wav.

    >
    > > Basically: how would you play a wav without Perl? Then get Perl to do
    > > the the same way.

    >
    > > You haven't said what OS or desktop system you are using. Most provide
    > > some means of playing a wav from the command-line; under most Unixes you
    > > can use sox(1). Under Win32 I guess you could invoke mplayer2.exe,
    > > though I don't know how you'd go about hiding the window it brings up.

    >
    > > A quick search of CPAN for e.g. 'audio' or 'sound' brings up lots of
    > > potentially useful modules, though again you'd need to say what OS you
    > > were using to know which could help you.

    >
    > > Ben

    >
    > Thanks for the reply. I am using perl on a windows xp system. It's
    > not necessary a large file that I want to play. I just want to play
    > something a little more elaborate then a system beep. Say for
    > instance a user does something wrong, I would like a sound to play.
    > Thanks again.


    I haven't used it myself, but Win32::Sound looks to be a good
    possibility.
    http://search.cpan.org/~jdb/libwin32-0.28/Sound/Sound.pm
    Ron Bergin, Dec 5, 2007
    #4
  5. On Dec 5, 12:39 am, Ron Bergin <> wrote:
    > On Dec 4, 8:57 pm, Cehotec - Tim <> wrote:
    >
    >
    >
    >
    >
    > > On Dec 4, 1:28 pm, Ben Morrow <> wrote:

    >
    > > > Quoth Cehotec - Tim <>:

    >
    > > > > I use perl script for an application which allows users to include
    > > > > their own code to be ran during the application.

    >
    > > > > How can I go about creating a sub that you play a wav file. I am not
    > > > > looking to open the wav with my default player.. but to actually play
    > > > > the wav.

    >
    > > > Basically: how would you play a wav without Perl? Then get Perl to do
    > > > the the same way.

    >
    > > > You haven't said what OS or desktop system you are using. Most provide
    > > > some means of playing a wav from the command-line; under most Unixes you
    > > > can use sox(1). Under Win32 I guess you could invoke mplayer2.exe,
    > > > though I don't know how you'd go about hiding the window it brings up.

    >
    > > > A quick search of CPAN for e.g. 'audio' or 'sound' brings up lots of
    > > > potentially useful modules, though again you'd need to say what OS you
    > > > were using to know which could help you.

    >
    > > > Ben

    >
    > > Thanks for the reply. I am using perl on a windows xp system. It's
    > > not necessary a large file that I want to play. I just want to play
    > > something a little more elaborate then a system beep. Say for
    > > instance a user does something wrong, I would like a sound to play.
    > > Thanks again.

    >
    > I haven't used it myself, but Win32::Sound looks to be a good
    > possibility.http://search.cpan.org/~jdb/libwin32-0.28/Sound/Sound.pm- Hide quoted text -
    >
    > - Show quoted text -


    Thanks everyone.

    use Win32::Sound;
    Win32::Sound::Volume('100%');
    Win32::Sound::play("file.wav");

    Worked!
    Cehotec - Tim, Dec 5, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    13
    Views:
    10,513
    Oliver Wong
    Jul 18, 2006
  2. mutyala rao

    How to play MP3 / Wav file using C

    mutyala rao, Apr 26, 2006, in forum: C Programming
    Replies:
    12
    Views:
    17,404
    ruoqingmm
    Apr 29, 2006
  3. Scott
    Replies:
    2
    Views:
    2,488
    Scott
    Apr 30, 2007
  4. '2+
    Replies:
    2
    Views:
    474
  5. Replies:
    1
    Views:
    582
Loading...

Share This Page