[squeak-dev] Question about SoundGenerationPlugin/mixSampleCount
Eliot Miranda
eliot.miranda at gmail.com
Sat Oct 10 19:01:14 UTC 2020
Hi Herbert, Hi Christoph,
> On Oct 9, 2020, at 12:33 PM, Herbert König <herbertkoenig at gmx.net> wrote:
>
> Hi Christoph,
>
> maybe you hit upon a stereo representation with interleaved channels? But then it should be 16 bit words, so not sure.
That’s right. The sound output primitive takes interleaved (alternating left/right, signed) 16-bit samples. So the mix down methods mix from whatever the representation into this stereo representation.
>
> Cheers,
>
> Herbert
>
> storeWAVSamplesOn: aBinaryStream
> "Store this sound as a 16-bit Windows WAV file at the current SoundPlayer sampling rate. Store both channels if self isStereo is true; otherwise, store the left channel only as a mono sound."
>
> Am 09.10.2020 um 18:19 schrieb Thiede, Christoph:
>> Hi all,
>>
>>
>>
>> for a test, I am storing sounds into a ByteArray and read them again. This works well for PluckedSounds, for example, but I found some strange behavior when doing the same with SampledSounds:
>>
>>
>>
>> sound := SampledSound new
>> setSamples: SampledSound coffeeCupClink
>> samplingRate: 12000.
>>
>> bytes := ByteArray streamContents: [:stream |
>> sound storeWAVSamplesOn: stream].
>>
>> outputSound := SampledSound fromWaveStream: bytes readStream binary.
>>
>>
>> After running this script, I would expect outputSound to have the same samples as sound. But actually, every byte in the SoundBuffer appears twice! Still, playing the sound does not sound differently in my ears. I traced the issue down and found out that #mixSampleCount:into:startingAt:leftVol:rightVol: is writing every byte four times on the stream - two would be okay for left and right channel, but I do not understand the four. I reproduced the issue both on Windows and Ubuntu (WSL). Disabling the primitive did not help either.
>>
>>
>>
>> So I am wondering: Is this a bug or totally fine (because you cannot hear a difference anyway)? If the latter is the case, how can I compare the sounds else in a reliable way? If I store outputSound again, the number of bytes is doubled again, so if you do certain operations, your image will blow up exponentially ...
>>
>>
>> For the context of this question, see also: http://forum.world.st/Overriding-in-Graphics-and-Sounds-td5122783.html
>>
>> Best,
>> Christoph
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20201010/41f8dc59/attachment.html>
More information about the Squeak-dev
mailing list
|