[squeak-dev] The Inbox: Sound-dtl.67.mcz
Stéphane Rollandin
lecteur at zogotounga.net
Wed Dec 11 12:36:25 UTC 2019
>> mixSampleCount: n into: aSoundBuffer startingAt: startIndex leftVol: leftVol rightVol: rightVol
>> "Play a number of sounds concurrently. The level of each sound can be set independently for the left and right channels."
>>
>> | snd left right |
>> 1 to: sounds size do: [:i |
>> (soundDone at: i) ifFalse: [
>> snd := sounds at: i.
>> + left := (leftVol * (leftVols at: i) * scaledVol / ScaleFactor) // ScaleFactor.
>> + right := (rightVol * (rightVols at: i) * scaledVol / ScaleFactor) // ScaleFactor.
>
> Assuming that leftVol, rightVol are integers, and leftVols and rightVols
> are arrays of integers, #/ is very likely to introduce Fractions,
Yes, good catch.
> #// may introduce noise without dithering. Perhaps it would be better to
> precalculate a constant outside the loop (e.g: scaledVol /
> FloatScaleFactor / FloatScaleFactor),
I found this whole business of dividing twice by ScaleFactor very fishy...
Stef
More information about the Squeak-dev
mailing list
|