Browse Source

More work on Carla-lv2 support

tags/v0.9.0
falkTX 13 years ago
parent
commit
429a2b7ad9
9 changed files with 1401 additions and 1147 deletions
  1. +19
    -0
      src/carla-includes/lilv/lilv.h
  2. +11
    -4
      src/carla-includes/lilv/lilvmm.hpp
  3. +141
    -0
      src/carla-includes/lv2/programs.h
  4. +19
    -0
      src/carla-lilv/lilv-0.14.0/lilv/lilv.h
  5. +0
    -279
      src/carla-lilv/lilv-0.14.0/lilv/lilvmm.hpp
  6. +54
    -0
      src/carla-lilv/lilv-0.14.0/src/ui.c
  7. +3
    -3
      src/carla/carla_backend.cpp
  8. +191
    -855
      src/carla/lv2.cpp
  9. +963
    -6
      src/carla/lv2_rdf.h

+ 19
- 0
src/carla-includes/lilv/lilv.h View File

@@ -1692,6 +1692,25 @@ LILV_API
const LilvNode*
lilv_ui_get_binary_uri(const LilvUI* ui);

/**
Custom calls
*/
LILV_API
LilvNodes*
lilv_ui_get_supported_features(const LilvUI* ui);

LILV_API
LilvNodes*
lilv_ui_get_required_features(const LilvUI* ui);

LILV_API
LilvNodes*
lilv_ui_get_optional_features(const LilvUI* ui);

LILV_API
LilvNodes*
lilv_ui_get_extension_data(const LilvUI* ui);

/**
@}
@}


+ 11
- 4
src/carla-includes/lilv/lilvmm.hpp View File

@@ -165,10 +165,14 @@ struct UI {
inline UI(const LilvUI* c_obj) : me(c_obj) {}
LILV_WRAP_CONVERSION(const LilvUI);

LILV_WRAP0(Node, ui, get_uri);
LILV_WRAP1(bool, ui, is_a, LilvNode*, ui_class);
LILV_WRAP0(Node, ui, get_bundle_uri);
LILV_WRAP0(Node, ui, get_binary_uri);
LILV_WRAP0(Node, ui, get_uri);
LILV_WRAP1(bool, ui, is_a, LilvNode*, ui_class);
LILV_WRAP0(Node, ui, get_bundle_uri);
LILV_WRAP0(Node, ui, get_binary_uri);
LILV_WRAP0(Nodes, ui, get_supported_features);
LILV_WRAP0(Nodes, ui, get_required_features);
LILV_WRAP0(Nodes, ui, get_optional_features);
LILV_WRAP0(Nodes, ui, get_extension_data);

const LilvUI* me;
};
@@ -200,6 +204,8 @@ struct Plugin {
LILV_WRAP0(Node, plugin, get_author_email);
LILV_WRAP0(Node, plugin, get_author_homepage);
LILV_WRAP0(bool, plugin, is_replaced);
LILV_WRAP0(Nodes, plugin, get_extension_data);
LILV_WRAP1(Nodes, plugin, get_related, Node, pred);
LILV_WRAP0(UIs, plugin, get_uis);

inline Port get_port_by_index(unsigned index) {
@@ -284,6 +290,7 @@ struct World {
LILV_WRAP2_VOID(world, set_option, const char*, uri, LilvNode*, value);
LILV_WRAP0_VOID(world, load_all);
LILV_WRAP1_VOID(world, load_bundle, LilvNode*, bundle_uri);
LILV_WRAP1_VOID(world, load_resource, LilvNode*, resource);
LILV_WRAP0(const LilvPluginClass*, world, get_plugin_class);
LILV_WRAP0(const LilvPluginClasses*, world, get_plugin_classes);
LILV_WRAP0(const Plugins, world, get_all_plugins);


+ 141
- 0
src/carla-includes/lv2/programs.h View File

@@ -0,0 +1,141 @@
/*
LV2 Programs Extension
Copyright 2012 Filipe Coelho <falktx@gmail.com>

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@file programs.h
C header for the LV2 programs extension <http://kxstudio.sf.net/ns/lv2ext/programs>.
*/

#ifndef LV2_PROGRAMS_H
#define LV2_PROGRAMS_H

#include <stdint.h>

#define LV2_PROGRAMS_URI "http://kxstudio.sf.net/ns/lv2ext/programs"
#define LV2_PROGRAMS_PREFIX LV2_PROGRAMS_URI "#"

#ifdef __cplusplus
extern "C" {
#endif

typedef void* LV2_Programs_Handle;

typedef struct _LV2_Program_Descriptor {

/** Bank number for this program. Note that this extension does not
support MIDI-style separation of bank LSB and MSB values. There is
no restriction on the set of available banks: the numbers do not
need to be contiguous, there does not need to be a bank 0, etc. */
uint32_t bank;

/** Program number (unique within its bank) for this program.
There is no restriction on the set of available programs: the
numbers do not need to be contiguous, there does not need to
be a program 0, etc. */
uint32_t program;

/** Name of the program. */
const char * name;

} LV2_Program_Descriptor;

/**
Programs extension, plugin data.

When the plugin's extension_data is called with argument LV2_PROGRAMS_URI,
the plugin MUST return an LV2_Programs_Plugin_Extension structure, which
remains valid for the lifetime of the plugin.
*/
typedef struct {
/**
* get_program()
*
* This member is a function pointer that provides a description
* of a program (named preset sound) available on this plugin.
*
* The Index argument is an index into the plugin's list of
* programs, not a program number as represented by the Program
* field of the LV2_Program_Descriptor. (This distinction is
* needed to support plugins that use non-contiguous program or
* bank numbers.)
*
* This function returns a LV2_Program_Descriptor pointer that is
* guaranteed to be valid only until the next call to get_program,
* deactivate, or configure, on the same plugin instance. This
* function must return NULL if passed an Index argument out of
* range, so that the host can use it to query the number of
* programs as well as their properties.
*/
const LV2_Program_Descriptor *(*get_program)(LV2_Programs_Handle handle,
uint32_t index);

/**
* select_program()
*
* This member is a function pointer that selects a new program
* for this plugin. The program change should take effect
* immediately at the start of the next run() call. (This
* means that a host providing the capability of changing programs
* between any two notes on a track must vary the block size so as
* to place the program change at the right place. A host that
* wanted to avoid this would probably just instantiate a plugin
* for each program.)
*
* Plugins should ignore a select_program() call with an invalid
* bank or program.
*
* A plugin is not required to select any particular default
* program on activate(): it's the host's duty to set a program
* explicitly.
*
* A plugin is permitted to re-write the values of its input
* control ports when select_program is called. The host should
* re-read the input control port values and update its own
* records appropriately. (This is the only circumstance in which
* a LV2 plugin is allowed to modify its own control-input ports.)
*/
void (*select_program)(LV2_Programs_Handle handle,
uint32_t bank,
uint32_t program);

} LV2_Programs_Plugin_Extension;

/**
Programs extension, UI data.

When the UI's extension_data is called with argument LV2_PROGRAMS_URI,
the UI MUST return an LV2_Programs_UI_Extension structure, which
remains valid for the lifetime of the UI.
*/
typedef struct {
/**
* select_program()
*
* This is exactly the same as select_program in LV2_Programs_Plugin_Extension,
* but this struct related to a UI instead of a plugin.
*/
void (*select_program)(LV2_Programs_Handle handle,
uint32_t bank,
uint32_t program);

} LV2_Programs_UI_Extension;

#ifdef __cplusplus
}
#endif

#endif /* LV2_PROGRAMS_H */

+ 19
- 0
src/carla-lilv/lilv-0.14.0/lilv/lilv.h View File

@@ -1692,6 +1692,25 @@ LILV_API
const LilvNode*
lilv_ui_get_binary_uri(const LilvUI* ui);

/**
Custom calls
*/
LILV_API
LilvNodes*
lilv_ui_get_supported_features(const LilvUI* ui);

LILV_API
LilvNodes*
lilv_ui_get_required_features(const LilvUI* ui);

LILV_API
LilvNodes*
lilv_ui_get_optional_features(const LilvUI* ui);

LILV_API
LilvNodes*
lilv_ui_get_extension_data(const LilvUI* ui);

/**
@}
@}


+ 0
- 279
src/carla-lilv/lilv-0.14.0/lilv/lilvmm.hpp View File

@@ -1,279 +0,0 @@
/*
Copyright 2007-2011 David Robillard <http://drobilla.net>

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifndef LILV_LILVMM_HPP
#define LILV_LILVMM_HPP

#include "lilv/lilv.h"

namespace Lilv {

static inline const char*
uri_to_path(const char* uri) {
return lilv_uri_to_path(uri);
}

#define LILV_WRAP0(RT, prefix, name) \
inline RT name() { return lilv_ ## prefix ## _ ## name (me); }

#define LILV_WRAP0_VOID(prefix, name) \
inline void name() { lilv_ ## prefix ## _ ## name(me); }

#define LILV_WRAP1(RT, prefix, name, T1, a1) \
inline RT name(T1 a1) { return lilv_ ## prefix ## _ ## name (me, a1); }

#define LILV_WRAP1_VOID(prefix, name, T1, a1) \
inline void name(T1 a1) { lilv_ ## prefix ## _ ## name(me, a1); }

#define LILV_WRAP2(RT, prefix, name, T1, a1, T2, a2) \
inline RT name(T1 a1, T2 a2) { \
return lilv_ ## prefix ## _ ## name(me, a1, a2); \
}

#define LILV_WRAP2_VOID(prefix, name, T1, a1, T2, a2) \
inline void name(T1 a1, T2 a2) { lilv_ ## prefix ## _ ## name(me, a1, a2); }

#ifndef SWIG
#define LILV_WRAP_CONVERSION(CT) \
inline operator CT*() const { return me; }
#else
#define LILV_WRAP_CONVERSION(CT)
#endif

struct Node {
inline Node(const LilvNode* node) : me(lilv_node_duplicate(node)) {}
inline Node(const Node& copy) : me(lilv_node_duplicate(copy.me)) {}

inline ~Node() { lilv_node_free(me); }

inline bool equals(const Node& other) const {
return lilv_node_equals(me, other.me);
}

inline bool operator==(const Node& other) const { return equals(other); }

LILV_WRAP_CONVERSION(LilvNode);

LILV_WRAP0(char*, node, get_turtle_token);
LILV_WRAP0(bool, node, is_uri);
LILV_WRAP0(const char*, node, as_uri);
LILV_WRAP0(bool, node, is_blank);
LILV_WRAP0(const char*, node, as_blank);
LILV_WRAP0(bool, node, is_literal);
LILV_WRAP0(bool, node, is_string);
LILV_WRAP0(const char*, node, as_string);
LILV_WRAP0(bool, node, is_float);
LILV_WRAP0(float, node, as_float);
LILV_WRAP0(bool, node, is_int);
LILV_WRAP0(int, node, as_int);
LILV_WRAP0(bool, node, is_bool);
LILV_WRAP0(bool, node, as_bool);

LilvNode* me;
};

struct ScalePoint {
inline ScalePoint(const LilvScalePoint* c_obj) : me(c_obj) {}
LILV_WRAP_CONVERSION(const LilvScalePoint);

LILV_WRAP0(const LilvNode*, scale_point, get_label);
LILV_WRAP0(const LilvNode*, scale_point, get_value);

const LilvScalePoint* me;
};

struct PluginClass {
inline PluginClass(const LilvPluginClass* c_obj) : me(c_obj) {}
LILV_WRAP_CONVERSION(const LilvPluginClass);

LILV_WRAP0(Node, plugin_class, get_parent_uri);
LILV_WRAP0(Node, plugin_class, get_uri);
LILV_WRAP0(Node, plugin_class, get_label);
LILV_WRAP0(LilvPluginClasses*, plugin_class, get_children);

const LilvPluginClass* me;
};

#define LILV_WRAP_COLL(CT, ET, prefix) \
inline CT(const Lilv ## CT* c_obj) : me(c_obj) {} \
LILV_WRAP_CONVERSION(const Lilv ## CT); \
LILV_WRAP0(unsigned, prefix, size); \
LILV_WRAP1(const ET, prefix, get, LilvIter*, i); \
LILV_WRAP0(LilvIter*, prefix, begin); \
LILV_WRAP1(LilvIter*, prefix, next, LilvIter*, i); \
LILV_WRAP1(bool, prefix, is_end, LilvIter*, i); \
const Lilv ## CT* me; \

struct PluginClasses {
LILV_WRAP_COLL(PluginClasses, PluginClass, plugin_classes);
LILV_WRAP1(const PluginClass, plugin_classes,
get_by_uri, const LilvNode*, uri);
};

struct ScalePoints {
LILV_WRAP_COLL(ScalePoints, ScalePoint, scale_points);
};

struct Nodes {
LILV_WRAP_COLL(Nodes, Node, nodes);
LILV_WRAP1(bool, nodes, contains, const Node, node);
};

struct Port {
inline Port(const LilvPlugin* p, const LilvPort* c_obj)
: parent(p), me(c_obj)
{}

LILV_WRAP_CONVERSION(const LilvPort);

#define LILV_PORT_WRAP0(RT, name) \
inline RT name () { return lilv_port_ ## name (parent, me); }

#define LILV_PORT_WRAP1(RT, name, T1, a1) \
inline RT name (T1 a1) { return lilv_port_ ## name (parent, me, a1); }

LILV_PORT_WRAP1(LilvNodes*, get_value, LilvNode*, predicate);
LILV_PORT_WRAP0(LilvNodes*, get_properties)
LILV_PORT_WRAP1(bool, has_property, LilvNode*, property_uri);
LILV_PORT_WRAP1(bool, supports_event, LilvNode*, event_uri);
LILV_PORT_WRAP0(const LilvNode*, get_symbol);
LILV_PORT_WRAP0(LilvNode*, get_name);
LILV_PORT_WRAP0(const LilvNodes*, get_classes);
LILV_PORT_WRAP1(bool, is_a, LilvNode*, port_class);
LILV_PORT_WRAP0(LilvScalePoints*, get_scale_points);

// TODO: get_range (output parameters)

const LilvPlugin* parent;
const LilvPort* me;
};

struct Plugin {
inline Plugin(const LilvPlugin* c_obj) : me(c_obj) {}
LILV_WRAP_CONVERSION(const LilvPlugin);

LILV_WRAP0(bool, plugin, verify);
LILV_WRAP0(Node, plugin, get_uri);
LILV_WRAP0(Node, plugin, get_bundle_uri);
LILV_WRAP0(Nodes, plugin, get_data_uris);
LILV_WRAP0(Node, plugin, get_library_uri);
LILV_WRAP0(Node, plugin, get_name);
LILV_WRAP0(PluginClass, plugin, get_class);
LILV_WRAP1(Nodes, plugin, get_value, Node, pred);
LILV_WRAP1(bool, plugin, has_feature, Node, feature_uri);
LILV_WRAP0(Nodes, plugin, get_supported_features);
LILV_WRAP0(Nodes, plugin, get_required_features);
LILV_WRAP0(Nodes, plugin, get_optional_features);
LILV_WRAP0(unsigned, plugin, get_num_ports);
LILV_WRAP0(bool, plugin, has_latency);
LILV_WRAP0(unsigned, plugin, get_latency_port_index);
LILV_WRAP0(Node, plugin, get_author_name);
LILV_WRAP0(Node, plugin, get_author_email);
LILV_WRAP0(Node, plugin, get_author_homepage);
LILV_WRAP0(bool, plugin, is_replaced);

inline Port get_port_by_index(unsigned index) {
return Port(me, lilv_plugin_get_port_by_index(me, index));
}

inline Port get_port_by_symbol(LilvNode* symbol) {
return Port(me, lilv_plugin_get_port_by_symbol(me, symbol));
}

inline void get_port_ranges_float(float* min_values,
float* max_values,
float* def_values) {
return lilv_plugin_get_port_ranges_float(
me, min_values, max_values, def_values);
}

inline unsigned get_num_ports_of_class(LilvNode* class_1,
LilvNode* class_2) {
// TODO: varargs
return lilv_plugin_get_num_ports_of_class(me, class_1, class_2, NULL);
}

const LilvPlugin* me;
};

struct Plugins {
LILV_WRAP_COLL(Plugins, Plugin, plugins);
LILV_WRAP1(const Plugin, plugins, get_by_uri, const LilvNode*, uri);
};

struct Instance {
inline Instance(Plugin plugin, double sample_rate) {
// TODO: features
me = lilv_plugin_instantiate(plugin, sample_rate, NULL);
}

LILV_WRAP_CONVERSION(LilvInstance);

LILV_WRAP2_VOID(instance, connect_port,
unsigned, port_index,
void*, data_location);

LILV_WRAP0_VOID(instance, activate);
LILV_WRAP1_VOID(instance, run, unsigned, sample_count);
LILV_WRAP0_VOID(instance, deactivate);

// TODO: get_extension_data

inline const LV2_Descriptor* get_descriptor() {
return lilv_instance_get_descriptor(me);
}

LilvInstance* me;
};

struct World {
inline World() : me(lilv_world_new()) {}
inline ~World() { lilv_world_free(me); }

inline LilvNode* new_uri(const char* uri) {
return lilv_new_uri(me, uri);
}
inline LilvNode* new_string(const char* str) {
return lilv_new_string(me, str);
}
inline LilvNode* new_int(int val) {
return lilv_new_int(me, val);
}
inline LilvNode* new_float(float val) {
return lilv_new_float(me, val);
}
inline LilvNode* new_bool(bool val) {
return lilv_new_bool(me, val);
}
inline Nodes find_nodes(const LilvNode* subject,
const LilvNode* predicate,
const LilvNode* object) {
return lilv_world_find_nodes(me, subject, predicate, object);
}

LILV_WRAP2_VOID(world, set_option, const char*, uri, LilvNode*, value);
LILV_WRAP0_VOID(world, load_all);
LILV_WRAP1_VOID(world, load_bundle, LilvNode*, bundle_uri);
LILV_WRAP0(const LilvPluginClass*, world, get_plugin_class);
LILV_WRAP0(const LilvPluginClasses*, world, get_plugin_classes);
LILV_WRAP0(const Plugins, world, get_all_plugins);

LilvWorld* me;
};

} /* namespace Lilv */

#endif /* LILV_LILVMM_HPP */

+ 54
- 0
src/carla-lilv/lilv-0.14.0/src/ui.c View File

@@ -128,3 +128,57 @@ lilv_ui_get_binary_uri(const LilvUI* ui)
assert(ui->binary_uri);
return ui->binary_uri;
}

static LilvNodes*
lilv_ui_get_value_internal(const LilvUI* ui,
const SordNode* predicate)
{
return lilv_world_query_values_internal(
ui->world, ui->uri->val.uri_val, predicate, NULL);
}

LILV_API
LilvNodes*
lilv_ui_get_supported_features(const LilvUI* ui)
{
LilvNodes* optional = lilv_ui_get_optional_features(ui);
LilvNodes* required = lilv_ui_get_required_features(ui);
LilvNodes* result = lilv_nodes_new();

LILV_FOREACH(nodes, i, optional)
zix_tree_insert((ZixTree*)result,
lilv_node_duplicate(lilv_nodes_get(optional, i)),
NULL);
LILV_FOREACH(nodes, i, required)
zix_tree_insert((ZixTree*)result,
lilv_node_duplicate(lilv_nodes_get(required, i)),
NULL);

lilv_nodes_free(optional);
lilv_nodes_free(required);

return result;
}

LILV_API
LilvNodes*
lilv_ui_get_required_features(const LilvUI* ui)
{
return lilv_ui_get_value_internal(
ui, ui->world->uris.lv2_requiredFeature);
}

LILV_API
LilvNodes*
lilv_ui_get_optional_features(const LilvUI* ui)
{
return lilv_ui_get_value_internal(
ui, ui->world->uris.lv2_optionalFeature);
}

LILV_API
LilvNodes*
lilv_ui_get_extension_data(const LilvUI* ui)
{
return lilv_ui_get_value_internal(ui, ui->world->uris.lv2_extensionData);
}

+ 3
- 3
src/carla/carla_backend.cpp View File

@@ -18,9 +18,6 @@
#include "carla_plugin.h"
#include "carla_threads.h"

//#include <cstring>
//#include <ostream>

// plugin specific
short add_plugin_ladspa(const char* filename, const char* label, void* extra_stuff);
short add_plugin_dssi(const char* filename, const char* label, void* extra_stuff);
@@ -29,6 +26,8 @@ short add_plugin_vst(const char* filename, const char* label);
short add_plugin_sf2(const char* filename, const char* label);
short add_plugin_bridge(BinaryType btype, PluginType ptype, const char* filename, const char* label, void* extra_stuff);

void lv2_load_all();

CarlaCheckThread carla_check_thread;

// -------------------------------------------------------------------------------------------------------------------
@@ -1129,6 +1128,7 @@ void set_option(OptionsType option, int value, const char* value_str)
break;
case OPTION_PATH_LV2:
setenv("LV2_PATH", value_str, 1);
lv2_load_all();
break;
case OPTION_PATH_VST:
setenv("VST_PATH", value_str, 1);


+ 191
- 855
src/carla/lv2.cpp
File diff suppressed because it is too large
View File


+ 963
- 6
src/carla/lv2_rdf.h
File diff suppressed because it is too large
View File


Loading…
Cancel
Save