Allow UI to send value by controller
This commit is contained in:
parent
308eb788e6
commit
2436414ad8
4 changed files with 45 additions and 8 deletions
|
|
@ -306,6 +306,12 @@ void Editor::close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Editor::sendQueuedOSC(const char* path, const char* sig, const sfizz_arg_t* args)
|
||||||
|
{
|
||||||
|
Impl& impl = *impl_;
|
||||||
|
impl.sendQueuedOSC(path, sig, args);
|
||||||
|
}
|
||||||
|
|
||||||
void Editor::Impl::uiReceiveValue(EditId id, const EditValue& v)
|
void Editor::Impl::uiReceiveValue(EditId id, const EditValue& v)
|
||||||
{
|
{
|
||||||
switch (id) {
|
switch (id) {
|
||||||
|
|
@ -1613,13 +1619,8 @@ void Editor::Impl::updateMemoryUsed(uint64_t mem)
|
||||||
|
|
||||||
void Editor::Impl::performCCValueChange(unsigned cc, float value)
|
void Editor::Impl::performCCValueChange(unsigned cc, float value)
|
||||||
{
|
{
|
||||||
// TODO(jpc) CC as parameters and automation
|
EditorController& ctrl = *ctrl_;
|
||||||
|
ctrl.uiSendValue(editIdForCC(int(cc)), value);
|
||||||
char pathBuf[256];
|
|
||||||
sprintf(pathBuf, "/cc%u/value", cc);
|
|
||||||
sfizz_arg_t args[1];
|
|
||||||
args[0].f = value;
|
|
||||||
sendQueuedOSC(pathBuf, "f", args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::Impl::performCCBeginEdit(unsigned cc)
|
void Editor::Impl::performCCBeginEdit(unsigned cc)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <sfizz_message.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
class EditorController;
|
class EditorController;
|
||||||
|
|
||||||
|
|
@ -24,6 +25,9 @@ public:
|
||||||
void open(CFrame& frame);
|
void open(CFrame& frame);
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
|
// TODO(jpc) remove me after doing parameter automations
|
||||||
|
void sendQueuedOSC(const char* path, const char* sig, const sfizz_arg_t* args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Impl;
|
struct Impl;
|
||||||
std::unique_ptr<Impl> impl_;
|
std::unique_ptr<Impl> impl_;
|
||||||
|
|
|
||||||
|
|
@ -537,6 +537,22 @@ void sfizz_ui_t::uiSendValue(EditId id, const EditValue& v)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto sendController = [this](LV2_URID property, float value) {
|
||||||
|
LV2_Atom_Forge *forge = &atom_forge;
|
||||||
|
LV2_Atom_Forge_Frame frame;
|
||||||
|
auto *atom = reinterpret_cast<const LV2_Atom *>(atom_temp);
|
||||||
|
lv2_atom_forge_set_buffer(forge, atom_temp, sizeof(atom_temp));
|
||||||
|
if (lv2_atom_forge_object(forge, &frame, 0, patch_set_uri) &&
|
||||||
|
lv2_atom_forge_key(forge, patch_property_uri) &&
|
||||||
|
lv2_atom_forge_urid(forge, property) &&
|
||||||
|
lv2_atom_forge_key(forge, patch_value_uri) &&
|
||||||
|
lv2_atom_forge_float(forge, value))
|
||||||
|
{
|
||||||
|
lv2_atom_forge_pop(forge, &frame);
|
||||||
|
write(con, SFIZZ_CONTROL, lv2_atom_total_size(atom), atom_event_transfer_uri, atom);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case EditId::Volume:
|
case EditId::Volume:
|
||||||
sendFloat(SFIZZ_VOLUME, v.to_float());
|
sendFloat(SFIZZ_VOLUME, v.to_float());
|
||||||
|
|
@ -566,6 +582,11 @@ void sfizz_ui_t::uiSendValue(EditId id, const EditValue& v)
|
||||||
sendPath(sfizz_scala_file_uri, v.to_string());
|
sendPath(sfizz_scala_file_uri, v.to_string());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
if (editIdIsCC(id)) {
|
||||||
|
int cc = ccForEditId(id);
|
||||||
|
LV2_URID urid = sfizz_lv2_ccmap_map(ccmap.get(), cc);
|
||||||
|
sendController(urid, v.to_float());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -329,7 +329,18 @@ void SfizzVstEditor::processNoteEventQueue()
|
||||||
///
|
///
|
||||||
void SfizzVstEditor::uiSendValue(EditId id, const EditValue& v)
|
void SfizzVstEditor::uiSendValue(EditId id, const EditValue& v)
|
||||||
{
|
{
|
||||||
if (id == EditId::SfzFile)
|
if (editIdIsCC(id)) {
|
||||||
|
int cc = ccForEditId(id);
|
||||||
|
// TODO(jpc) CC as parameters and automation
|
||||||
|
if (Editor* editor = editor_.get()) {
|
||||||
|
char pathBuf[256];
|
||||||
|
sprintf(pathBuf, "/cc%u/value", cc);
|
||||||
|
sfizz_arg_t args[1];
|
||||||
|
args[0].f = v.to_float();
|
||||||
|
editor->sendQueuedOSC(pathBuf, "f", args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (id == EditId::SfzFile)
|
||||||
loadSfzFile(v.to_string());
|
loadSfzFile(v.to_string());
|
||||||
else if (id == EditId::ScalaFile)
|
else if (id == EditId::ScalaFile)
|
||||||
loadScalaFile(v.to_string());
|
loadScalaFile(v.to_string());
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue