Sat, 18 Oct 2008
Foobar 2000 and the Rabbit.
Foobar 2000 (see also the Wikipedia entry) is a media player for a legacy operating system commonly known as Microsoft Windows. Secret Rabbit Code is an audio sample rate converter that I wrote, and released under the terms of the GNU GPL 2002.
As the sole author and copyright owner of Secret Rabbit Code I have also made it available under a commercial use license (PDF) that is currently earning me a small income. However, developing Secret Rabbit Code was difficult, took a huge amount of research and the development of many prototypes which were thrown away. Now, after 6 years, that income is coming close to covering the cost of developing that initial version. It still has some way to go to cover the cost of the subsequent maintenance and the improvements I have made.
In 2005 I became aware that someone had released a binary only plugin for Foobar 2000 that used Secret Rabbit Code to do sample rate conversion. The fact that this was a binary only release was not the only problem. There was also the problem of Foobar being under a license that was not GPL compatible.
First off, I emailed the ISP in France where the binary was being hosted and asked for the download to be taken down. I also tried to track down the author of the plugin since authorship was not obvious from the download. Within a day or two I was able to track him down via the Hydrogen Audio forums.
The final result of the discussion on that forum was that I decided I would write and release a Secret Rabbit Code based plugin for Foobar. This of course involved development for windows on windows a platform I rarely if ever use and which I actually prefer not to work on. However after some 10 or 12 hours work I had a working plugin that I posted on my website. I also added a Paypal donation button on the page hoping to get paid for the time and effort I put into creating the plugin.
Unfortunately, the donations have been few and far between. Since 2005 when the plugin was released I have only had about 10 people pay the measly US$10 I am asking for. That is despite the fact that I have proven interest in this plugin. The page has had over 30000 hits since 2005, and I get an email every couple of weeks asking if there is a more recent version using later versions of Secret Rabbit Code or a version for other versions of Foobar 2000.
So here's how it stands:
- I don't use Windows or the Foobar 2000 program.
- As someone who has been coding on Unix and Linux for well over a decade and rarely touches windows this work was a rather painful and unpleasant exercise.
- I spent my precious time developing this plugin for a platform I don't use
- For the 10-12 hours work I put into this plugin I have received about US$100 which means I got paid US$8 to $10 per hour for my time. This is a small fraction of my normal salary as a professional software engineer with well over a decade of experience.
- The fact that I release the Rabbit for free (as in free beer) under the terms of the GPL is irrelevant. I use dozens of GPL and other FOSS (Free and Open Source Software) programs every day and I consider the Rabbit and my other project libsndfile as my paltry contribution back to the FOSS cause.
Since most users of this plugin don't think I should be paid for my work creating it for use with Foobar on Windows, I currently have no intention of releasing a new version of this plugin. When and if I get a decent stream of payments for the work I have put in so far I will roll out a new version and maybe even an updated plugin for other versions of Foobar.
I will answer Foobar related emails from people who have donated or work for companies that paid for a commercial use license. The vast majority of other emails regarding the Foobar plugin will be directed to this blog post.
Posted at: 09:21 | Category: CodeHacking/SecretRabbitCode | Permalink
Sun, 30 Mar 2008
libsamplerate 0.1.3.
About a week ago I released a new version of SecretRabbitCode (aka libsamplerate).
The major change was that the new improved SINC based converters I blogged about here are now the default. There were also a couple of minor bug fixes.
The fine people at Infinitewave have now updated their test results to include the new converter and it shows Secret Rabbit Code comes very close to the best of the commercial converters in terms of quality.
Posted at: 15:11 | Category: CodeHacking/SecretRabbitCode | Permalink
Sat, 08 Mar 2008
Progress on the Rabbit.
For over three years now, I have been working on (on and off, but mostly off) a new algorithm for doing audio sample rate conversion in Secret Rabbit Code. The idea for the new algorithm has been rattling around in my head for most of that time, but the problem was always the implementation. While I am making progress it has been slow.
However, a public comparison between a large collection of converters showed that while the conversion quality of Secret Rabbit Code was good, it was nowhere near state of the art.
In order to see if I could get Secret Rabbit Code closer to state of the art quickly, I decided to revisit the existing converter during the xmas/new-year break.
The existing converter had a set of digital filters whose coefficients were generated by a small program written in GNU Octave. My first task was to convert that program to Ocaml which has become my favourite language for technical computing. I then spent quite a bit of time finding and analyzing where the filter design program was loosing precision and finding work arounds. Finally, I spent even more time looking at how the different filter design parameters interact with one another and with the conversion algorithm itself.
Fortunately, all this work has paid off. The result is new versions of the SRC_SINC_MEDIUM_QUALITY and SRC_SINC_BEST_QUALITY converters. The old versions of these converters have been renamed to SRC_OLD_SINC_MEDIUM_QUALITY and SRC_OLD_SINC_BEST_QUALITY. The old versions will be removed once the new versions have been fully validated.
So far, the new converters seem to have significantly improved signal to noise ratio as can be seen from the following to spectrograms (using the methodology described here). It should be obvious from these plots that the new versions of the converters have significantly less artifacts (the purple and blue bits) than the old converters.
Obviously, conversion quality is not the only criterion to evaluate sample rate converters; conversion speed can also be important in some situations. In my preliminary testing, the updated Best SINC converter runs up to 25% slower than the old one. The new best converter also uses significantly more memory than the old one. Storage of filter coefficients has gone up by a factor of 20, which is now over a megabyte for best quality converter alone.
In the tables below I've listed the SNR, throughput speeds and bandwidths as measured by the test suite (the snr_bw_test and throughput_test programs) distributed with the code for a couple of different CPU types.
1.1 GHz Intel Pentium M (32 bit) with 2048 KB cache
| Converter Name | SNR | Throughput | Bandwidth |
|---|---|---|---|
| SRC_OLD_SINC_MEDIUM_QUALITY | |||
| SRC_SINC_MEDIUM_QUALITY | |||
| SRC_OLD_SINC_BEST_QUALITY | |||
| SRC_SINC_BEST_QUALITY |
|
1.8 GHz AMD Opteron 265 (64 bit) with 1024 KB cache
| Converter Name | SNR | Throughput | Bandwidth |
|---|---|---|---|
| SRC_OLD_SINC_MEDIUM_QUALITY | |||
| SRC_SINC_MEDIUM_QUALITY | |||
| SRC_OLD_SINC_BEST_QUALITY | |||
| SRC_SINC_BEST_QUALITY |
|
1.86GHz Intel Core Duo (32 bit) with 2048 KB cache
| Converter Name | SNR | Throughput | Bandwidth |
|---|---|---|---|
| SRC_OLD_SINC_MEDIUM_QUALITY | |||
| SRC_SINC_MEDIUM_QUALITY | |||
| SRC_OLD_SINC_BEST_QUALITY | |||
| SRC_SINC_BEST_QUALITY |
|
A pre-release containing these updated converters is available for download here. Once they have been tested a little more widely I intend to replace the old versions of the converters with the new, higher specification ones.
Anybody who wants to discuss this further should join the SRC mailing list and discuss it there.
Finally, once a version of Secret Rabbit Code with these new converters has been officially released I can get back to the new converter algorithm which should at least match the what I have here in terms of quality but run significantly faster and use at least an order of magnitude less RAM.
Posted at: 14:50 | Category: CodeHacking/SecretRabbitCode | Permalink
Tue, 30 Jan 2007
SRC Comparison.
One of my Free Software projects is Secret Rabbit Code, aka libsamplerate, aka the Rabbit, a library for performing sample rate conversion (Wikipedia) on audio signals. Recently, a company in Canada did a comparison of a number sample rate converters in professional audio software and also included the Rabbit in that test.
The tests were carried out by generating a input signal at a sampling rate of 96 kHz, configuring each sample rate converter to to do a conversion from 96 kHz input sample rate to 44.1 kHz output sample rate and passing the input signal through each converter and capturing each converter's output. The input test signal was a sine wave which sweeps from a low frequency of about 100 Hz at the start to a frequency of 44.1 kHz at the end. Finally, a spectrogram is then generated from each output signal.
The spectrogram of the output of Secret Rabbit Code's Best Sinc converter looks like this:
The spectrogram shows time in seconds along the x-axis and frequency in Hertz along the y-axis. The colour indicates the signal strength at each point in time and frequency, with white being the strongest signal (0 decibels) and black being the weakest signal (-180 decibels).
The tricky thing about the sample rate conversion process is that for any given sample rate fs, the highest frequency signal that can be correctly represented is at fs/2. When sample rate converting from 96 kHz to 44.1 kHz, all frequencies above half of the destination sample rate must be removed during the conversion process. Failure to do so will result in audio distortion and noise in the output signal.
Looking at the spectrogram of the Rabbit's output, its easy to see that the the main sweep (in bright white) clearly goes from some low frequency at the start to 22.05 kHz (half of the output sample rate) at 5 seconds. After about 5 seconds, the input signal's sine wave frequency goes above half the destination sample rate and the Rabbit does the correct thing and almost completely removes it.
The rest of the colour in the spectrogram is an artifact of the conversion process but by referencing the colour scale, its possible to confirm that all of these artifacts are 100 decibels below the level of the main signal. Ideally they shouldn't be there at all, but if they are the should be as low as possible.
Anyone who has read this far can now go to the comparison page pick any two converters and compare them. They can also confirm for themselves that although the Rabbit (Best Sinc) wasn't the best converter among the ones tested (that award would have to go to r8brain and iZotope), it certainly didn't disgrace itself either. A number of the commercial converters in expensive software packages (like Sony Vegas and Digital Performer) didn't perform all that well in comparison.
The good news is that the existence of commercial closed source converters that are better than the Rabbit gives me some incentive to come up with a better converter for inclusion in the Rabbit.
Posted at: 23:18 | Category: CodeHacking/SecretRabbitCode | Permalink