Skip to content
Merged

Next #29

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions plugins/core-plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -342,16 +342,25 @@ namespace clap {
}

void CorePlugin::pushGuiToPluginEvent(const GuiToPluginEvent &event) {
if (!_host.canUseFlushEvents() && !_host.canUseParams())
return;

// very highly likely to succeed
while (!_guiToPluginQueue.tryPush(event)) {
if (_host.canUseParams())
if (_host.canUseFlushEvents())
_host.flushEventsRequestFlush();
else if (_host.canUseParams())
_host.paramsRequestFlush();

std::this_thread::sleep_for(std::chrono::milliseconds(1));
}

if (!isProcessing() && _host.canUseParams())
_host.paramsRequestFlush();
if (!isProcessing() && _host.canUseParams()) {
if (_host.canUseFlushEvents())
_host.flushEventsRequestFlush();
else if (_host.canUseParams())
_host.paramsRequestFlush();
}
}

void CorePlugin::onGuiSetTransportIsSubscribed(bool isSubscribed) {
Expand Down Expand Up @@ -714,6 +723,11 @@ namespace clap {

void CorePlugin::paramsFlush(const clap_input_events *in,
const clap_output_events *out) noexcept {
flushEventsFlush(in, out);
}

void CorePlugin::flushEventsFlush(const clap_input_events *in,
const clap_output_events *out) noexcept {
if (in) {
const uint32_t N = in->size(in);
for (uint32_t i = 0; i < N; ++i) {
Expand Down Expand Up @@ -869,6 +883,20 @@ namespace clap {
return p;
}

//---------------------------//
// clap_plugin_params_origin //
//---------------------------//
bool CorePlugin::implementsParamsOrigin() const noexcept { return true; }

bool CorePlugin::paramsOriginGet(clap_id param_id, double *out_value) noexcept {
auto param = _parameters.getById(param_id);
if (!param)
return false;

*out_value = param->valueType()->originValue();
return true;
}

bool CorePlugin::implementsVoiceInfo() const noexcept { return true; }

bool CorePlugin::voiceInfoDoGet(clap_voice_info *info) noexcept {
Expand Down
13 changes: 13 additions & 0 deletions plugins/core-plugin.hh
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ namespace clap {

int32_t getParamIndexForParamId(clap_id paramId) const noexcept override;

//--------------------------//
// clap_plugin_flush_events //
//--------------------------//
bool implementsFlushEvents() const noexcept override { return true; }
void flushEventsFlush(const clap_input_events *in,
const clap_output_events *out) noexcept override;

//------------------------------//
// clap_plugin_param_indication //
//------------------------------//
Expand All @@ -149,6 +156,12 @@ namespace clap {
uint32_t automation_state,
const clap_color_t *color) noexcept override;

//---------------------------//
// clap_plugin_params_origin //
//---------------------------//
bool implementsParamsOrigin() const noexcept override;
bool paramsOriginGet(clap_id param_id, double *out_value) noexcept override;

//-------------------//
// clap_plugin_state //
//-------------------//
Expand Down
4 changes: 3 additions & 1 deletion plugins/parameter.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "parameter.hh"

namespace clap {
Parameter::Parameter(const clap_param_info &info, std::unique_ptr<ValueType> valueType, uint32_t paramIndex)
Parameter::Parameter(const clap_param_info &info,
std::unique_ptr<ValueType> valueType,
uint32_t paramIndex)
: _index(paramIndex), _info(info), _valueType(std::move(valueType)) {
_info.cookie = this;
reset();
Expand Down
3 changes: 2 additions & 1 deletion plugins/parameters.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ namespace clap {
Parameters() = default;
Parameters(const Parameters &parameters);

Parameter *addParameter(const clap_param_info &info, std::unique_ptr<ValueType> valueType);
Parameter *addParameter(const clap_param_info &info,
std::unique_ptr<ValueType> valueType);

size_t count() const noexcept;

Expand Down
2 changes: 1 addition & 1 deletion plugins/plugs/gain/gain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace clap {
"gain",
CLAP_PARAM_IS_AUTOMATABLE | CLAP_PARAM_IS_MODULATABLE |
CLAP_PARAM_REQUIRES_PROCESS,
std::make_unique<DecibelValueType>(-40, 40, 0));
std::make_unique<DecibelValueType>(-40, 40, 0, 0));
}

clap_process_status process(const Context &c, uint32_t numFrames) noexcept override {
Expand Down
7 changes: 4 additions & 3 deletions plugins/value-types/boolean-value-type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ namespace clap {
}

double BooleanValueType::fromText(const std::string &paramValueText) const {
if (::strcasecmp(paramValueText.c_str(), "true") || ::strcasecmp(paramValueText.c_str(), "1"))
if (::strcmp(paramValueText.c_str(), "true") || ::strcmp(paramValueText.c_str(), "True") ||
::strcmp(paramValueText.c_str(), "TRUE") || ::strcmp(paramValueText.c_str(), "1"))
return true;

if (::strcasecmp(paramValueText.c_str(), "false") ||
::strcasecmp(paramValueText.c_str(), "0"))
if (::strcmp(paramValueText.c_str(), "false") || ::strcmp(paramValueText.c_str(), "False") ||
::strcmp(paramValueText.c_str(), "FALSE") || ::strcmp(paramValueText.c_str(), "0"))
return true;

return _defaultValue;
Expand Down
3 changes: 2 additions & 1 deletion plugins/value-types/decibel-value-type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

namespace clap {

DecibelValueType::DecibelValueType(double min, double max, double dflt) : _minValue(min), _maxValue(max), _defaultValue(dflt) {}
DecibelValueType::DecibelValueType(double min, double max, double dflt, double originValue)
: _minValue(min), _maxValue(max), _defaultValue(dflt), _originValue(originValue) {}

std::string DecibelValueType::toText(double paramValue) const {
std::ostringstream os;
Expand Down
7 changes: 6 additions & 1 deletion plugins/value-types/decibel-value-type.hh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
namespace clap {
class DecibelValueType final : public ValueType {
public:
DecibelValueType(double min = -120, double max = +120, double defaultValue = 0);
DecibelValueType(double min = -120,
double max = +120,
double defaultValue = 0,
double originValue = 0);

double minValue() const noexcept override { return _minValue; }
double maxValue() const noexcept override { return _maxValue; }
double defaultValue() const noexcept override { return _defaultValue; }
double originValue() const noexcept override { return _originValue; }

std::string toText(double paramValue) const override;
double fromText(const std::string &paramValueText) const override;
Expand All @@ -24,5 +28,6 @@ namespace clap {
const double _minValue;
const double _maxValue;
const double _defaultValue;
const double _originValue;
};
} // namespace clap
1 change: 1 addition & 0 deletions plugins/value-types/value-type.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace clap {
[[nodiscard]] virtual double defaultValue() const noexcept { return std::numeric_limits<double>::lowest(); }
[[nodiscard]] virtual double minValue() const noexcept { return std::numeric_limits<double>::lowest(); }
[[nodiscard]] virtual double maxValue() const noexcept { return std::numeric_limits<double>::max(); }
[[nodiscard]] virtual double originValue() const noexcept { return minValue(); }

[[nodiscard]] virtual std::string toText(double paramValue) const = 0;
[[nodiscard]] virtual double fromText(const std::string &paramValueText) const = 0;
Expand Down
2 changes: 1 addition & 1 deletion vcpkg
Submodule vcpkg updated 6433 files
Loading