Parameter changes and correct value displays
This commit is contained in:
parent
4dd9d55c62
commit
b4412624a9
@ -148,11 +148,34 @@ struct Plugin : public clap_plugin {
|
|||||||
std::vector<float *> outputBuffers;
|
std::vector<float *> outputBuffers;
|
||||||
|
|
||||||
void processEvent(const clap_event_header *header) {
|
void processEvent(const clap_event_header *header) {
|
||||||
LOG_EXPR(header->size);
|
if (header->space_id != CLAP_CORE_EVENT_SPACE_ID) return; // only core events supported atm
|
||||||
LOG_EXPR(header->time);
|
if (header->type == CLAP_EVENT_PARAM_VALUE) {
|
||||||
LOG_EXPR(header->space_id);
|
auto *event = (clap_event_param_value *)header;
|
||||||
LOG_EXPR(header->type);
|
auto *param = (Param *)event->cookie;
|
||||||
LOG_EXPR(header->flags);
|
if (!param) {
|
||||||
|
auto paramId = event->param_id;
|
||||||
|
for (auto &p : params) {
|
||||||
|
if (p.id == paramId) {
|
||||||
|
param = &p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!param) return; // invalid parameter
|
||||||
|
} else if (param->id != event->param_id) {
|
||||||
|
return; // inconsistent ID / cookie
|
||||||
|
}
|
||||||
|
if (param->rangeParam) {
|
||||||
|
*param->rangeParam = param->rangeInfo->fromUnit(event->value);
|
||||||
|
} else {
|
||||||
|
*param->steppedParam = int(std::round(event->value));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOG_EXPR(header->size);
|
||||||
|
LOG_EXPR(header->time);
|
||||||
|
LOG_EXPR(header->space_id);
|
||||||
|
LOG_EXPR(header->type);
|
||||||
|
LOG_EXPR(header->flags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CLAP plugin methods
|
// CLAP plugin methods
|
||||||
@ -361,7 +384,7 @@ struct Plugin : public clap_plugin {
|
|||||||
for (auto ¶m : plugin.params) {
|
for (auto ¶m : plugin.params) {
|
||||||
if (param.id == paramId) {
|
if (param.id == paramId) {
|
||||||
if (param.rangeParam) {
|
if (param.rangeParam) {
|
||||||
auto str = param.rangeInfo->toString(value);
|
auto str = param.rangeInfo->toString(param.rangeInfo->fromUnit(value));
|
||||||
std::strncpy(text, str.c_str(), textCapacity);
|
std::strncpy(text, str.c_str(), textCapacity);
|
||||||
} else {
|
} else {
|
||||||
auto str = param.steppedInfo->toString(int(std::round(value)));
|
auto str = param.steppedInfo->toString(int(std::round(value)));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user