[squeak-dev] Adjusting the volume of a sound as it's playing

St├ęphane Rollandin lecteur at zogotounga.net
Sun Aug 18 09:44:43 UTC 2019


> There seems to be the right method in AbstractSound --
> adjustVolumeTo:overMSecs: -- but in Squeak 4.3 this seems to not be
> properly overridden in MixedSound or RepeatingSound. I was getting
> absolutely nothing to work until I stumbled onto changing leftVols and
> rightVols by brute force at an explorer. This DOES WORK.
> 
> leftVols and rightVols are instance variables in MixedSound, so it seems to
> me they should be changed by MixedSound's own implementation of
> adjustVolumeTo:overMSecs:. RepeatingSound should have its own
> implementation which just passes on to its sound.

For the volume control to work in MixedSound, it seems you would have to 
replace the lines

	left := (leftVol * (leftVols at: i)) // ScaleFactor.
	right := (rightVol * (rightVols at: i)) // ScaleFactor.

with

	left := (leftVol * (leftVols at: i) * scaledVol) // ScaleFactor.
	right := (rightVol * (rightVols at: i) * scaledVol) // ScaleFactor.

in MixedSound>>#mixSampleCount:into:startingAt:leftVol:rightVol:

Does that work?

Stef


More information about the Squeak-dev mailing list