[LAD] Tutorial for programming with JACK

Robin Gareus robin at gareus.org
Fri Feb 17 15:12:50 UTC 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Kris,

Welcome back.

On 02/17/2012 03:17 PM, Kris Calabio wrote:
> Thanks for the advice!  I sent a similar e-mail to this list two years ago
> then got distracted with school, work, etc.  I've since found the time and
> motivation to get back into it.
> 
> I am indeed a software developer, but still a novice in many ways.  My only
> experience in audio programming was making a synthesizer in PureData, but I
> want to be more fluent in C/C++ programming so I can work on making JACK
> clients.

you will like:
https://github.com/jackaudio/jack2/blob/master/example-clients/simple_client.c

> Which leads me to my next question:  are most JACK applications written in
> C/C++?  I understand that programming as close to the hardware as possible
> is important for performance, but what about programming in a JVM language
> (I have Clojure in mind)?  How reasonable is that?

At least the DSP part of most pro-audio applications is written in C to
have tight control over worst-case execution time of the code.

The reason for this are real-time constraints: "close to hardware" here
means to have control over memory-allocation and avoid [thread] locks
[in the audio thread]. ie.
  * prevent the memory needed for DSP from being paged out.
  * don't do any memory alloc/dealloc operations in the audio thread

JACK assists greatly with that (calls memlock, provides lock-free
ringbuffers, etc) but you still need to know what you're doing in your
DSP code.

The above constraints rule out [most] garbage-collecting (object
oriented) languages. It is NTL possible to carefully program sound
processing in those langs but you'll need to know much more about what
happens during compilation and/or interpretation of the language. C has
the least pitfalls.

A really good general introduction and nice read is
http://www.rossbencina.com/code/real-time-audio-programming-101-time-waits-for-nothing

Anyways, There are JACK bindings for a lot of languages incl. JAVA. The
most recent announcement that crossed this email-list is
https://code.google.com/p/java-audio-utils/  (I don't know if that lib
works with Clojure, but it should)

Yet all major (proper?!) sound-applications separate the audio (here:
JACK) part from the user-interface and I/O in one way or another. Mixing
languages for that is not uncommon.

ciao,
robin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAk8+bnEACgkQeVUk8U+VK0JaHwCfczcirTKxlnlMu5pa5NouCKYp
jN4AoIPXdRHZ7uNqappuL4hlA1T990LI
=H9Zd
-----END PGP SIGNATURE-----



More information about the Linux-audio-dev mailing list