<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p>Hi David, thanks for the explanation!</p>
<p><br>
</p>
<p>Given that explanation, the patched method will still not work correctly for ByteArray on a BigEndian system, is that correct? (I do not have a BigEndian system available.) Should we define reverseBytes as the following instead?</p>
<p><br>
</p>
<p><span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt">reverseBytes := streamDirect ifTrue: [bigEndianFlag xor: Smalltalk isBigEndian] ifFalse: [bigEndianFlag].</span><br>
</p>
<p><span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt"><br>
</span></p>
<p><span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt">Best,</span></p>
<p><span style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt">Christoph</span></p>
<div id="x_Signature">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<div name="x_divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<div>
<div class="x__rp_T4" id="x_Item.MessagePartBody">
<div class="x__rp_U4 x_ms-font-weight-regular x_ms-font-color-neutralDark x_rpHighlightAllClass x_rpHighlightBodyClass" id="x_Item.MessageUniqueBody" style="font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont">
<div dir="ltr">
<div id="x_divtagdefaultwrapper"><font face="Calibri,Helvetica,sans-serif,EmojiFont,Apple Color Emoji,Segoe UI Emoji,NotoColorEmoji,Segoe UI Symbol,Android Emoji,EmojiSymbols">
<div id="x_Signature">
<div style="margin:0px"><font style="font-family:Calibri,Arial,Helvetica,sans-serif,serif,EmojiFont">
<div><font size="3" color="black"><span style="font-size:12pt"><a href="http://www.hpi.de/" target="_blank" rel="noopener noreferrer" id="LPNoLP"><font size="2"><span id="LPlnk909538"><font color="#757B80"></font></span></font></a></span></font></div>
</font></div>
</div>
</font></div>
</div>
</div>
</div>
</div>
<div><font size="2" color="#808080"></font></div>
</div>
</div>
</div>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von David T. Lewis <lewis@mail.msen.com><br>
<b>Gesendet:</b> Dienstag, 1. September 2020 20:48:55<br>
<b>An:</b> The general-purpose Squeak developers list<br>
<b>Betreff:</b> Re: [squeak-dev] The Trunk: Sound-ct.71.mcz</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">On Tue, Sep 01, 2020 at 06:03:09AM +0000, Thiede, Christoph wrote:<br>
> Hi David, hi all, thanks for merging!<br>
> <br>
> Do you know what Smalltalk endianness is good for? Is this maybe only relevant for FileStreams at all?<br>
<br>
Endianness is important when you need to know about the memory addressing<br>
conventions of the platform that Squeak is running on. For example, the<br>
elements of a ByteArray are always accessed consistenty in Smalltalk<br>
(e.g the first element is aByteArray at: 1). But the internal storage<br>
of the bytes in the object memory is done differently on little-endian<br>
versus big-endian platforms.<br>
<br>
If you look for senders of #endianness, #isBigEndian, and #isLittleEndian<br>
you will find lots of places where the endianness is important.<br>
<br>
It is worth noting also that the object memory gets fixed up for<br>
endianness when the image is loaded. Thus if you save an image on<br>
a little-endian machine, then load and run that image on a big-endian<br>
machine, then the byte ordering gets swapped at image loading time.<br>
Within Squeak, everything looks the same, but internally in the VM<br>
the bytes will be been swapped into the appropriate ordering.<br>
<br>
There is a good overview at <a href="https://en.wikipedia.org/wiki/Endianness">https://en.wikipedia.org/wiki/Endianness</a><br>
<br>
Dave<br>
<br>
> <<a href="http://www.hpi.de/">http://www.hpi.de/</a>><br>
> <br>
> Best,<br>
> Christoph<br>
> ________________________________<br>
> Von: Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von David T. Lewis <lewis@mail.msen.com><br>
> Gesendet: Dienstag, 1. September 2020 04:13:16<br>
> An: squeak-dev@lists.squeakfoundation.org<br>
> Cc: packages@lists.squeakfoundation.org<br>
> Betreff: Re: [squeak-dev] The Trunk: Sound-ct.71.mcz<br>
> <br>
> Thanks Christoph, good catch and thanks for the fix.<br>
> <br>
> I moved this and the supporting test immediately to trunk because it is<br>
> clearly a worthwhile change.<br>
> <br>
> All - Christoph requests detailed review, please do so and make any updates<br>
> if appropriate.<br>
> <br>
> I'm really happy to see long-overlooked details like this being addressed :-)<br>
> <br>
> Dave<br>
> <br>
> <br>
> On Tue, Sep 01, 2020 at 02:01:27AM +0000, commits@source.squeak.org wrote:<br>
> > David T. Lewis uploaded a new version of Sound to project The Trunk:<br>
> > <a href="http://source.squeak.org/trunk/Sound-ct.71.mcz">http://source.squeak.org/trunk/Sound-ct.71.mcz</a><br>
> ><br>
> > ==================== Summary ====================<br>
> ><br>
> > Name: Sound-ct.71<br>
> > Author: ct<br>
> > Time: 1 September 2020, 2:07:15.07999 am<br>
> > UUID: 0d91a1bf-41cb-834c-ab0c-fa2ad832e408<br>
> > Ancestors: Sound-nice.69<br>
> ><br>
> > Fixes wave sound streaming on non-filestream objects. The endianness was inverted because #int16: already uses Big Endian. This did not sound well - listen yourself in an unpatched image: :-)<br>
> ><br>
> > array := ByteArray streamContents: [:stream |<br>
> >        PluckedSound bachFugue storeWAVSamplesOn: stream].<br>
> > (FileStream fileNamed: 'bachFugue.wav') binary in: [:stream |<br>
> >        [array do: [:ea | stream nextPut: ea]]<br>
> >                ensure: [stream close]].<br>
> > (SampledSound fromWaveFileNamed: 'bachFugue.wav') play.<br>
> ><br>
> > Please review in detail as this is one of my first contacts to the Sound system!<br>
> ><br>
> > =============== Diff against Sound-nice.69 ===============<br>
> ><br>
> > Item was changed:<br>
> >   ----- Method: AbstractSound>>storeSampleCount:bigEndian:on: (in category 'file i/o') -----<br>
> >   storeSampleCount: samplesToStore bigEndian: bigEndianFlag on: aBinaryStream<br>
> >        "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."<br>
> ><br>
> > +      | bufSize stereoBuffer reverseBytes streamDirect |<br>
> > -      | bufSize stereoBuffer reverseBytes |<br>
> >        self reset.<br>
> >        bufSize := (2 * self samplingRate rounded) min: samplesToStore.  "two second buffer"<br>
> >        stereoBuffer := SoundBuffer newStereoSampleCount: bufSize.<br>
> > +      streamDirect := aBinaryStream isKindOf: StandardFileStream.<br>
> > +      reverseBytes := (bigEndianFlag xor: Smalltalk isBigEndian) xor: streamDirect not.<br>
> > -      reverseBytes := bigEndianFlag ~= (Smalltalk isBigEndian).<br>
> ><br>
> >        'Storing audio...'<br>
> >                displayProgressFrom: 0 to: samplesToStore during: [:bar | | remaining out |<br>
> >                        remaining := samplesToStore.<br>
> >                        [remaining > 0] whileTrue: [<br>
> >                                bar value: samplesToStore - remaining.<br>
> >                                stereoBuffer primFill: 0.  "clear the buffer"<br>
> >                                self playSampleCount: (bufSize min: remaining) into: stereoBuffer startingAt: 1.<br>
> >                                out := self isStereo<br>
> >                                                ifTrue: [stereoBuffer]<br>
> >                                                ifFalse: [stereoBuffer extractLeftChannel].<br>
> >                                reverseBytes ifTrue: [out reverseEndianness].<br>
> > +                              streamDirect<br>
> > -                              (aBinaryStream isKindOf: StandardFileStream)<br>
> >                                        ifTrue: [  "optimization for files: write sound buffer directly to file"<br>
> >                                                aBinaryStream next: (out size // 2) putAll: out startingAt: 1]  "size in words"<br>
> >                                        ifFalse: [  "for non-file streams:"<br>
> >                                                1 to: out monoSampleCount do: [:i | aBinaryStream int16: (out at: i)]].<br>
> > +                              remaining := remaining - bufSize]].!<br>
> > -                              remaining := remaining - bufSize]].<br>
> > - !<br>
> ><br>
> ><br>
> <br>
<br>
> <br>
<br>
<br>
</div>
</span></font>
</body>
</html>