Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a param-origin extension #429

Draft
wants to merge 9 commits into
base: next
Choose a base branch
from
61 changes: 61 additions & 0 deletions include/clap/ext/draft/param-origin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#pragma once

#include "../../plugin.h"

static CLAP_CONSTEXPR const char CLAP_EXT_PARAM_ORIGIN[] = "clap.param-origin/1";

#ifdef __cplusplus
extern "C" {
#endif

/// This extension provides an optional value per parameter that lets the host draw a visual
/// indication for the parameter's origin.
///
/// examples:
/// - lowpass filter cutoff parameter with an origin equal to param_info.min_value
/// [--------------> ]
/// 60Hz 20kHz
/// min=origin max
/// - highpass filter cutoff parameter with an origin equal to param_info.max_value
/// [ <--------------]
/// 60Hz 20kHz
/// min max=origin
/// - (bipolar) parameter with a range from -1.0 to +1.0 with an origin of 0.0
/// [ <------| ]
/// -1.0 0.0 +1.0
/// min origin max
/// - crossfade parameter without an origin
/// [ o ]
/// A B
/// min max

typedef struct clap_plugin_param_origin {
// Get the origin value for a parameter.
// Returns false if the parameter has no origin, true otherwise.
// The host must not call this for params with CLAP_PARAM_IS_ENUM flag set.
//
// out_value constraints:
// - has to be in the range from param_info.min_value to param_info.max_value
// - has to be an integer value if CLAP_PARAM_IS_STEPPED flag is set
// [main-thread]
bool(CLAP_ABI *get)(const clap_plugin_t *plugin, clap_id param_id, double *out_value);
} clap_plugin_param_origin_t;

typedef struct clap_host_param_origin {
// Informs the host that param origins have changed.
//
// Note: If the plugin calls params.rescan with CLAP_PARAM_RESCAN_ALL, all previously scanned
// parameter origins must be considered invalid. It is thus not necessary for the plugin to call
// param_origin.changed in this case.
//
// Note: This is useful if a parameter origin changes on-the-fly. For example a plugin might want
// to change the origin of a filter cutoff frequency parameter when the corresponding filter type
// (LP/BP/HP) has changed.
//
// [main-thread]
void(CLAP_ABI *changed)(const clap_host_t *host);
} clap_host_param_origin_t;

#ifdef __cplusplus
}
#endif
6 changes: 6 additions & 0 deletions include/clap/host.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ typedef struct clap_host {
void(CLAP_ABI *request_process)(const struct clap_host *host);

// Request the host to schedule a call to plugin->on_main_thread(plugin) on the main thread.
// This callback should be called as soon as practicable, usually in the host application's next
// available main thread time slice. Typically callbacks occur withink 33ms / 30hz.
// Despite this guidance, plugins should not make assumptions about the exactness of timing for
// a main thread callback, but hosts should endeavour to be prompt. For example, in high load situations
// the environment may starve the gui/main thread in favor of audio processing, leading to substantially
// longer latencies for the callback than the indicative times given here.
// [thread-safe]
void(CLAP_ABI *request_callback)(const struct clap_host *host);
} clap_host_t;
Expand Down
Loading