Resampling in Mac OS part 2 :)

After a few snarky messages from Mac owners, I thought I had better post a follow-up. I experimented a little at the weekend and found the following:

If I leave my soundcard (Audiophile Firewire) permanently on 96kHz, then:

iTunes will resample to 96kHz internally, with quality that sounds just fine.

VLC will output at whatever the sample rate of the media is, and get resampled to 96k by AUHAL on its default quality setting, which sounds a bit sketchy.

But, VLC can be set to always output at a particular rate, resampling internally. There’s an option called “Frequency” in the advanced audio preferences. According to VLC’s debug stream, it uses a module called “bandlimited_resampler”, and that’s encouraging, because it suggests that the guy who coded it knows the word “bandlimited”. It uses about 6% CPU time, and again, sounds fine. Thanks to the wonders of open source, we can see bandlimited.h here! Ooo, a 1536 point sinc kernel with linear interpolation and single-precision floating point arithmetic.

I got VLC’s “Media Library” to work too, so it can store a playlist, remembering what FLAC stuff I have and the track order of it.

I’ve not tried to play DVDs yet, but hopefully the computer won’t catch fire.

So in conclusion, I’m upgrading this from “:(” to “:)”

Resampling in Mac OS :(

Recently I’ve been experimenting with higher definition music downloads. For example, the Studio Masters recordings from Linn Records, or the material from B&W Society Of Sound. Everything went nicely until I got my new Mac.

First of all, the only lossless format supported by iTunes is Apple Lossless. It won’t play FLAC (the open source Free Lossless Audio Codec) properly, even with the extensions, Fluke, or whatever. A bummer, as I already had a fair amount of music in FLAC format. Sure, VLC will play it, but VLC can’t understand iTunes playlists.

Second, Linn don’t support Apple Lossless. They supply their music in FLAC and WMA formats only. I guess they’d rather you bought their own stupid, overpriced DS network media players, even if you have a Mac already.

Third, Mac OS resamples! Windows was smart enough (or dumb enough?) to set your audio hardware to the actual sample rate and bit depth of the track that was currently playing. Or at least the setup I used, Winamp Classic with the ASIO driver, would do that, guaranteeing bit-accurate output under all conditions.

The Mac doesn’t. You set the sample rate and bit depth once and for all in the audio control panel, and all the sound gets resampled to that. You can play 96kHz material till you’re blue in the face, using any player application you like, but if the system sample rate is set to 44.1, it’ll get downsampled. Watch a DVD, and the sound is getting resampled from 48 to 44.1.

I don’t know about you, but I wouldn’t trust any resampling algorithm I hadn’t written or at least tested myself. They’re notoriously hard to get right. And a “right” one consumes so much CPU power that there’s a real incentive to downgrade the performance deliberately.

Here’s the official line from the Coreaudio mailing list, found here

This was a comment posed to the list (which was replayed verbatim from Benchmark’s Elias Gwinn)
> […] If the user changes CoreAudio’s sample-rate in AudioMIDI Setup to something different than what iTunes is locked to, CoreAudio will convert the sample rate of the audio that it is receiving from iTunes. In this case, the audio may be undergoing two levels of sample-rate conversion (once by iTunes and once by CoreAudio). (The SRC in iTunes is of very high quality (virtually inaudible), but the SRC in CoreAudio is horrible and will cause significant distortion.) If the user wants to change the sample rate of CoreAudio, iTunes should be restarted so that it can lock to the correct sample rate.

This is the response from an Apple employee:
iTunes uses the AudioConverter API internally but we set the quality to “max” and AUHAL probably uses the default (I don’t know). One SRC at max quality followed by one at the default quality is not so great when analyzing sine tone playback.

So the bottom line seems to be, that if you have material recorded at a higher sample rate than 44.1, then you need to turn your system’s sample rate up to appreciate it. And if you do that, then all of your other stuff will get upsampled, though at least it uses Coreaudio’s best quality algorithm. Or does it? Leopard introduced a new “Mastering grade” algorithm, and it’s not obvious whether that one is used.

One step forward, two back. Come on Apple, twiddle those nose rings and come up with a sexy solution.

To EQ or not to EQ, that is the Q

If you’re a follower of hi-fi trends, you might have noticed that tone controls don’t seem to be cool any more. High-end amplifiers have become very minimal, with only a volume control and power switch.

Well, there’s high end and high end. Richard Burwen’s system would certainly qualify as high-end by almost any definition, if only because of its 20,000 watts of amplification, 169 speakers, and 34 channels of active crossover and EQ, which Burwen claims to have spent a year adjusting by ear for a flat overall frequency response. In other words, the very opposite of a minimal system.

Moving on to my own hi-fi system, which has 60 watts of amplification, 2 speakers, and no tone controls or EQ whatsoever, and has been plagued by annoying room modes. I’ve tried several different speakers, but the bass on all of them just sounded terrible in there.

Recently, I realised that the fundamental problem is that my living room has the two large opposing walls made of solid brick. These two reflective surfaces allow a standing wave to develop between them, and the result is a highly resonant bass boost of about 9dB at 60Hz. I fed the measurements of the room into an online room mode calculator, and it agrees that I should get terrible bass.

So, what to do about it? The minimal solution would be to damp the resonance by installing bass traps. This would be a major carpentry project, though, and good bass traps have to be physically large, so I would lose space in the room. And, I hate working with rockwool, it makes me itch all over.

So, like Richard Burwen, I decided to install an EQ, and “tune by ear for flat frequency response”. My first attempt was with an Alesis PEQ-450, which is a 10-band digital parametric EQ. It only took about 5 minutes to find the offending frequency and notch it out, and I was amazed by the improvement. I found myself getting out those old hip-hop and drum’n’bass CDs that had just sounded offensive on the system before.

However, I wasn’t too happy with the sound quality of the PEQ-450. Maybe I was imagining it, but I felt that it grunged up the treble somewhat. It was also too big and I had nowhere to install it. I ended up buying two (they’re mono) Presonus EQ3Bs on Ebay, and again, tuned them by ear for best bass. I could have gone digital with a Behringer DEQ2496, but in the end, I decided that the simpler solution would be better.

So now, I find myself in the situation of committing audio sacrilege (tone controls are bad! So EQ must be worse!) in order to get a major improvement in the performance of my audio system. Mmm, sacred cowburger.


The EQ3Bs in place

The system

The system. The graffiti paintings are by my brother, and help to break up standing waves too. πŸ™‚

Goodbye decks…

Lack of DJ skillz and impending middle age forces sale! ;-(

There’s a story behind me and decks, which I can tell now that the 10 year non-disclosure agreement has expired. In my final year at university, I took the “Innovation For Engineers” class, which taught how to be an entrepreneur. Myself and another student, Andy Williams, decided that we would have a go at entrepreneurship for real. Andy knew I was a mad inventor, and he lent me money to develop one of my inventions, in exchange for half of the profits. (lesson 1 in entrepreneurship: never give anyone half of the profits)

The invention I chose was an improved crossfader for DJ mixers. I’d just fixed a DJ mixer for a friend, his crossfader had worn out, and I thought I could invent one that would last for ever. I soon had a prototype together, and we took it to music industry trade shows in Manchester and London to attract interest. The first interest we got was “Company G” who offered us Β£10k to bury the thing, a la everlasting lightbulb. (In hindsight we should have taken that.)

After a lot of board treading, we got the attention of “Company N” who agreed to buy the invention off us and fund the patent. Enter endless messing around with contract and patent lawyers. All went well until a substantive patent search found that I had reinvented a mechanism first patented by RCA in the 1970s. Game over! We walked away with Β£5k each, after a year’s work, for a net hourly rate comparable to flipping burgers. But it was certainly an interesting experience.

Company N launched the new fader anyway, in their Pro SM-3 mixer. Sales were so-so and the model was discontinued after a while, the company choosing to get out of analog mixers altogether and go to a digital solution.

Fast forward to 2 years ago, when I finally decided to buy some decks of my own. I bought a second-hand pair of Technics 1200s, only to discover to my surprise that I’m a crap DJ! I can match beats, but I can’t be bothered shopping for records, and have no idea what sort of records I’d want to buy anyway. And if I ever do buy any, I can’t remember the right places to mix them into each other.

The decks had their finest hour at my 30th birthday party, where I persuaded a friend of a friend to come and spin drum’n’bass on them. My flat was well and truly rinsin’! Unfortunately the rest of us got completely drunk, kicked him off the decks and started to play Blondie. He didn’t drink, and left in the huff. The party was still going at dawn the next day. Sorry, Chris.

Now I think it’s time to move on. Feel free toΒ bid on my decks on Ebay!Β πŸ™‚

decks for sale!


No, it’s not some sort of futuristic android sex change.

I’ve lived happily with the Crown SXA for about a year now, and by and large, it’s been a pleasure. It sounds great, has more than enough power for me, and now winter is coming, I can warm my feet on it!

My main worry, though, was always the power transformers. Not only are they something like 50 years old, but they were never designed to handle 50Hz power, which is what we have in the UK. So, even with RG Keen’s Vintage Voltage adaptor installed inside the chassis, they hummed really loudly, got really hot, and gave off worrying smells.

My first port of call was Sowter Transformers, a custom winding company in Ipswich. I sent them the dimensions of the original trannies, and got the reply: “We don’t do metric sized transformers”. They were made in Indiana in 1960. How can they possibly be metric? But none of Sowter’s standard core sizes were even close.

So I thought, maybe “metric” just means “Not British”. A quick peek in the Hammond catalogue (sorry, catalog!) and sure enough, there were several transformers of the right size. I settled on the 290KX, which is Hammond’s replacement for the Marshall JCM900 guitar amp, and Bluebell Audio in Dundee supplied me with a pair.

After purchasing some end bells from TAD and some M4 threaded rod from “boltmeup”‘s Ebay store, it was time to pull the poor Crown apart!


This took most of the day. The new trannies had lugs sticking out of their bobbins, and needed some trimming to get them through the chassis holes. “It’s just like trimming a toenail”, as Philip from Bluebell told me, but much more expensive if you get it wrong!

New vs. old

After much fiddling, rewiring the rectifier to a bridge, wiring one of the transformers up backwards (thank goodness for the old light bulb limiter trick!) and pulling out the redundant Vintage Voltage unit, she was good to go!


The bad news is, the new trannies still hum a bit. They’re quieter than the old ones, but not silent. They also still run fairly hot. The good news is, they don’t smell!

I finally painted the OPTs black to match

The Stinkpad Saga Part 2.

I did some more research into the “meh” quality of the Stinkpad onboard audio, and it turned out that the sound chip resamples everything internally to 48kHz. The resampling doesn’t seem to cause any bad artifacts, just a slight loss of treble through the anti-alias filter, but that very lack of high end is probably what makes it meh.

So I decided to have one last attempt at getting an audiophile-grade output from old Stinkpad, and if it failed I would throw him out of the window and make do with a single computer. I’ve long been a fan of M-Audio products: I struggled with music production on consumer soundcards for years, until the day I bought a Delta 66, and everything just worked. So I bought a Transit, which is their cheapest, lowest-channel-count USB audio doofer.

Upon installing it to the Stinkpad I got exactly the same snaps and pops as before, at the rate of about 5 per second πŸ™ But this time, I noticed that they only happened when the CPU was idle, and loading it up with Winamp’s visualisation thing made them go away. There were no pops from Sound Forge, and indeed I was able to get a bit-for-bit digital copy through the Transit’s optical I/O to my MP3 player and back. (I have an IHP-120 running Rockbox that has digital I/O and can record and playback uncompressed, so I could test everything by dubbing a test file from the laptop to the IHP-120 and back, and subtracting the result from the original.)

This was a promising result that made it worth investigating more. I assumed that the problem was due to some sort of power management system that was shutting the CPU off when it was idle, and maybe taking a bit too long to power it up again, so that the USB audio stream ran dry. And now the heartwarming bit, the Thinkpad 600X might be 10 years old, but IBM/Lenovo still support it! I was able to download a power management driver compatible with XP from their site. This added a tab to XP’s Power Properties dialog, with options to disable CPU and PCI bus power management. I disabled the CPU power management, and the audio troubles were utterly gone, with the machine running considerably faster as a bonus.

Of course, in computing you never fix one problem without introducing three new ones. The CPU fan now runs full speed all the time, and I expect the battery will now last about 5 minutes while the laptop will get hot enough to fry eggs πŸ™ There doesn’t seem to be any way of having this CPU power management “On for battery power but off for AC”, either. Maybe there was a driver to make that happen in Windows 98, but it wouldn’t work in XP.

Oh well, I guess this is what I get for bringing a vintage tractor on the information superhighway.

I smell stinkpad…

I’m currently trying to kick my computer collecting habit, as there’s only room for so many of the things in my flat. My plan is to get down to two machines: one small, low-powered one that can be left on all the time, for things like playing MP3s and internet radio, and running BitTorrent, and a big fast machine crammed with noisy fans to use for my digital audio experiments. The role of the low-powered machine used to be filled by Linosaur, my Linux server, but it’s currently down after a failed attempt to fit it into a smaller case. (That’s “down” as in dismantled in a cardboard box in my mum and dad’s garage. No, it doesn’t respond to pings.)

Hence, I decided that the Stinkpad should take its place. This is an old IBM Thinkpad 600E that refuses to die. It was made at IBM’s plant in Greenock, so it has some typically Scottish quirks such as headbutting you on errors instead of beeping. I upgraded the memory and hard drive, but I can’t do anything about the slow-ass 500MHz CPU. However in this application, the slowness isn’t a problem, as long as it can run uTorrent and Winamp.

The problem I had was that it wouldn’t even do that, since I upgraded it to XP. The onboard audio tended to stutter whenever the machine was loaded, and any external soundcards I tried just popped and stuttered even worse. I tried all sorts of things, messing with settings, disabling all the XP eye candy, but it made no difference.

That is, until I went into the Device Manager and noticed that my hard drive was running in PIO mode! Like it was 1987 again! πŸ™‚ (For non-tech readers, PIO is an old, obsolete way of communicating between hard drive and computer, which is very slow and wastes CPU power. Any half-decent machine can use “DMA” mode which shifts the data faster, and lets the CPU get on with something else in the meantime.)

All attempts to make it go into DMA mode failed, until I found this helpful script. After the mandatory reboot, the stuttering was gone, and as a bonus, the Stinkpad felt about 10 times faster. It must have been stuck in PIO mode for ages, maybe even since the day I installed XP. Who knows why it happened, I’ll just hope it doesn’t do it again.

It now performs its role better than Linosaur did. Since it’s Windows, I can listen to the BBC IPlayer (powered by Windows Media, which makes it pretty off-limits for Linux.) I get really good sound quality using a Roland UA-1EX USB sound dongle, with Otachan’s ASIO plugin for Winamp to bypass all the kernel mixer and resampling gubbins built into Windows. (for media played through Winamp at least…) No I don’t! it worked once and then started snapping and popping πŸ™

Neatest of all, using TCPMP it gives decent full-screen playback of MP4 movies, something Linosaur always struggled to do since it had no screen at all πŸ™‚ I first tried TCPMP as a player for my palmtop, and it worked so well on that, I thought I’d try the desktop version too.

All in all, I think this is pretty good meh for a 10 year old laptop running XP.

I <3 Soma FM

Lately I’ve been listening to Soma FM a lot. I especially like their Groove Salad channel. They play Boards of Canada all the time, but that’s not necessarily a bad thing.

Anyway, their 128k MP3 stream has pretty decent quality – I guess it’s technically the same as a DAB radio station – and it plays on just about anything. Winamp on my PC, with its Delta 1010 hooked up to the stereo, no problem. Linosaur, my Linux server, was a little trickier, but once I figured out the stream URL, I pasted it into phpMP and saved it as a playlist, and off it went. I have a LCD and keypad hooked up to linosaur using LCDproc and a modified version of lcd-stuff, and I can play stuff from that.

Perhaps the coolest thing is that it plays on my Pocket PC (an old Ipaq hx4700) using GSPlayer. When you visit Soma FM’s page, it downloads a Winamp playlist onto your machine to start playback. That contains several streams, I guess as backup if some of them are down. I just got this groovesalad.pls file and copied it onto my PDA’s memory card. (I prefer to keep stuff on a card, since my hx4700 crashes and wipes its RAM with monotonous regularity.) When I run GSPlayer (which I also keep on the card to save reinstalling every 2 weeks) the playlist can be opened and the fat beats begin.

So, if I do this, and dangle my DSL modem/router out of the window, I can listen in the back yard while washing my bike. I’m off to do that now πŸ™‚

Last person in the world on iTunes?

This week I was lucky enough to be given a small, cute iPod Shuffle for my birthday. Yay.

Unfortunately this meant I had to start using iTunes. I’d previously managed all my digital music with a bunch of free software, ripping CDs with (now defunct) RipTrax, playing things with an old Linux machine running mpd/phpMP, and filling my iRiver mp3 player with rsync.

I’ve heard that there are other ways of getting music into an iPod than iTunes, even that it was possible from Linux, but the complexity and level of Linux evangelism involved nearly made my head explode. Asplode, even. And the sheer pointlessness, when my main computer at home runs XP, and my Linux box linosaur is headless.

So off to I went, downloaded the latest iTunes for Windows, and installed it, and it just worked. Almost! I forgot that I had quite a lot of music in Ogg Vorbis format.

But after a quick visit to Quicktime Components I could play all my Ogg stuff too! Though if I ever try uploading any of it to the Shuffle, it may well catch fire.

All in all, I really like the iTunes software, and it may make linosaur’s jukebox function obsolete, and let me get rid of another computer at home.

I even found my own band in the iTunes store. Hardly surprising, since it was me who delivered our album via TuneCore.

(click to see the album in iTunes, if you have it installed) πŸ˜€

Less is More: Pay More, Get Less

‘What can we design that makes our life better, not just “more”‘ –

I recently read Treehugger’s debate on Nikon’s decision to stop making film cameras. I think it summed up a lot of things I’ve been dealing with lately, so I decided to do some blogging about it.

If you live in the developed world in the 21st century, as I do, you probably know all about “more”. More megapixels, gigabytes and gigahertz every couple of years. Cell phones that can surf the net, whether you actually want to or not: I’ve covered this issue before.

But there’s another kind of more that I find even more insidious: More features on our software and consumer gadgets. Once a designer puts a microprocessor into a gadget, he can add extra features by just adding more computer code. These features add practically no manufacturing cost to the end product, while they can still be used as selling points by the advertising guys, so the result is a kind of feature arms race.

The downside of this is that buttons, knobs and large displays do add manufacturing cost, so if the designer wants to maximize features per unit cost, he ends up using a very deep and complicated menu system to control his features. Operating an instrument like this can feel like flying a Jumbo jet when your only access to the flight deck is a letterbox-sized hole and a pool cue. More might be better for the sales guys, but it’s definitely not better for the poor end user.

This is possibly the thing I hate most about the information age. Back in the good old days, instruments had one button per function. To listen to music, you grabbed a vinyl record, put it on a turntable, and lowered a stylus onto the track you wanted. The record deck did not suddenly turn into an address book because you accidentally double-clicked the 33rpm button, and make you spend 10 minutes figuring out how to transform it back. In short, each function had a real, material cost in terms of hardware. The result was that designers had to think hard about what functions to implement, and make sure they were really worthwhile.

I’ve never felt this more than in my dealings with electronic music. Synthesizers, samplers and recording software are powered by microprocessors, made for gearheads by gearheads, but a good musical performance needs an intuitive, gut-level connection between the musician and the instrument. There is very little time for double-clicks or multi-level menus, unless you’re Kraftwerk.

I’m “lucky” enough to own some of the worst excesses of the 90s, like the Yamaha A4000 sampler. It has the jumbo jet syndrome in spades: it took me a good six months to get comfortable working my way round the user interface, in so far as you could get comfortable at all. It bombed, to the extent that fully loaded examples can be found on Ebay for about $250. (I’m keeping mine.)

The polar opposite of this would be a “classic synth” that does one thing and does it very well. Sometimes this isn’t even what the designer intended it to do, as in the case of the legendary TB-303. Its built-in pattern sequencer was so awful that very few people had the patience to program more than a few two-bar loops. The tone generator only had five knobs to change the sound – six if you count the tuning – but those few adjustments were carefully chosen and delightfully tweakable.

These built-in limitations led to the birth of acid house music, and the 303 has kept its resale value a lot better than the A4000 πŸ™‚