|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include "../../plugin.h" |
| 4 | + |
| 5 | +// This extension allows a host to render a small curve provided by the plugin. |
| 6 | +// A useful application is to render an EQ frequency response in the DAW mixer view. |
| 7 | + |
| 8 | +static CLAP_CONSTEXPR const char CLAP_EXT_MINI_CURVE_DISPLAY[] = "clap.mini-curve-display/1"; |
| 9 | + |
| 10 | +#ifdef __cplusplus |
| 11 | +extern "C" { |
| 12 | +#endif |
| 13 | + |
| 14 | +typedef struct clap_plugin_mini_curve_display { |
| 15 | + // Renders the curve into the data buffer. |
| 16 | + // The value 0 will be at the bottom of the curve and UINT16_MAX will be at the top. |
| 17 | + // The value at index 0 will be the leftmost and the value at index data_size -1 will be the |
| 18 | + // rightmost. |
| 19 | + // [main-thread] |
| 20 | + bool(CLAP_ABI *render)(clap_plugin_t *plugin, uint16_t *data, uint32_t data_size); |
| 21 | + |
| 22 | + // Tells the plugin if the curve is currently observed or not. |
| 23 | + // When it isn't observed render() can't be called. |
| 24 | + // |
| 25 | + // When is_obseverd becomes true, the curve content and axis name are implicitely invalidated. So |
| 26 | + // the plugin don't need to call host->changed. |
| 27 | + // |
| 28 | + // [main-thread] |
| 29 | + void(CLAP_ABI *set_observed)(clap_plugin_t *plugin, bool is_observed); |
| 30 | + |
| 31 | + // Retriev the axis name. |
| 32 | + // Returns true on success, if the name capacity was sufficient. |
| 33 | + // [main-thread] |
| 34 | + bool(CLAP_ABI *get_axis_name)(clap_plugin_t *plugin, |
| 35 | + char *x_name, |
| 36 | + char *y_name, |
| 37 | + uint32_t name_capacity); |
| 38 | +} clap_plugin_mini_curve_display_t; |
| 39 | + |
| 40 | +enum clap_mini_curve_display_change_flags { |
| 41 | + // Informs the host that the curve content changed. |
| 42 | + // Can only be called if the curve is observed and is static. |
| 43 | + CLAP_MINI_CURVE_DISPLAY_CURVE_CHANGED = 1 << 0, |
| 44 | + |
| 45 | + // Informs the host that the curve axis name changed. |
| 46 | + // Can only be called if the curve is observed. |
| 47 | + CLAP_MINI_CURVE_DISPLAY_AXIS_NAME_CHANGED = 1 << 1, |
| 48 | +}; |
| 49 | + |
| 50 | +typedef struct clap_host_mini_curve_display { |
| 51 | + // Mark the curve as being static or dynamic. |
| 52 | + // The curve is initially considered as static, though the plugin should explicitely |
| 53 | + // initialize this state. |
| 54 | + // |
| 55 | + // When static, the curve changes will be notified by calling host->changed(). |
| 56 | + // When dynamic, the curve is constantly changing and the host is expected to |
| 57 | + // periodically re-render. |
| 58 | + // |
| 59 | + // [main-thread] |
| 60 | + void(CLAP_ABI *set_dynamic)(clap_host_t *host, bool is_dynamic); |
| 61 | + |
| 62 | + // Informs the host that the curve content changed. |
| 63 | + // Can only be called if the curve is observed and is static. |
| 64 | + // [main-thread] |
| 65 | + void(CLAP_ABI *curve_changed)(clap_host_t *host); |
| 66 | + |
| 67 | + // See clap_mini_curve_display_change_flags |
| 68 | + // [main-thread] |
| 69 | + void(CLAP_ABI *changed)(clap_host_t *host, uint32_t flags); |
| 70 | +} clap_host_mini_curve_display_t; |
| 71 | + |
| 72 | +#ifdef __cplusplus |
| 73 | +} |
| 74 | +#endif |
0 commit comments