55// This extension allows a host to render a small curve provided by the plugin.
66// A useful application is to render an EQ frequency response in the DAW mixer view.
77
8- static CLAP_CONSTEXPR const char CLAP_EXT_MINI_CURVE_DISPLAY [] = "clap.mini-curve-display/2 " ;
8+ static CLAP_CONSTEXPR const char CLAP_EXT_MINI_CURVE_DISPLAY [] = "clap.mini-curve-display/3 " ;
99
1010#ifdef __cplusplus
1111extern "C" {
1212#endif
1313
1414enum clap_mini_curve_display_curve_kind {
15+ // If the curve's kind doesn't fit in any proposed kind, use this one
16+ // and perhaps, make a pull request to extend the list.
17+ CLAP_MINI_CURVE_DISPLAY_CURVE_KIND_UNSPECIFIED = 0 ,
18+
1519 // The mini curve is intended to draw the total gain response of the plugin.
16- // In this case the y values are in dB and the x values are in hz (logarithmic).
20+ // In this case the y values are in dB and the x values are in Hz (logarithmic).
1721 // This would be useful in for example an equalizer.
1822 CLAP_MINI_CURVE_DISPLAY_CURVE_KIND_GAIN_RESPONSE = 1 ,
1923
2024 // The mini curve is intended to draw the total phase response of the plugin.
21- // In this case the y values are in radians and the x values are in hz (logarithmic).
25+ // In this case the y values are in radians and the x values are in Hz (logarithmic).
2226 // This would be useful in for example an equalizer.
2327 CLAP_MINI_CURVE_DISPLAY_CURVE_KIND_PHASE_RESPONSE = 2 ,
2428
@@ -42,7 +46,7 @@ enum clap_mini_curve_display_curve_kind {
4246 // Note: more entries could be added here in the future
4347};
4448
45- typedef struct clap_mini_display_curve_hints {
49+ typedef struct clap_mini_curve_display_curve_hints {
4650
4751 // Range for the x axis.
4852 double x_min ;
@@ -52,21 +56,48 @@ typedef struct clap_mini_display_curve_hints {
5256 double y_min ;
5357 double y_max ;
5458
55- } clap_mini_display_curve_hints_t ;
59+ } clap_mini_curve_display_curve_hints_t ;
60+
61+ // A set of points representing the curve to be painted.
62+ typedef struct clap_mini_curve_display_curve_data {
63+ // Indicates the kind of curve those values represent, the host can use this
64+ // information to paint the curve using a meaningful color.
65+ int32_t curve_kind ;
5666
67+ // values[0] will be the leftmost value and values[data_size -1] will be the rightmost
68+ // value.
69+ //
70+ // The value 0 and UINT16_MAX won't be painted.
71+ // The value 1 will be at the bottom of the curve and UINT16_MAX - 1 will be at the top.
72+ uint16_t * values ;
73+ uint32_t values_count ;
74+ } clap_mini_curve_display_curve_data_t ;
5775
5876typedef struct clap_plugin_mini_curve_display {
59- // Renders the curve into the data buffer.
60- // The value 0 will be at the bottom of the curve and UINT16_MAX will be at the top.
61- // The value at index 0 will be the leftmost and the value at index data_size -1 will be the
62- // rightmost.
77+ // Returns the number of curves the plugin wants to paint.
78+ // Be aware that the space to display those curves will be small, and too much data will make
79+ // the output hard to read.
80+ uint32_t (CLAP_ABI * get_curve_count )(const clap_plugin_t * plugin );
81+
82+ // Renders the curve into each the curves buffer.
83+ //
84+ // curves is an array, and each entries (up to curves_size) contains pre-allocated
85+ // values buffer that must be filled by the plugin.
86+ //
87+ // The host will "stack" the curves, from the first one to the last one.
88+ // curves[0] is the first curve to be painted.
89+ // curves[n + 1] will be painted over curves[n].
90+ //
91+ // Returns the number of curves rendered.
6392 // [main-thread]
64- bool (CLAP_ABI * render )(const clap_plugin_t * plugin , uint16_t * data , uint32_t data_size );
93+ uint32_t (CLAP_ABI * render )(const clap_plugin_t * plugin ,
94+ clap_mini_curve_display_curve_data_t * curves ,
95+ uint32_t curves_size );
6596
6697 // Tells the plugin if the curve is currently observed or not.
6798 // When it isn't observed render() can't be called.
6899 //
69- // When is_obseverd becomes true, the curve content and axis name are implicitely invalidated. So
100+ // When is_obseverd becomes true, the curve content and axis name are implicitly invalidated. So
70101 // the plugin don't need to call host->changed.
71102 //
72103 // [main-thread]
@@ -77,6 +108,7 @@ typedef struct clap_plugin_mini_curve_display {
77108 // Returns true on success, if the name capacity was sufficient.
78109 // [main-thread]
79110 bool (CLAP_ABI * get_axis_name )(const clap_plugin_t * plugin ,
111+ uint32_t curve_index ,
80112 char * x_name ,
81113 char * y_name ,
82114 uint32_t name_capacity );
@@ -94,11 +126,11 @@ enum clap_mini_curve_display_change_flags {
94126
95127typedef struct clap_host_mini_curve_display {
96128 // Fills in the given clap_mini_display_curve_hints_t structure and returns
97- // true if succesful . If not, return false.
129+ // true if successful . If not, return false.
98130 // [main-thread]
99- bool (CLAP_ABI * get )(const clap_host_t * host ,
100- uint32_t kind ,
101- clap_mini_display_curve_hints_t * hints );
131+ bool (CLAP_ABI * get_hints )(const clap_host_t * host ,
132+ uint32_t kind ,
133+ clap_mini_curve_display_curve_hints_t * hints );
102134
103135 // Mark the curve as being static or dynamic.
104136 // The curve is initially considered as static, though the plugin should explicitely
0 commit comments