Sunday, February 10, 2008

All we need is Music!

So. If we need to play music in real-time, to make your own genius software synthesizer sound using your keyboard, midi-keyboard, midi-didgeridoo, theremin, or ruler with a pick-up and ltp-port connection, we can't treat this with general tools.

We need a very small delay time, i.e. low latency.

In Linux we have Jack system for this purpose. And it's amazing. You can get something like 1.33 milliseconds with common build-in sound card. And it's simple to implement.

Those who don't like Linux, will use Windows.
And at Windows we have to use Steinberg's ASIO specification.

(We can also use PortAudio, but it seems not to support Jack fully for now.)


I've tried to build a standart sample from ASIO SDK. With GCC + MinGW. It even compiles =). And runs. But then it hangs.

GCC + MS Platform SDK. Hangs.
MSVC + MS Platform SDK. Works.

What I've found out: ASIO driver can work only with programs, built by MSVC, because it uses MSVC calls specification ("thiscall" for C++). Other compilers use their own implementation, so those binaries are incompatible.

Portaudio, which supports ASIO, uses a special workaround.
It's a wrapper, which imitates MSVC thiscalls for ASIO: http://www.audiomulch.com/~rossb/code/calliasio/. It's written mostly in asm.

I'm in doubt, if this wrapper will update in time, and if it suppors x86_64 architecture. So, better we don't deal with assembler. Better compile it with MSVC.


By the way - it's well-known issue with C++ for Win. Binary interface (ABI) for C is open, so pure C libraries can be linked with any code.

Microsoft's C++ ABI is proprietary. So, you have to compile your applications with MSVC, to link useful third-party libraries.

No comments: