May 23
I use vim coupled with the SuperTab plugin for my text editing and auto-completion needs. In some vim setups (E.g. Mac OS X) it is configured by default to search included files when completing words. This sounds like a useful feature but it turns out not to be. It has a habit of searching the include files of system libraries and modules, the keywords of which you rarely want. Its also quite a slow operation as it trawls through all the files. The solution is to add the following in your .vimrc file.
set complete=.,w,b,u,t
This is the same set of flags as the default except with the ‘i‘ option removed. See the help for the ‘complete’ option for an explanation of what each flag means.
Apr 16
For my current software project I have the need to decode MP3 files for the purpose of producing an audio waveform. It doesn’t need to be overly accurate as the decoded samples will be displayed, not played. However it does need to be fast, as a typical use case for the application will be MP3 files of around 100Mb (full length CDs). The application is for Mac OS X, although the results of my testing below could be useful for other platforms.
Assisted by a code sample from Apple I wrote an initial version of the decoder that would read the source MP3 file and write the raw linear PCM data out to a file. I did this using the Core Audio framework built into Mac OS X. Once the program was working I tested it against some sample files and came to the conclusion that 4 seconds to decode a 3 min track was great but over 100 seconds for a full length CD, not so great.
I did some searching and came up with two other libraries that seemed well suited to the task of MP3 decoding, they were mpg123 (libmpg123) and MAD (libmad). mpg123 had claims of being very fast, mad claimed it was very accurate.
Methodology
I built the two additional libraries with the default configuration options, except for libmad, which I added the --enable-speed option. With the help of example code I made programs out of each that were comparable to the first version for Core Audio. I.e. MP3 file in, 16-bit Linear PCM audio samples out.
To provide a benchmark I wrote a script that would run each of the three programs against a source MP3 file. Each program reported the elapsed time (via time(3)) and the processor time (via clock(3)) when it finished decoding. The programs were run one after another on the source file 10 times. Their PCM output was written to a new file for each invocation.
Continue reading »
Apr 15
I snapped this with my my phone whilst I was shopping at Safeway last Sunday. It seems the Australian Women’s Weekly are Linux fans or aren’t aware that they may be infringing Larry Ewing’s copyright. Who wouldn’t want a Tux cake though.
Mar 27
Strangely enough I had the need to determine if it was possible to create a valid but empty tar file. Turns out it is. The method varies slightly depending on your flavour of tar program, here’s how to do it on three of the big ones:
BSD
tar cvf empty.tar --from-file /dev/null
GNU (Linux)
tar cvf empty.tar --files-from /dev/null
Solaris
tar cvf empty.tar -I /dev/null
Now if you wondering why I would want this, here’s the explanation. I work on a batch processing system that processes files delivered from other systems. In some cases its necessary to wait for a file to arrive but give up after some time. In order to give up we copy and empty file (automatically) so that the processing proceeds normally. Ordinarily this is an empty plain file but for the system I’m working on I’m expecting a tar file, hence the need for an empty one.