Carla API Guide?

Programming applications for making music on Linux.

Moderators: MattKingUSA, khz

User avatar
noedig
Established Member
Posts: 233
Joined: Wed Feb 12, 2014 4:39 am
Location: South Africa
Has thanked: 9 times
Been thanked: 52 times

Carla API Guide?

Post by noedig »

Has anyone used the Carla (the plugin host by falkTX) source as an API to include plugin host capability in their own app?

I'm looking for a quick basic guide to get started. It doesn't make sense spending a lot of time figuring this out from the source when someone has already done it ;).

For instance, fluidsynth has a nice guide at http://fluidsynth.sourceforge.net/api/index.html to get started. A similar one for Carla would be useful (or even just some pointers to get started quickly).
User avatar
noedig
Established Member
Posts: 233
Joined: Wed Feb 12, 2014 4:39 am
Location: South Africa
Has thanked: 9 times
Been thanked: 52 times

Re: Carla API Guide?

Post by noedig »

Awesome, thanks for the help!

Please bare with me though; we might have to start quite basic.

Is there a Carla source package I need to install, or do I extract the source code and use it from there?
User avatar
noedig
Established Member
Posts: 233
Joined: Wed Feb 12, 2014 4:39 am
Location: South Africa
Has thanked: 9 times
Been thanked: 52 times

Re: Carla API Guide?

Post by noedig »

Building and installing Carla (stable) doesn't produce any .pc files for pkg-config, so
pkg-config --cflags carla-standalone
and
pkg-config --libs carla-standalone
doesn't work.
User avatar
noedig
Established Member
Posts: 233
Joined: Wed Feb 12, 2014 4:39 am
Location: South Africa
Has thanked: 9 times
Been thanked: 52 times

Re: Carla API Guide?

Post by noedig »

Nevermind - I added the KXStudio repositories and installed Carla from there. pkg-config now works.
User avatar
noedig
Established Member
Posts: 233
Joined: Wed Feb 12, 2014 4:39 am
Location: South Africa
Has thanked: 9 times
Been thanked: 52 times

Re: Carla API Guide?

Post by noedig »

Roundup thus far:
The includes are

Code: Select all

#include <carla/CarlaBackend.h>
#include <carla/CarlaEngine.hpp>
#include <carla/CarlaHost.h>
#include <carla/includes/CarlaDefines.h>
#include <carla/CarlaPlugin.hpp>
#include <carla/CarlaNative.h>
I use

Code: Select all

CARLA_BACKEND_USE_NAMESPACE
to be in the right namespace.

Funny thing: when building, I get a "cannot find rpath=/usr/lib/carla: No such file or directory" error. If I edit the makefile line from

Code: Select all

LIBS = ... -WL,rpath=/usr/lib/carla ...
to

Code: Select all

LIBS = ... -WL,-rpath=/usr/lib/carla ...
(added the dash before rpath)
it stops complaining. Any idea why this is? I use qmake (QtCreator) to build.

Anyway. After a successfull build, should I be hearing the audio file being played back? (Yes I replaced the filename with an existing one on my system and connected the new client to System in QJackCtl.)

Secondly, can you briefly explain the arguments of the carla_add_plugin function? For instance, if I were to load the Hexter DSSI plugin, the arguments would be:
btype: BINARY_NATIVE
ptype: PLUGIN_DSSI
filename: /usr/lib/dssi/hexter.so
name: any string
label: ?
uniqueID: Does this matter?
extraPtr: ?
User avatar
noedig
Established Member
Posts: 233
Joined: Wed Feb 12, 2014 4:39 am
Location: South Africa
Has thanked: 9 times
Been thanked: 52 times

Re: Carla API Guide?

Post by noedig »

I have trouble getting the app to produce sound. It builds ok and runs; jack clients appear and I can assign it to the system audio output and assign midi to its input. However, no audio. Both for the audio file example you provided, as well as for loading other plugins. I can even show the plugin's gui with carla_show_custom_ui. But just no sound.

Is there something else I should initialise in the code?
User avatar
noedig
Established Member
Posts: 233
Joined: Wed Feb 12, 2014 4:39 am
Location: South Africa
Has thanked: 9 times
Been thanked: 52 times

Re: Carla API Guide?

Post by noedig »

Ok I can now produce sound from plugins, by activating them:

Code: Select all

carla_set_active(0,true);
(0 being the id of the plugin.)

The internal audio file player still doesn't work though.
User avatar
noedig
Established Member
Posts: 233
Joined: Wed Feb 12, 2014 4:39 am
Location: South Africa
Has thanked: 9 times
Been thanked: 52 times

Re: Carla API Guide?

Post by noedig »

Is there some trick to loading a plugin state? I can save a state using carla_save_plugin_state, but using carla_load_plugin_state on the same file returns false.

Does the api provide a way to have for instance one midi input port and one audio output port, and then route the midi and audio internally between the plugins? i.e. Every plugin does not appear as a client to Jack, only the main application does.
User avatar
noedig
Established Member
Posts: 233
Joined: Wed Feb 12, 2014 4:39 am
Location: South Africa
Has thanked: 9 times
Been thanked: 52 times

Re: Carla API Guide?

Post by noedig »

Big sfz sample packs take a while to load. Is there any way one can get the loading progress from the carla host api when using the native sfz plugin?

How do I set the backend mode (i.e. Rack mode / single client mode / multi client mode)?

The patchbay port connect function takes groupID and portID. What are these? Also, is there a way to get port names for a given plugin?
User avatar
noedig
Established Member
Posts: 233
Joined: Wed Feb 12, 2014 4:39 am
Location: South Africa
Has thanked: 9 times
Been thanked: 52 times

Re: Carla API Guide?

Post by noedig »

Does the way the Carla backend uses Fluidsynth prevent one from implementing it elsewhere in the same program?
I use the Fluidsynth library in an app. However, when building with the appropriate libraries in order to also use Carla, I get the message

Code: Select all

fluidsynth: error: Couldn't find the requested audio driver jack. Valid drivers are: .
on standard output when running, and no Fluidsynth clients are registered in Jack. When removing the Carla libraries from my build, Fluidsynth works fine again.
Any thoughts?
User avatar
noedig
Established Member
Posts: 233
Joined: Wed Feb 12, 2014 4:39 am
Location: South Africa
Has thanked: 9 times
Been thanked: 52 times

Re: Carla API Guide?

Post by noedig »

falkTX,

What exactly does the carla_engine_idle() function do and how important is it to call it often? I just realized that I kind of forgot to ever call it, and everything seems to be working fine.
Post Reply