claude<p>In 2010 I made an <a href="https://post.lurk.org/tags/AudioVisual" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>AudioVisual</span></a> piece using <a href="https://post.lurk.org/tags/Haskell" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>Haskell</span></a>, <a href="https://post.lurk.org/tags/OpenGL" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>OpenGL</span></a>, and <a href="https://post.lurk.org/tags/SC3" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>SC3</span></a>:</p><p><a href="https://mathr.co.uk/blog/2010-03-12_bowntz.html" rel="nofollow noopener" target="_blank"><span class="invisible">https://</span><span class="ellipsis">mathr.co.uk/blog/2010-03-12_bo</span><span class="invisible">wntz.html</span></a></p><p>This weekend I ported it from Haskell to <a href="https://post.lurk.org/tags/C" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>C</span></a>, using <a href="https://post.lurk.org/tags/SDL2" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>SDL2</span></a> as framework including <a href="https://post.lurk.org/tags/audio" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>audio</span></a> in the same program (SC3 was overkill for the simple sounds, and maintaining Haskell code to keep working with changes to the ecosystem is too much busy-work).</p><p>I changed the colours (suggested by <span class="h-card"><a href="https://post.lurk.org/@netzzz" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>netzzz</span></a></span>), moved the <a href="https://post.lurk.org/tags/physics" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>physics</span></a> <a href="https://post.lurk.org/tags/simulation" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>simulation</span></a> from the <a href="https://post.lurk.org/tags/video" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>video</span></a> thread to the <a href="https://post.lurk.org/tags/audio" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>audio</span></a> thread for tighter timing (the SC3 version scheduled events with bundles), and added a <a href="https://post.lurk.org/tags/RingBuffer" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>RingBuffer</span></a> to send the visualisation data back to the video thread (for smoother animation with good a/v sync).</p><p>I also did various optimisations, using tables instead of trigonometric functions, using (client-side) vertex arrays instead of glBegin().</p><p>License changed from <a href="https://post.lurk.org/tags/GPL" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>GPL</span></a> v3 or later to <a href="https://post.lurk.org/tags/AGPL" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>AGPL</span></a> v3 only, in anticipation of compiling it to run in the browser using Emscripten.</p><p>Code at:<br><a href="https://code.mathr.co.uk/bowntz" rel="nofollow noopener" target="_blank"><span class="invisible">https://</span><span class="">code.mathr.co.uk/bowntz</span><span class="invisible"></span></a></p><p>There's still (at least) one bug: after some time the program freezes and uses 100% CPU, I think it happens when the ball count limit is reached. Takes a long time so will be hard to figure out what is going on...</p>