I’m delving into some audio based development with Mark Heath and the NAudio library for a side project. This is a ton of fun and I hope to make a good presentation out of it for some code camps and eventually larger venues.
Everything was going good until I started playing with the MIDI controller. The set up was fine, however whenever I plugged in a MIDI controller into the laptop I’m using I would get that hiss/pop/crackle sound when I hit the keys on the controller (I use an AKAI MPD 24 for a MIDI controller). This is caused by buffer under-runs to and from the software from the controller. Basically, the sound buffer has to be full and ready to play when I hit a key. The lower the latency setting, the more buffer under-runs I got – the more snap-crackle-pop. Not good.
Here is a screen shot from FL Studio with the number of under runs:
Well… bump up the buffer length then, right? Well, not really. When you bump up the buffer length this bumps up the time that the software will return from a key hit. In music, if you hit a key, you expect a sound immediately. So if you have 100 millisecond latency to fill the buffer that’s 1/10 of a second off. THAT IS A LIFETIME between key hits. Imagine playing a piano and hitting a key and the sound doesn’t emit until 1/10 of a second later. When it comes down to it, this makes playing/recording music impossible and really crappy.
Welcome ASIO4ALL
ASIO4ALL Helps solve this problem. ASIO stands for “Audio Stream Input/Output” …
ASIO bypasses the normal audio path from the user application through layers of intermediary Windows operating system software, so that the application connects directly to the soundcard hardware. Each layer that is bypassed means a reduction in latency, the delay between an application sending sound to the sound being reproduced by the soundcard. In this way ASIO offers a relatively simple way of accessing multiple audio inputs and outputs independently. Its main strength lies in its method of bypassing the inherently high latency of Windows audio mixing kernels (KMixer), allowing direct, high speed communication with audio hardware. Unlike KMixer, an unmixed ASIO output is “bit identical”, that is, the bits sent to the sound card are identical to those of the original WAV file, thus having higher audio fidelity. [Source]
ASIO4ALL is a free driver that you can download to get this improved speed:
ASIO4ALL is a hardware independent low latency ASIO driver for WDM audio devices. It uses WDM Kernel-Streaming and sometimes even more sophisticated methods to achieve its objectives. [Source– Project Brief]
It Works, Sometimes
I installed the driver, set it up in my audio software (FL Studio) and got to town with some sound development. Sounds simple? Right? Well, you sort of need a little luck to get it running sometimes. I had some problems with the driver working intermittently. It took a few hours to figure out what was going on.
The problem had to do with streaming media such as You Tube. I would watch something on You Tube and then my ASIO4ALL driver would stop working.
The Fix
As soon as I closed FireFox or IE (which YouTube was running in) the driver would start working again. It looks like something in FireFox or IE grabs a hold of the sound driver it needs (not the ASIO one), forces itself to be the primary and kills all other drivers (I think, maybe – I’m sure someone on ‘teh internets’ knows more about this than me – so please chime in).
So the fix? Close all other windows/apps that play sound while working with something that utilizes ASIO4ALL.
Now, when I have my buffer length set to 7 milliseconds, the under-runs are absolutely ZERO and my latency is gone – well, its 7ms, but that’s virtually nothing.
The a screen shot with ASIO4ALL shows it all.
I can now hit the keys on the MIDI controller, have an effective response and actually play music as it is meant to be played.
File Cabinet Lock Bar says
Excellent! Great article, I already saved it to my favourite,
Pandorabracelets says
ZQADCBQRJKL I like it very much!