Tue Apr 28 21:12:44 2009: Request 43776 was acted upon.
Transaction: Correspondence added by cvertz
Queue: Win32-Sound
Subject: Old bug in Win32::Sound::Volume
Broken in: (no value)
Severity: Important
Owner: Nobody
Requestors: [email protected]
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=43776 >
Thank you Robert. I have tested your patch and I believe it works
perfectly.
After calling Volume("50%"), volume is now 50% and the left-right
balance is no longer affected. Now Volume() returns (32767,32767).
I did not test the workaround. Thanks again!
On Tue Mar 17 05:56:50 2009, ROBERTMAY wrote:
> On Mon Mar 02 14:28:32 2009, cvertz wrote:
> > #1 Setting volume works for left channel but silences right channel.
> > #2 Parsing of percentage volumes appears to be incorrect.
>
> Attached an (untested) patch that:
>
> (1) Fixes the range of allowed volumes to be 0-65535 to match the
> documentation (along with correct bit-shifts of 16-bits rather than
8-bits).
> (2) Fixes the percentage volume calculations.
> (3) Bumps the version to 0.50
>
> Also (untested), I beleive that the following can be used to work around
> the problems:
>
> #!perl -w
> use strict;
> use warnings;
>
> use Win32::Sound();
>
> sub win32_volume {
> my(@in) = @_;
>
> if(not scalar @in) {
> my $volume = Win32::Sound::_Volume();
>
> if (wantarray) {
> my $left = ($volume >> 16) & 0x0000FFFF;
> my $right = ($volume ) & 0x0000FFFF;
>
> return ($left, $right);
> }
>
> return $volume;
> }
>
> # Allows '0%'..'100%'
> $in[0] =~ s{ ([\d\.]+)%$ }{ int($1*65535/100) }ex if defined $in[0];
> $in[1] =~ s{ ([\d\.]+)%$ }{ int($1*65535/100) }ex if defined $in[1];
>
> $in[1] = $in[0] unless defined $in[1];
>
> my $volume = (($in[0] & 0x0000FFFF) << 16) | ($in[1] & 0x0000FFFF);
>
> return Win32::Sound::_Volume($volume, 0);
> }
>
>