Play wav or sound file.

Play wav or sound file.

am 04.12.2007 19:08:21 von 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. any suggestions would be greatly appricaited. THANKS

Re: Play wav or sound file.

am 04.12.2007 19:28:10 von Ben Morrow

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

Re: Play wav or sound file.

am 05.12.2007 05:57:04 von Cehotec - Tim

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.

Re: Play wav or sound file.

am 05.12.2007 06:39:19 von Ron Bergin

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

Re: Play wav or sound file.

am 05.12.2007 16:22:05 von Petr Vileta

Cehotec - Tim wrote:
> 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.

Look for Win32::Sound module on CPAN.

--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your
mail from another non-spammer site please.)

Please reply to

Re: Play wav or sound file.

am 05.12.2007 17:11:03 von Cehotec - Tim

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!

Re: Play wav or sound file.

am 06.12.2007 03:18:56 von Petr Vileta

Cehotec - Tim wrote:
> Thanks everyone.
>
> use Win32::Sound;
> Win32::Sound::Volume('100%');
> Win32::Sound::Play("file.wav");
>
> Worked!
Take a look to Win32::Sound documentation. This module know to play sound file
asynchronous. In other word sound file is playing and your script continue in
work without waiting to end of sound.
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your
mail from another non-spammer site please.)

Please reply to