[squeak-dev] decomposing a MixedSound into left and right channels

Eliot Miranda eliot.miranda at gmail.com
Tue Aug 9 23:32:05 UTC 2022

Hi St├ęphane, Hi All,

    I'm working on AAC encode/decode and mp4 packaging.  I'm trying to test
using the stereoBachFugue, but I can't even get the following to generate
any sound in stereo.  What am I doing wrong?

    | aMixedSound left right samples |
    (aMixedSound := MixedSound new)
        add: (AbstractSound bachFugueVoice1On: FMSound oboe1) pan: 0.4;
        add: (AbstractSound bachFugueVoice2On: FMSound organ1) pan: 0.1;
        add: (AbstractSound bachFugueVoice3On: PluckedSound default) pan:
        add: (AbstractSound bachFugueVoice4On: FMSound brass1) pan: 0.6.
    left := WriteStream on: SoundBuffer new.
    right := WriteStream on: SoundBuffer new.
    samples := aMixedSound computeSamplesForSeconds: aMixedSound duration.
    [1 to: samples size by: 2 do:
         left nextPut: (samples at: i).
         right nextPut: (samples at: i + 1)]] value. "to step over quickly
in the debugger"
    ^MixedSound new
        add: (SampledSound samples: left contents samplingRate: aMixedSound
samplingRate) pan: 0;
        add: (SampledSound samples: right contents samplingRate:
aMixedSound samplingRate) pan: 1;

    "self testSqueakStereoSound"

The idea is to pan the harpsichord and organ almost hard right and left,
and pan the oboe and tuba a little around the centre, generate the stereo
samples via computeSamplesForSeconds:, decompose the two channels into two
separate monophonic channels, and recombine them.  But I on;y ever get
silence.  I can see that the decomposition looks correct, but why do
neither the resulting MixedSound, nor either the left or right channel
produce any sound?

best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220809/a72735fa/attachment.html>

More information about the Squeak-dev mailing list