clap

CLAP Audio Plugin API
Log | Files | Refs | README | LICENSE

commit e22533dee371e008659d0444af7db2308a735fad
parent ccc4de50b59bb150e3eb6d9b46b33b407981681f
Author: Alexandre Bique <bique.alexandre@gmail.com>
Date:   Thu,  6 Feb 2025 15:09:32 +0100

mini-curve-display: new extension (#455)


Diffstat:
Minclude/clap/all.h | 1+
Ainclude/clap/ext/draft/mini-curve-display.h | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+), 0 deletions(-)

diff --git a/include/clap/all.h b/include/clap/all.h @@ -7,6 +7,7 @@ #include "ext/draft/extensible-audio-ports.h" #include "ext/draft/gain-adjustment-metering.h" +#include "ext/draft/mini-curve-display.h" #include "ext/draft/project-location.h" #include "ext/draft/resource-directory.h" #include "ext/draft/scratch-memory.h" diff --git a/include/clap/ext/draft/mini-curve-display.h b/include/clap/ext/draft/mini-curve-display.h @@ -0,0 +1,74 @@ +#pragma once + +#include "../../plugin.h" + +// This extension allows a host to render a small curve provided by the plugin. +// A useful application is to render an EQ frequency response in the DAW mixer view. + +static CLAP_CONSTEXPR const char CLAP_EXT_MINI_CURVE_DISPLAY[] = "clap.mini-curve-display/1"; + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct clap_plugin_mini_curve_display { + // Renders the curve into the data buffer. + // The value 0 will be at the bottom of the curve and UINT16_MAX will be at the top. + // The value at index 0 will be the leftmost and the value at index data_size -1 will be the + // rightmost. + // [main-thread] + bool(CLAP_ABI *render)(clap_plugin_t *plugin, uint16_t *data, uint32_t data_size); + + // Tells the plugin if the curve is currently observed or not. + // When it isn't observed render() can't be called. + // + // When is_obseverd becomes true, the curve content and axis name are implicitely invalidated. So + // the plugin don't need to call host->changed. + // + // [main-thread] + void(CLAP_ABI *set_observed)(clap_plugin_t *plugin, bool is_observed); + + // Retriev the axis name. + // Returns true on success, if the name capacity was sufficient. + // [main-thread] + bool(CLAP_ABI *get_axis_name)(clap_plugin_t *plugin, + char *x_name, + char *y_name, + uint32_t name_capacity); +} clap_plugin_mini_curve_display_t; + +enum clap_mini_curve_display_change_flags { + // Informs the host that the curve content changed. + // Can only be called if the curve is observed and is static. + CLAP_MINI_CURVE_DISPLAY_CURVE_CHANGED = 1 << 0, + + // Informs the host that the curve axis name changed. + // Can only be called if the curve is observed. + CLAP_MINI_CURVE_DISPLAY_AXIS_NAME_CHANGED = 1 << 1, +}; + +typedef struct clap_host_mini_curve_display { + // Mark the curve as being static or dynamic. + // The curve is initially considered as static, though the plugin should explicitely + // initialize this state. + // + // When static, the curve changes will be notified by calling host->changed(). + // When dynamic, the curve is constantly changing and the host is expected to + // periodically re-render. + // + // [main-thread] + void(CLAP_ABI *set_dynamic)(clap_host_t *host, bool is_dynamic); + + // Informs the host that the curve content changed. + // Can only be called if the curve is observed and is static. + // [main-thread] + void(CLAP_ABI *curve_changed)(clap_host_t *host); + + // See clap_mini_curve_display_change_flags + // [main-thread] + void(CLAP_ABI *changed)(clap_host_t *host, uint32_t flags); +} clap_host_mini_curve_display_t; + +#ifdef __cplusplus +} +#endif