diff options
Diffstat (limited to 'src/control.h')
-rw-r--r-- | src/control.h | 94 |
1 files changed, 44 insertions, 50 deletions
diff --git a/src/control.h b/src/control.h index 46ca360..0109e60 100644 --- a/src/control.h +++ b/src/control.h @@ -7,18 +7,17 @@ #include "attributes.h" #include "nodes.h" -#include "lilv/lilv.h" -#include "lv2/atom/forge.h" -#include "lv2/urid/urid.h" +#include <lilv/lilv.h> +#include <lv2/atom/forge.h> +#include <lv2/urid/urid.h> #include <stdbool.h> #include <stddef.h> #include <stdint.h> +// Support for plugin controls (control port or event-based) JALV_BEGIN_DECLS -// Plugin control utilities - /// Type of plugin control typedef enum { PORT, ///< Control port @@ -33,27 +32,28 @@ typedef struct { /// Plugin control typedef struct { - ControlType type; ///< Type of control - LilvNode* node; ///< Port or property - LilvNode* symbol; ///< Symbol - LilvNode* label; ///< Human readable label - LV2_Atom_Forge* forge; ///< Forge (for URIDs) - LV2_URID property; ///< Iff type == PROPERTY - uint32_t index; ///< Iff type == PORT - LilvNode* group; ///< Port/control group, or NULL - void* widget; ///< Control Widget - size_t n_points; ///< Number of scale points - ScalePoint* points; ///< Scale points - LV2_URID value_type; ///< Type of control value - LilvNode* min; ///< Minimum value - LilvNode* max; ///< Maximum value - LilvNode* def; ///< Default value - bool is_toggle; ///< Boolean (0 and 1 only) - bool is_integer; ///< Integer values only - bool is_enumeration; ///< Point values only - bool is_logarithmic; ///< Logarithmic scale - bool is_writable; ///< Writable (input) - bool is_readable; ///< Readable (output) + ControlType type; ///< Type of control + union { + LV2_URID property; ///< Iff type == PROPERTY + uint32_t index; ///< Iff type == PORT + } id; + LilvNode* node; ///< Port or property + LilvNode* symbol; ///< Symbol + LilvNode* label; ///< Human readable label + LilvNode* group; ///< Port/control group, or NULL + void* widget; ///< Control Widget + size_t n_points; ///< Number of scale points + ScalePoint* points; ///< Scale points + LV2_URID value_type; ///< Type of control value + LilvNode* min; ///< Minimum value + LilvNode* max; ///< Maximum value + LilvNode* def; ///< Default value + bool is_toggle; ///< Boolean (0 and 1 only) + bool is_integer; ///< Integer values only + bool is_enumeration; ///< Point values only + bool is_logarithmic; ///< Logarithmic scale + bool is_writable; ///< Writable (input) + bool is_readable; ///< Readable (output) } ControlID; /// Set of plugin controls @@ -62,39 +62,33 @@ typedef struct { ControlID** controls; } Controls; -/// Control change event, sent through ring buffers for UI updates -typedef struct { - uint32_t index; - uint32_t protocol; - uint32_t size; - // Followed immediately by size bytes of data -} ControlChange; - -/// Order scale points by value -int -scale_point_cmp(const ScalePoint* a, const ScalePoint* b); - /// Create a new ID for a control port ControlID* -new_port_control(LilvWorld* world, - const LilvPlugin* plugin, - const LilvPort* port, - uint32_t port_index, - float sample_rate, - const JalvNodes* nodes, - LV2_Atom_Forge* forge); +new_port_control(LilvWorld* world, + const LilvPlugin* plugin, + const LilvPort* port, + uint32_t port_index, + float sample_rate, + const JalvNodes* nodes, + const LV2_Atom_Forge* forge); /// Create a new ID for a property-based parameter ControlID* -new_property_control(LilvWorld* world, - const LilvNode* property, - const JalvNodes* nodes, - LV2_URID_Map* map, - LV2_Atom_Forge* forge); +new_property_control(LilvWorld* world, + const LilvNode* property, + const JalvNodes* nodes, + LV2_URID_Map* map, + const LV2_Atom_Forge* forge); + +/// Free a control allocated with new_port_control() or new_property_control() +void +free_control(ControlID* control); +/// Add a control to the given controls set, reallocating as necessary void add_control(Controls* controls, ControlID* control); +/// Return a pointer to the control for the given property, or null ControlID* get_property_control(const Controls* controls, LV2_URID property); |