[squeak-dev] Sound mixing makes nasty noises

tim Rowledge tim at rowledge.org
Fri Dec 18 01:52:53 UTC 2020


> On 2020-12-17, at 5:12 PM, St├ęphane Rollandin <lecteur at zogotounga.net> wrote:
>> There is the futzing with the  'scaledVol' value built in to the assorted mix prims & methods, so surely that ought to work?
> Yes, but that scaledVol value is already set to change cyclicly (is that a word?) in FMSound organ1 in order to modulate the base sine wave and give it some timbre. If we attempt to use that same value to control the overall loudness, we will lose the timbre. In fact we would need to multiply the timbral volume envelope with the loudness one, but this is not trivial because the first one uses a loop.

I *think* that the FMSound>>#primitiveMixFMSound code handles this; at least it looks like it pays attention to the waveTable etc. I've just taken a quick look and the code that changes the scaleVol if the scaledVolIncr value is non-0 is there in the prim too, so there hasn't been a major regression in  the code. Probably.

>> What would be the 'proper' way to merge multiple sounds with varying volumes? Do you scale all of them? 
> Yes, and whether or not their volumes are varying, the sounds must have been scaled beforehand to ensure there is enough headroom for their superposition.

Yikes. That smacks of needing a lot of advance information. How on earth do we handle sometihng like a true ten-finger keyboard? Make each sound only allow volume 0.1 ?

> This again is not trivial, because of the way interference works: adding two sounds can potentially double the height of their amplitude peaks, where they interfere constructively, but can also, where they interfere destructively, lead to a lower volume (for an extreme example, if you mix a signal with its exact mirror you will get a plain silence).

Oh yes. Wave interference maths is great fun. I was just reading a couple of nights ago about using the positive Grassmanian and Kodama-Williams equations to model soliton waves. I hope we don't need to worry about that to solve this tiny problem!

tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
If at first you don't succeed, destroy all evidence that you tried.

More information about the Squeak-dev mailing list