<div dir="ltr"><div dir="ltr"><div class="gmail_default">Hi Herbert, Hi Tim,</div><div class="gmail_default"><br></div><div class="gmail_default">    I suspect I've made a mistake somewhere.  This used to play smoothly and now I can hear some distortion and it's unlilely to do with my speakers, as the same is heard either through my laptop speakers or my apple display speakers:</div><div class="gmail_default"><br></div><div class="gmail_default"><div class="gmail_default"><font face="times new roman, serif">| samples sineTable sound |</font></div><div class="gmail_default"><font face="times new roman, serif">"1 second of A below middle C (220Hz). 16000 / 220 is 72.72 recurring"</font></div><div class="gmail_default"><font face="times new roman, serif">sineTable := SoundPlayer sineTable: 73.</font></div><div class="gmail_default"><font face="times new roman, serif">sineTable doWithIndex: "And let's not deafen anyone..."</font></div><div class="gmail_default"><font face="times new roman, serif"><span class="gmail-Apple-tab-span" style="white-space:pre">    </span>[:sample :index| sineTable at: index put: sample // 4].</font></div><div class="gmail_default"><font face="times new roman, serif">samples := SoundBuffer new: 16000.</font></div><div class="gmail_default"><font face="times new roman, serif">1 to: samples size by: sineTable size do:</font></div><div class="gmail_default"><font face="times new roman, serif"><span class="gmail-Apple-tab-span" style="white-space:pre">    </span>[:i| samples replaceFrom: i to: (i + sineTable size - 1 min: 16000) with: sineTable startingAt: 1].</font></div><div class="gmail_default"><font face="times new roman, serif">1 to: 146 do:</font></div><div class="gmail_default"><font face="times new roman, serif"><span class="gmail-Apple-tab-span" style="white-space:pre">      </span>[:i|</font></div><div class="gmail_default"><font face="times new roman, serif"><span class="gmail-Apple-tab-span" style="white-space:pre">  </span>samples at: i put: ((samples at: i) * i / 146) asInteger.</font></div><div class="gmail_default"><font face="times new roman, serif"><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>samples at: 16001 - i put: ((samples at: 16001 - i) * i / 146) asInteger].</font></div><div class="gmail_default"><font face="times new roman, serif">sound := SampledSound</font></div><div class="gmail_default"><font face="times new roman, serif"><span class="gmail-Apple-tab-span" style="white-space:pre">                       </span>samples: samples</font></div><div class="gmail_default"><font face="times new roman, serif"><span class="gmail-Apple-tab-span" style="white-space:pre">                      </span>samplingRate: 16000.</font></div><div class="gmail_default"><font face="times new roman, serif">sound := MixedSound new</font></div><div class="gmail_default"><font face="times new roman, serif"><span class="gmail-Apple-tab-span" style="white-space:pre">                   </span>add: sound pan: 0.25;</font></div><div class="gmail_default"><font face="times new roman, serif"><span class="gmail-Apple-tab-span" style="white-space:pre">                 </span>add: sound pan: 0.75;</font></div><div class="gmail_default"><font face="times new roman, serif"><span class="gmail-Apple-tab-span" style="white-space:pre">                 </span>yourself.</font></div><div class="gmail_default"><font face="times new roman, serif">sound play</font></div><div class="gmail_default"><br></div><div class="gmail_default">So I'll try and do a regression test soon.</div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 29, 2020 at 10:53 AM Herbert König <<a href="mailto:herbertkoenig@gmx.net">herbertkoenig@gmx.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
  
    
  
  <div>
    I changed playLoop to just copy the current SoundBuffer into a
    collection. I got some 11 seconds sound (2 below) <br>
    Each buffer I differentiated and took the abs value. (see attached
    st) <br>
    Of those I took the max. In case of wraparound that would be close
    to 64k.  <br>
    The zeroes in these buffers are the clippings. (3 below) Again I
    took the max. (4 below). <br>
    <br>
    I can't email screenshots from the Pi but I did it on a Pi too. I
    used Tim's first snippet. I found a lot of clipping inside Squeak
    and not a single wraparound in several attempts.<br>
    <br>
    Same observation id waggling the Keyboard or playing my 6 voiced C
    major while waggling the keyboard morph.<br>
    <br>
    On the Pi3 I still lost buffers (getting 7 seconds worth of buffers
    from 10+ seconds of Audio). I would not search in the Squeak
    Smalltalk code for the problem but would suspect the primitive where
    Squeak hands the output to Raspbian. <br>
    <br>
    That said clipping still makes for horrible sound (SCNR :-).<br>
    <br>
    Cheers,<br>
    <br>
    Herbert<br>
    <br>
    <br>
    <img src="cid:176afe0224c6567fb471" alt="">
    <div>Am 29.12.2020 um 12:38 schrieb Herbert
      König:<br>
    </div>
    <blockquote type="cite">
      <br>
      <br>
      Am 28.12.2020 um 22:48 schrieb tim Rowledge:
      <br>
      <blockquote type="cite">
        <blockquote type="cite">On 2020-12-28, at 10:36 AM, Herbert
          <a href="mailto:herbertkoenig@gmx.net" target="_blank"><herbertkoenig@gmx.net></a> wrote:
          <br>
          <br>
          Inside Squeak I saw a lot of clipping as expected, outside I
          saw
          <br>
          wrapping whenever it clipped inside.
          <br>
        </blockquote>
        That would be an interesting thing to prove conclusively. It's
        not unimagineable that there could be a bug in a unix sound
        library.
        <br>
      </blockquote>
      I'd suspect the Squeak primitive that hands the buffers to the OS
      before
      <br>
      looking into OS code.
      <br>
      <br>
      Would it be conclusive to record the outside for a minute or so,
      read
      <br>
      that file and count wrapping
      <br>
      (sample(n) = +fullscale and sample(n+1) = -fullscale) or
      (sample(n) =
      <br>
      -fullscale and sample(n+1) = +fullscale)
      <br>
      and do the same for all SoundBuffers we get hold of inside Squeak
      during
      <br>
      the recording? (repeatedly checking SoundBuffer allInstances)
      <br>
      <br>
      <blockquote type="cite">Maybe if we make a crafted sound buffer
        with a clean waveform that we know never gets clipped but does
        hit the maxval/minval and play it directly with no mixing
        related calls (because the mixer code does volume scaling etc
        and internal clipping) we might see what comes out of pulseaudio
        and indeed alsa.
        <br>
      </blockquote>
      AbstractSound or the like has a class var Sine with that but I
      feel
      <br>
      that's directed at finding a bug in the OS and discards the
      possibility
      <br>
      of Squeak messing it up. And the organ sounds used are predictable
      <br>
      enough re clipping but I hope the individual envelopes add some
      <br>
      randomness to cover more cases.
      <br>
      <br>
      Cheers,
      <br>
      <br>
      Herbert
      <br>
      <br>
      <br>
    </blockquote>
    <br>
  </div>

<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>