[squeak-dev] Sound mixing makes nasty noises

Eliot Miranda eliot.miranda at gmail.com
Tue Dec 29 19:03:28 UTC 2020


Hi Herbert, Hi Tim,

    I suspect I've made a mistake somewhere.  This used to play smoothly
and now I can hear some distortion and it's unlilely to do with my
speakers, as the same is heard either through my laptop speakers or my
apple display speakers:

| samples sineTable sound |
"1 second of A below middle C (220Hz). 16000 / 220 is 72.72 recurring"
sineTable := SoundPlayer sineTable: 73.
sineTable doWithIndex: "And let's not deafen anyone..."
[:sample :index| sineTable at: index put: sample // 4].
samples := SoundBuffer new: 16000.
1 to: samples size by: sineTable size do:
[:i| samples replaceFrom: i to: (i + sineTable size - 1 min: 16000) with:
sineTable startingAt: 1].
1 to: 146 do:
[:i|
samples at: i put: ((samples at: i) * i / 146) asInteger.
samples at: 16001 - i put: ((samples at: 16001 - i) * i / 146) asInteger].
sound := SampledSound
samples: samples
samplingRate: 16000.
sound := MixedSound new
add: sound pan: 0.25;
add: sound pan: 0.75;
yourself.
sound play

So I'll try and do a regression test soon.

On Tue, Dec 29, 2020 at 10:53 AM Herbert König <herbertkoenig at gmx.net>
wrote:

> I changed playLoop to just copy the current SoundBuffer into a collection.
> I got some 11 seconds sound (2 below)
> Each buffer I differentiated and took the abs value. (see attached st)
> Of those I took the max. In case of wraparound that would be close to
> 64k.
> The zeroes in these buffers are the clippings. (3 below) Again I took the
> max. (4 below).
>
> I can't email screenshots from the Pi but I did it on a Pi too. I used
> Tim's first snippet. I found a lot of clipping inside Squeak and not a
> single wraparound in several attempts.
>
> Same observation id waggling the Keyboard or playing my 6 voiced C major
> while waggling the keyboard morph.
>
> On the Pi3 I still lost buffers (getting 7 seconds worth of buffers from
> 10+ seconds of Audio). I would not search in the Squeak Smalltalk code for
> the problem but would suspect the primitive where Squeak hands the output
> to Raspbian.
>
> That said clipping still makes for horrible sound (SCNR :-).
>
> Cheers,
>
> Herbert
>
>
> Am 29.12.2020 um 12:38 schrieb Herbert König:
>
>
>
> Am 28.12.2020 um 22:48 schrieb tim Rowledge:
>
> On 2020-12-28, at 10:36 AM, Herbert <herbertkoenig at gmx.net>
> <herbertkoenig at gmx.net> wrote:
>
> Inside Squeak I saw a lot of clipping as expected, outside I saw
> wrapping whenever it clipped inside.
>
> That would be an interesting thing to prove conclusively. It's not
> unimagineable that there could be a bug in a unix sound library.
>
> I'd suspect the Squeak primitive that hands the buffers to the OS before
> looking into OS code.
>
> Would it be conclusive to record the outside for a minute or so, read
> that file and count wrapping
> (sample(n) = +fullscale and sample(n+1) = -fullscale) or (sample(n) =
> -fullscale and sample(n+1) = +fullscale)
> and do the same for all SoundBuffers we get hold of inside Squeak during
> the recording? (repeatedly checking SoundBuffer allInstances)
>
> Maybe if we make a crafted sound buffer with a clean waveform that we know
> never gets clipped but does hit the maxval/minval and play it directly with
> no mixing related calls (because the mixer code does volume scaling etc and
> internal clipping) we might see what comes out of pulseaudio and indeed
> alsa.
>
> AbstractSound or the like has a class var Sine with that but I feel
> that's directed at finding a bug in the OS and discards the possibility
> of Squeak messing it up. And the organ sounds used are predictable
> enough re clipping but I hope the individual envelopes add some
> randomness to cover more cases.
>
> Cheers,
>
> Herbert
>
>
>
>
>

-- 
_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20201229/73d4c53d/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hnbcejajmlkkicge.png
Type: image/png
Size: 234140 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20201229/73d4c53d/attachment-0001.png>


More information about the Squeak-dev mailing list