Marcel Taeumel uploaded a new version of Sound to project The Trunk: http://source.squeak.org/trunk/Sound-mt.97.mcz
==================== Summary ====================
Name: Sound-mt.97 Author: mt Time: 15 January 2024, 6:41:20.905928 pm UUID: 122e8e23-da9c-9b48-b787-b6478bd54df7 Ancestors: Sound-ct.96
Fixes regression from Sound-tpr.93, which truncated too much during a sound's file-out.
=============== Diff against Sound-ct.96 ===============
Item was changed: ----- Method: AbstractSound>>storeSampleCount:bigEndian:on: (in category 'file i/o') ----- storeSampleCount: samplesToStore bigEndian: bigEndianFlag on: aBinaryStream "Store my samples on the given stream at the current SoundPlayer sampling rate. If bigFlag is true, then each 16-bit sample is stored most-significant byte first (AIFF files), otherwise it is stored least-significant byte first (WAV files). If self isStereo is true, both channels are stored, creating a stereo file. Otherwise, only the left channel is stored, creating a mono file."
| bufSize stereoBuffer reverseBytes streamDirect | self reset. bufSize := (2 * self samplingRate rounded) min: samplesToStore. "two second buffer" stereoBuffer := SoundBuffer newStereoSampleCount: bufSize. streamDirect := aBinaryStream isKindOf: StandardFileStream. reverseBytes := (bigEndianFlag xor: Smalltalk isBigEndian) xor: streamDirect not.
'Storing audio...' displayProgressFrom: 0 to: samplesToStore during: [:bar | | remaining out | remaining := samplesToStore. [remaining > 0] whileTrue: [ bar value: samplesToStore - remaining. stereoBuffer primFill: 0. "clear the buffer" self playSampleCount: (bufSize min: remaining) into: stereoBuffer startingAt: 1. out := self isStereo ifTrue: [stereoBuffer] ifFalse: [stereoBuffer extractLeftChannel]. reverseBytes ifTrue: [out reverseEndianness]. streamDirect ifTrue: "optimization for files: write sound buffer directly to file" + [aBinaryStream next: (out size // 2 min: remaining) putAll: out startingAt: 1] "size in words" - [aBinaryStream next: (out size // 2 min: remaining// 2) putAll: out startingAt: 1] "size in words" ifFalse: "for non-file streams:" + [1 to: (out monoSampleCount min: remaining * 2) do: [:i | aBinaryStream int16: (out at: i)]]. - [1 to: (out monoSampleCount min: remaining) do: [:i | aBinaryStream int16: (out at: i)]]. remaining := remaining - bufSize]].!
On 2024-01-15, at 5:41 PM, commits@source.squeak.org wrote:
Fixes regression from Sound-tpr.93, which truncated too much during a sound's file-out.
That's odd. I don't remember any specifics of that, but it was probably sometihng to do with updating NuScratch to handle the Pi change to using pulseaudio. Your fix is basically reverting to the prior version. It's that whole complicated dividicating by two thing.
tim -- tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim Calm down -- it's only ones and zeros.
Hi Tim --
Your fix is basically reverting to the prior version. It's that whole complicated dividicating by two thing.
Nah, it's still cutting of the silence at the end. We just had a "type issue" regarding the receiver and argument of #min:. Please report back if you get too-long sounds again.
In an example, we noticed that PluckedSound (3 seconds) cannot be exported correctly. Just 2 seconds got out, which is exactly the buffer size. We want all the 3 seconds. And not 4, which was your original fix.
| m | m := MixedSound new. 0 to: 1 do: [:pan | m add: PluckedSound default asSampledSound pan: pan]. test := [:sound | | b | b := ByteArray streamContents: [:stream | sound storeWAVSamplesOn: stream]. sound duration - (SampledSound fromWaveStream: b readStream) duration]. {test value: m sounds first. test value: m}
Best, Marcel
Best, Marcel
Am 15.01.2024 19:18:24 schrieb Tim Rowledge tim@rowledge.org:
On 2024-01-15, at 5:41 PM, commits@source.squeak.org wrote:
Fixes regression from Sound-tpr.93, which truncated too much during a sound's file-out.
That's odd. I don't remember any specifics of that, but it was probably sometihng to do with updating NuScratch to handle the Pi change to using pulseaudio. Your fix is basically reverting to the prior version. It's that whole complicated dividicating by two thing.
tim -- tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim Calm down -- it's only ones and zeros.
squeak-dev@lists.squeakfoundation.org