Beginning Programming Audio: ASIO4ALL Is Picky

By admin on Dec 29 2008 | 5 Comments

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:

image

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

imageAs 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.

Post info

Tags:
Categories: .NET , Audio

Comments

sulumits retsambew
sulumits retsambew United States on 5/15/2009 10:03 PM very nice info, thanks.
Brendon C
Brendon C Canada on 6/15/2009 1:06 PM tried all these with no luck. any other advice with how i could get asio4all running with my fl studio8?
Donn
Donn United States on 6/15/2009 1:23 PM Yeah, here is another couple of tips.

- Make sure you have all other apps that use audio are closed.
- Example: Virtual PC, Windows Media player, WinAmp, etc.

What I think (key words: I think) is happening is that Windows  (or something) is grabbing onto the regular device driver (like Sigmatel, or whatever you have on your system). Once it does this it will not release the handle until the app is closed. I've noticed this with the said applications.

Once you have closed ALL other apps (look in your task bar too), give it a go.

Donn
Precision Engineers
Precision Engineers United States on 6/19/2009 5:53 AM Interface support is normally restricted to Microsoft Windows, since other operating systems (e.g. Apple's Mac OS X or Linux) do not have such mixer latency problems (see Core Audio and ALSA). In Windows Vista, KMixer has been removed and replaced by a new WaveRT port driver. WaveRT cannot provide synchronized audio to multiple devices and does not support external clocks.As of 2007 there is also an experimental ASIO driver for Wine, a Windows layer for Linux. This wineasio driver uses the JACK sound server as its audio back-end and allows many ASIO-aware applications to run with low-latency under WINE.
Sulumits Retsambew
Sulumits Retsambew United States on 7/4/2009 5:35 AM nice post.. thanks

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading