<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi David,</p>
    <p>While your code runs without error, the file produced has wrong
      byte ordering and sounds wrong, at least on my Mac. I preferred
      simplifying the method a bit. Just pushed the updated package to
      GitHub.</p>
    <p>Thanks,</p>
    <div class="moz-cite-prefix">On 2026-03-02 11:30 AM, David Gouge via
      Cuis-dev wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:cBASXs4vRrvatiJkC51_vbLJrcAHfIov1y2yf0ByEUEUeMsGwecODVxNe_KLJybe5Qz89AfFDp6kv_lHCCTPVEus6xar4j8KeiXZPNR0sRg=@pm.me">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div style="font-family: Arial, sans-serif; font-size: 14px;">
        <p>It seems that I just found a small bug when playing around
          with the Sound package.</p>
        <p>From a Workspace do:</p>
        <p>Feature require: 'Sound'.<br>
          (PluckedSound default) storeWAVOnFileNamed: '/tmp/foo.wav'.</p>
        <p><br>
        </p>
        <p>Exception raised.. Here's the offending stack:</p>
        <p>SoundBuffer(Object)>>doesNotUnderstand: #asUtfBytes</p>
        <p> UniFileStream>>nextPutAll:: aStringOrBytes<br>
              "Argument can be String, UnicodeString or ByteArray.<br>
              Write to this file. Both kinds of Strings are UTF-8
          encoded."<br>
          <br>
              | bytes |<br>
              aStringOrBytes isEmpty ifTrue: [ ^self ].<br>
              bytes := aStringOrBytes.<br>
              (aStringOrBytes is: #ByteArray) ifFalse: [<br>
                  bytes := aStringOrBytes asUtf8Bytes].   <--- 
          Exception raised here.</p>
        <p><br>
        </p>
        <p>My naive newbie fix is as follows: </p>
        <p>AbstractSound>>storeSampleCount: samplesToStore
          bigEndian: bigEndianFlag on: aBinaryStream</p>
        <p>.. Clipped ..<br>
          <br>
              'Storing audio...' displayProgressAt: Sensor mousePoint<br>
                  from: 0 to: samplesToStore during: [:barBlock | |
          remaining out |<br>
                      remaining := samplesToStore.<br>
                      [remaining > 0] whileTrue: [<br>
                          barBlock value: samplesToStore - remaining.<br>
                          stereoBuffer primFill: 0.  "clear the buffer"<br>
                          self playSampleCount: (bufSize min: remaining)
          into: stereoBuffer startingAt: 1.<br>
                          self isStereo<br>
                              ifTrue: [out := stereoBuffer asByteArray]
          "<-- answer ByteArray instead of SoundBuffer"<br>
                              ifFalse: [out := stereoBuffer
          extractLeftChannel asByteArray]. "<--- and here"</p>
        <p>... Clipped ..</p>
        <p>This has let me work around the bug but I'm a complete Cuis
          noob so take it FWIW.</p>
        <p><br>
        </p>
        <p>Best Regards,</p>
        <p>-Dave </p>
        <br>
      </div>
      <div style="font-family: Arial, sans-serif; font-size: 14px;"><br>
      </div>
      <div style="font-family: Arial, sans-serif; font-size: 14px;"
        class="protonmail_signature_block">
        <div
class="protonmail_signature_block-user protonmail_signature_block-empty">
        </div>
        <div class="protonmail_signature_block-proton"> Sent with <a
            href="https://proton.me/mail/home" target="_blank"
            moz-do-not-send="true">Proton Mail</a> secure email. </div>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Juan Vuletich
<a class="moz-txt-link-abbreviated" href="http://www.cuis.st">www.cuis.st</a>
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich</pre>
  </body>
</html>