It looks to me like he's using 16 bits (8 for the left and 8 for the 
right), and by shifting, keeping it all within one 16 bit "word." When 
computers had 16k in memory, that kind of stuff was necessary, now -- IF 
(big if) that is what he's doing -- it seems kind of silly. Of course, 
doing that kind of stuff may still be necessary because it's still built 
into the language from way back in the days when those tricks were 
necessary memory savers.

And I can see how you could easily run into a logic problem doing that.

If it is only 8 bits, that much memory is only capable of counting up to 
128, so your volume is probably rolling over at 128%, so 129% becomes 1% 
(unless it accepts negatives in which case it would roll to a negative 128 
[which with a digital speaker would pull instead of push, or vice versa, 
possibly making white noise to the opposing speaker? Or nothing! ]) -- 
except that IF he's packing 'em into one word, this rolling over business 
and how it interacts with that shifting and packing (and maybe negatives) 
[the right side may not roll over but may simply force a bit into the high 
order left side which of course adds to and generally messes up the left 
side, while the left side does roll over (possibly both before and after 
packing)]

All adds up to a logic problem I don't want to think about right now. 
Especially, since I don't know enough C to code it even if I did work out 
the logic. But basically, if you want to go to 500% (and more?) you're 
going to need more memory space for that function. But, will the sound card 
even accept numbers like that? Perhaps, it only accepts up to 100%, and 
that's the reason he didn't bother with using enough memory to go over 
100%. If that is the case though, he really should've put a statement 
something like:

if (volume > 100%) volume = 100%
or
if (volume > 100%)
  quit "Don't do that, it hurts right in the sub-processor"

In there, somewhere, it seems to me :)

ms


At 13:56 6/28/02 -0500, you wrote:

>----- Original Message -----
>From: "Ron Grabowski" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Wednesday, June 26, 2002 11:30 PM
>Subject: Re: Reply: Win32 Sound Module install ???
>
>
> > The volume kind of works for me:
> >
> >  perl -MWin32::Sound -le "Win32::Sound::Volume('500%');
> > Win32::Sound::Play('S
> >  ystemStart');"
> >
> > but sound only comes out of the left speaker? Even with
> > "Volume('500%','500%')". ???
>
>
>Don't use %'s without first fixing the bug in Sound.pm's volume() method
>(check the division, but look back in the archives for what the bug is, I
>can't remember off-hand).
>
>You might do best (for full volume, can't go beyond that =) to say:
>
>...::Volume(0xFFFF,0xFFFF); or something like the same.
>
>While my C isn't too, erm, robust, I think the problem with only setting the
>left channel is here : (in Sound.xs -- _volume method)
>
>     default:
>         volume = SvIV(ST(0)) | SvIV(ST(1)) << 8; // HERE
>         mmr = waveOutSetVolume((HWAVEOUT) WAVE_MAPPER, volume);
>         if(mmr == MMSYSERR_NOERROR) {
>             XSRETURN_YES;
>         } else {
>             WaveOutCheckError(mmr);
>             XSRETURN_NO;
>         }
>
>I'm not sure what the | and << do in C, but the volume value should be two
>dwords (two 16bit values).
>
>Can anyone elucidate on the result of that single line?
>
>Thanks!
>
>!c
>
>
>
>
>_______________________________________________
>Perl-Win32-Users mailing list
>[EMAIL PROTECTED]
>To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to