Console Lua

I made a thing.

ConsoleLua is a simple game engine for making character-mode games reminiscent of the kinds of things one would write in QBasic on a DOS-based PC in the early 1980s.

Snakes In a Game

The sad part is that it took me almost as long to write the documentation as it did to write the program itself.

("It's like, how much more pointless could this be? And the answer is none. None more pointless.")

In hindsight, I should have made the Windows Console API bindings a Lua library and compiled it into a DLL so any Lua project could use it. I could still do that and then base the ConsoleLua application on it.


Fixing LCD Image Persistence

I noticed that my primary monitor at work had developed a bad case of image persistence, so I wrote a simple utility in Processing to fix it. It displays a full-screen borderless window full of rapidly-changing RGB noise that "shakes loose" the persistent image stored in the liquid crystals. It might even help with stuck pixels; that's what the program that inspired it (JScreenFix) does.

How to use this program:

  1. Download and install Processing
  2. Launch Processing and copy the source code below into the editor window
  3. Run the sketch for (say) half an hour or so

// render buffer
PGraphics graphics;

// size of each pixel block
final int zoom = 4;

boolean sketchFullScreen()
  return true;

void setup()
  size(displayWidth, displayHeight);
  colorMode(RGB, 1);
  graphics = createGraphics(width / zoom, height / zoom);

void draw()
  for (int i = 0; i < graphics.pixels.length; ++i)
    graphics.pixels[i] = color(random(1), random(1), random(1));
  // draw the render buffer with scaling
  image(graphics, 0, 0, width, height);

Voice Command

I wanted to set an 8AM wake-up alarm like I had set on my previous phone but had no idea where to look for that in Android. I clicked on the microphone icon and said "set alarm", which took me right to it. Handy!

The more I use this phone, the more I like it. :)

Semi-reluctantly joining the 21st century

After years of using cheap flip-phones, I finally got a smarphone (an 8GB 4G LTE Moto G). So far I've set up account info, connected to the WiFi at my apartment, called my parents to try it out, and noodled around with various settings. It'll take some getting used to.

(This was not posted from it. I haven't figured it out that well yet.)

Spectrum Analyzer

I found out earlier this week that I was doing the spectrum analyzer wrong.

I had noticed from the beginning that I got broad "cusp" shapes with long tails on either side instead of narrow vertical bars. It turns out that I was asking BASS to do a Fast Fourier Transform much larger than the audio buffer so it was padding the sample data with zeroes. The incomplete data acted as a rectangular windowing function that smeared out the frequency response. Increasing the audio buffer length solved (or at least reduced) that problem but introduced unacceptable latency.

I found this out while attempting to replace the FFT with a filter bank based on the Goertzel algorithm. That didn't pan out, so I tried implementing my own FFT that would process a larger "sliding buffer". Getting clean data turned out to be harder than I expected, and I ended up using the BASS library's "DSP" feature to harvest the audio data and add it to the sliding buffer. I did get everything working correctly but I didn't like having to maintain my own copy of the FFT and looked for an alternative.

After a variety of failed attempts, I hit upon using a decode stream with custom callback that returns data from the sliding buffer. It always returns enough data for the 8192-point FFT, so the spectrum looks correct. Huzzah!


New build of Mini-Synth

It's been a while since I've posted a new version of the mini-synthesizer. It has a significantly faster filter, improved sound output, revised menu system with effects on a separate page, "colored noise" oscillator (controlled by Width parameter of Noise oscillator), sample-and-hold and linearly-interpolated noise oscillators, improved spectrum analyzer, and a variety of bug fixes and optimizations.

The new version is available here