Archive for programming

perks and perils of caffine

At my job, we have one of those new espresso pod machines in the kitchen. Usually after lunch, I’ll start to get a little drowsy and need a caffine kick.

Today, I chose the heavy duty espresso forte pod and made myself a double espresso.

After finishing it, I immediately found the puzzling bug that the lead dev and I had been staring at. Super. I then misread the spec and dove deep into Qt4′s QTableView MVC architecture before coming up for air.

There are twothreefour1 things wrong with caffine.

  1. Too much and I get anxious and my heart starts jumping
  2. I start thinking too fast and making mistakes
  3. I hear you can build up a tolerence, so I’d need more and more to have the same effect
  4. The inevitable crash

I try to not have it every day, so I can preserve the wonderful, creative effect it has.2

  1. No one expects the Spanish Inquisition! []
  2. This post was a result of caffine []

Comments

smart counting with dynamic_bitset and boost.framework

In Ardour, we have numbered audio tracks named Track 1, Track 2, and so on. Most software when faced with what to name the next created track will just use a static int that is incremented with each track.

With Ardour, we wanted to make it smarter. We wanted to be able to re-add Track 1 if the first track was deleted. But not if the first track had just been renamed. We use C++ for the libardour backend, so we were in luck.

The STL includes bitset, a very handy wrapper for what’s essentially an array of booleans, but optimized for space.

The technique is: look for the first false slot in the bitset. The index is the number of the new track. When a track is deleted, mark the slot as false. This lets the user rename a track and it won’t interfere with the counting.

The one problem with this is the size of a bitset is set at compile time. You could use vector<bool>, but its use is discouraged. Luckily, boost.org has an implementation of dynamic_bitset which can be grown during runtime.

This smart counting gives Ardour a polish and the users love it.

I’ve created a boost.framework for those of you lucky enough to be using C++ on OS X. It’s all header files, so you only need to include it in the frameworks path. It doesn’t need to be linked in. It unzips to a large size, but you only pay for what you use.

Comments

« Previous Page « Previous Page Next entries »