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

hello.

i am writing a little drum-sequencer using the Win32::Sound::WaveOut module. so far it works ok, but when i included a scale to change the volumes of the different channels i encountered problems. below excerpts from the code :
my $WAV1 = new Win32::Sound::WaveOut($sound_a) or die "WaveOut: $!"; # open sound for channel 1 ... ... $WAV1 -> Volume($level_a, $level_a); $WAV1 -> Play() or die "Play: $!"; # play sound with the level set
$level_a is defined by the user via a scale :
my $level_a_scale = $frame3-> Scale(-variable=>\$level_a, -from => 0, +-to => 65535);
the weird thing is that though i define the level twice (left and right), i only get a signal on the left speaker and that setting $level_a to 0 does not mute the sound
if i don't use the line
$WAV1 -> Volume($level_a, $level_a);
the sound is played on both speakers.

thanks for your help, b4e.

Replies are listed 'Best First'.
Re: Changing the Volume with the Win32::Sound::WaveOut module
by meetraz (Hermit) on Aug 02, 2004 at 18:27 UTC
    b4e,
    I think the issues you are experiencing are bugs with this module.
    I was able to duplicate what you describe, and looking at the source
    code for the module, I spotted other bugs as well.

    I think the best thing for you to do is contact the author with detailed
    examples of what you are experiencing.

Re: Changing the Volume with the Win32::Sound::WaveOut module
by ixo111 (Acolyte) on Jul 21, 2008 at 02:38 UTC
    ( only four years after the original post! )

    I haven't tested this with the WaveOut portion of the Win32::Sound module, but the logic seems nearly identical in both the Win32::Sound and Win32::Sound::Waveout sections of Sound.c. Basically, snag the module, edit Sound.c and change all occurrences of '<< 8' to '<< 16' and only use 0-65536 for volume changes, not the percentage notation as specified by the documentation. This fix is only a few minutes old but I've been able to successfully set the left and right channels independently or synched, so for now that's good enough.

    ( note : I was using this under Cygwin but I expect it should work equally well with Activestate )