slloyd has asked for the wisdom of the Perl Monks concerning the following question:

Can anyone help me out? I cannot seem to figure out how to set the volume on a sound started via winmm through the mciSendString API in windows. I am able to play and stop the sound fine but I cannot figure out the syntax to control the volume.

$mci ||= new Win32::API("winmm", "mciSendStringA", 'PPNN', 'N') || ret +urn 0; #- Init $retstring my $retstring=" "x256; #- Open mp3 file $mci->Call("open \"$file\" alias mysound",$retstring,256,0); #- Play it $mci->Call("play mysound from 1",$retstring,256,0); # - how do I set the volume?

Replies are listed 'Best First'.
Re: Set Volume with winmm and mciSendString
by fglock (Vicar) on Jun 27, 2004 at 05:20 UTC

    Check this out: Win32::Sound. You can take a look at the source code to find out how they do it, or simply use it as-is.

use Win32::MCI::Basic;
by PodMaster (Abbot) on Jun 27, 2004 at 05:57 UTC
    Win32::MCI::Basic
    #synopsis use Win32::MCI::Basic; my $lpszCommand = "status cdaudio number of tracks"; # example MCI c +ommand my ($APICallReturnValue, $lpszReturnString) = mciSendString($lpszCom +mand); print "Number of tracks: $lpszReturnString\n"; my $lpszErrorText = mciGetErrorString($ReturnValue); print "Error: $lpszErrorText\n";

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      Win32::MCI::Basic module does not help as I cannot get the syntax for the 'setaudio' command correctly. Either that or it simply does not work.
        The module works. I've used it successfully in the form of Win32::MCI::CD despite the typo.

        MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
        I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.