[linux-audio-dev] writing JACK and LADSPA apps with the ECI C impl

Kai Vehmanen kai.vehmanen at wakkanet.fi
Sat Oct 5 17:53:01 UTC 2002


I've just reinvented remote-procedure-calls, strings, linked lists and
bunch of other stuff while writing the new standalone C implementation of
Ecasound Control Interface (ECI) (ugh, C, ugh ;)).  But I think the work
was worth it. Next I'll demonstrate how to develop a simple app taking
advantage of both JACK and LADSPA (with real-time parameter control) with
a minimum amount of developer effort. If you are now wondering why I'm
writing about this, jump to (6). ;)

--
1. Requirements (for this specific example)

- jack-CVS installed and running
- Steve's plate reverb LADSPA plugin installed 
- ecasound-CVS installed

--
2. The Application

--cut--
#include <ecasoundc.h>

int main(int argc, char *argv[])
{
  eci_init();

  /* create the chainsetup and one chain */
  eci_command("cs-add jackdemo_chainsetup");
  eci_command("c-add chain1");

  /* add the audio inputs and outputs */
  eci_command("ai-add foo.wav");
  eci_command("ao-add jack_alsa,out");

  /* add an LADSPA plate reverb */
  eci_command("cop-add -el:plate,50,0.5,0.5");

  /* select the 3rd param (wet/dry) for real-time control */
  eci_command("copp-select 3");

  /* connect the setup and start */
  eci_command("cs-connect");
  eci_command("start");

  while(1) {
    double curpos;
    sleep(1);
    /* fetch current play position */ 
    eci_command("get-position");
    curpos = eci_last_float();
    if (curpos > 10.0) {
      /* at pos=10sec, quit playing */
      break;
    }
    else if (curpos > 5.0) {
      /* at pos=5sec, set reverb length to 80% */
      eci_command_float_arg("copp-set", 0.8);
    }
  }
  
  eci_command("stop");
  eci_command("cs-disconnect");
  eci_cleanup();

  return(0);
}
--cut--

---
3. Compiling

gcc -o jackdemo jackdemo.c -lecasoundc

---
4. Running

./jackdemo

---
5. Dependencies

--cut--
###| ~|$ ldd ./jackdemo
	libc.so.6 => /lib/i686/libc.so.6 (0x42000000)
	/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

###| ~|$ du -h jackdemo
52k	jackdemo

###| ~|$ file jackdemo
jackdemo: ELF 32-bit LSB executable, Intel 80386, version 1, dynamically linked (uses shared libs), not stripped
--cut--

---
6. The Catch

The created binary, jackdemo, does not rely on any external libraries. No
dependency to ecasound libraries, JACK libraries, C++ runtime, threading
support... just the basic C runtime! In other words jackdemo does not
create depency-hells. ;)

...

PS Although the example looks simple, a lot happens underneath.
   'foo.wav' is read using a double-buffering disk i/o subsystem.
   If jackdemo is run with root privileges, all memory is locked
   and realtime scheduling is used. In otherwords, jackdemo 
   takes advantage of all known tricks to achieve reliable
   audio performance in Linux.

-- 
 http://www.eca.cx
 Audio software for Linux!




More information about the Linux-audio-dev mailing list