Tuesday, January 26, 2021

Sisyphean Programming

The world seems buggy at the moment. Blogger is slow and unreliable since the last Windows update.

I was awake for too long last night thinking about this annoying bug in my music software. I thought that it might be down to a memory infringement by a plug-in, so I started (at 11pm) to think of how to test this. Lots of plug-ins use effect buffers; a classic example is a delay, which stores the current output in a sort of loop, so a one second delay needs a second's worth of data (so 44100 samples, at 'CD quality'). I came up with a solution to test for a memory infringement; I'd reserve 4 extra bytes (not 1 because even numbers are more efficient) and fill those with an unusual number, say 99. After using the plug-in I will see if those 99s are all still there. If so then all is well. If not then the buffer has been accidentally exceeded.

It worked, I made a test plug-in that was deliberately buggy and this was detected. Unfortunately, none of the actual plug-ins were though, they were fine. In practice, there aren't many of the 100 or so effects that use buffers. They are delays, delay related effects (chorus, flange), reverbs, and a few other special ones that all use little delays inside. The reverbs are the most complex because they contain a LOT of little delays inside, up to 20 per channel, but even so, it looks like I calculated everything well enough.

Sigh, so at least it's not this.

Then I revisited my code again and sought out lots of possible bugs. Trying to find this rare crash became an obsession and I hardly took more than a few minutes from my computer screen all day. I found one bug in the memory reporting code - but that was a miscalculation, hardly a bug. I noted that some songs, like the Nick Drake one, take up about 500Mb of memory (mostly samples).

I then found a feature called Code Analysis which asks the compiler what it thinks. This spotted a few possible errors, null pointers and possible memory infringements. In practice though, none of those should have been serious... except one. One definite null pointer bug was there in the Event List display code. This is odd; it should have, could have, caused a crash at any time, but is unlikely to be my problem as the event list isn't really updated at the time when the crash occurs, and if it did crash, it would have been easy to spot because it would have happened at a specific and predictable time. Still, I fixed this and tidied up about 10 smaller issues.

This took me to the evening. I decided to record the vocals to the Nick Drake song, which sounds rather nice. Most of these vocals are very simple, no complex effects. The two songs I've recorded so far are the simplest vocally.

I read about Beethoven's Heiligenstadt Testament before sleeping and remembered my own contemplation of suicide at a similar age.

I have many musical ideas. I must try to focus now on the music and stop obsessing about this bug.