[squeak-dev] Sound mixing makes nasty noises

Herbert herbertkoenig at gmx.net
Mon Dec 28 18:36:31 UTC 2020


Hi,

after a lot of trying I managed to have

parec --file-format=wav
--device=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor test.wav

record the audio output of Squeak. Device is found via pactl list sinks
and Squeak is started via

exec padsp "${VM}" "${IMAGE}"

 From there on I used my slightly improved but still not working
playLoop to record inside Squeak and the above to record outside Squeak.

Inside Squeak I saw a lot of clipping as expected, outside I saw
wrapping whenever it clipped inside. I saw no buffer loss in the
recording outside of Squeak up to the 6 voices I checked. My recording
inside playLoop still looses most of the buffers.

I used:

SoundPlayer startReverb.
FMSound organ1 setPitch: 261.6 dur: 10 loudness: 0.3 ; play.
FMSound organ1 setPitch: 329.6 dur: 10 loudness: 0.3 ; play.
FMSound organ1 setPitch: 392 dur: 10 loudness: 0.3 ; play.
FMSound organ1 setPitch: 523.2 dur: 10 loudness: 0.3 ; play.
FMSound organ1 setPitch: 659.3 dur: 10 loudness: 0.3 ; play.
FMSound organ1 setPitch: 784 dur: 10 loudness: 0.3 ; play.

C major chord plus an octave above.

With loudness 0.2 nearly no clipping occurred up to 0.3 with constant
clipping. As playing even one voice sets the CPU to 100% load on the Pi
(as per top). I checked up to 6 voices to see if it was a matter of CPU
load which it seems to be not on a Pi3.


Conclusion: It seems to happen somewhere between

primSoundPlaySamples: count from: Buffer startingAt: 1 (Before that I
recorded inside Squeak to a file)

and the output to the os. primSoundPlay... is sent in SoundPlayer class
playLoop.

quoting Tim:

Staring at the generated C code it looks possibly suspicious that we have

short int *aSoundBuffer;
sqInt s;
		if (leftVol > 0) {
			i = (2 * sliceIndex) - 1;
			s = (aSoundBuffer[i]) + ((sample * leftVol) / ScaleFactor);
			if (s > 0x7FFF) {
				s = 0x7FFF;
			}
			if (s < -32767) {
				s = -32767;
			}
			aSoundBuffer[i] = s;
		}
But surely no C compiler screws that up these days?

if that's from the primitive, why do we clip here? Clipping is done
inside Squeak.

Cheers,


Herbert



Am 25.12.20 um 14:54 schrieb K K Subbu:
> On 25/12/20 6:49 pm, Herbert König wrote:
>> It would be cool if someone can implement Your suggestion on how to
>> write Squeak's audio output buffers to a file because then I could
>> discern if the whole mess gets created by Squeak or if the OS plays a
>> role too.
>
> You may use parec (sound capture to file) and paplay (file to sound
> output) to test the audio subsystem of the OS to rule out any audio
> driver or mixer configuration problems [1]. The corresponding ALSA
> utilities are arecord and aplay. The mixer is alsamixer.
>
> padsp acts as a relay between the older /dev/dsp (audio device under
> OSS) and the newer /dev/snd/* (audio i/o devices).
>
> [1] https://manpages.debian.org/testing/pulseaudio-utils/pacat.1.en.html
>
> HTH .. Subbu
>


More information about the Squeak-dev mailing list