Send UI the instrument description

This commit is contained in:
Jean Pierre Cimalando 2021-04-02 18:39:52 +02:00
parent 10b36293b6
commit 5e06aba595
3 changed files with 74 additions and 9 deletions

View file

@ -22,11 +22,19 @@ enum class EditId : int {
UserFilesDir, UserFilesDir,
FallbackFilesDir, FallbackFilesDir,
// //
Key0, #define KEY_RANGE(Name) Name##0, Name##Last = Name##0 + 128 - 1
KeyLast = Key0 + 128 - 1, #define CC_RANGE(Name) Name##0, Name##Last = Name##0 + sfz::config::numCCs - 1
// //
Controller0, KEY_RANGE(Key),
ControllerLast = Controller0 + sfz::config::numCCs - 1, CC_RANGE(Controller),
//
KEY_RANGE(KeyUsed),
KEY_RANGE(KeyLabel),
KEY_RANGE(KeyswitchUsed),
KEY_RANGE(KeyswitchLabel),
CC_RANGE(ControllerUsed),
CC_RANGE(ControllerDefault),
CC_RANGE(ControllerLabel),
// //
UINumCurves, UINumCurves,
UINumMasters, UINumMasters,
@ -35,6 +43,9 @@ enum class EditId : int {
UINumPreloadedSamples, UINumPreloadedSamples,
UINumActiveVoices, UINumActiveVoices,
UIActivePanel, UIActivePanel,
//
#undef KEY_RANGE
#undef CC_RANGE
}; };
struct EditRange { struct EditRange {
@ -66,5 +77,12 @@ struct EditRange {
// defines editIdForCC, ccForEditId, editIdIsCC, etc.. // defines editIdForCC, ccForEditId, editIdIsCC, etc..
DEFINE_EDIT_ID_RANGE_HELPERS(cc, CC, Controller) DEFINE_EDIT_ID_RANGE_HELPERS(cc, CC, Controller)
DEFINE_EDIT_ID_RANGE_HELPERS(key, Key, Key) DEFINE_EDIT_ID_RANGE_HELPERS(key, Key, Key)
DEFINE_EDIT_ID_RANGE_HELPERS(keyUsed, KeyUsed, KeyUsed)
DEFINE_EDIT_ID_RANGE_HELPERS(keyLabel, KeyLabel, KeyLabel)
DEFINE_EDIT_ID_RANGE_HELPERS(keyswitchUsed, KeyswitchUsed, KeyswitchUsed)
DEFINE_EDIT_ID_RANGE_HELPERS(keyswitchLabel, KeyswitchLabel, KeyswitchLabel)
DEFINE_EDIT_ID_RANGE_HELPERS(ccUsed, CCUsed, ControllerUsed)
DEFINE_EDIT_ID_RANGE_HELPERS(ccDefault, CCDefault, ControllerDefault)
DEFINE_EDIT_ID_RANGE_HELPERS(ccLabel, CCLabel, ControllerLabel)
#undef DEFINE_EDIT_ID_RANGE_HELPERS #undef DEFINE_EDIT_ID_RANGE_HELPERS

View file

@ -371,11 +371,33 @@ port_event(LV2UI_Handle ui,
} }
static void static void
sfizz_ui_update_description(const InstrumentDescription& desc) sfizz_ui_update_description(sfizz_ui_t *self, const InstrumentDescription& desc)
{ {
// TODO(jpc) perform editor updates here self->uiReceiveValue(EditId::UINumCurves, desc.numCurves);
self->uiReceiveValue(EditId::UINumMasters, desc.numMasters);
self->uiReceiveValue(EditId::UINumGroups, desc.numGroups);
self->uiReceiveValue(EditId::UINumRegions, desc.numRegions);
self->uiReceiveValue(EditId::UINumPreloadedSamples, desc.numSamples);
//std::cerr << desc << std::endl; for (unsigned key = 0; key < 128; ++key) {
bool keyUsed = desc.keyUsed.test(key);
bool keyswitchUsed = desc.keyswitchUsed.test(key);
self->uiReceiveValue(editIdForKeyUsed(key), float(keyUsed));
self->uiReceiveValue(editIdForKeyswitchUsed(key), float(keyswitchUsed));
if (keyUsed)
self->uiReceiveValue(editIdForKeyLabel(key), desc.keyLabel[key]);
if (keyswitchUsed)
self->uiReceiveValue(editIdForKeyswitchLabel(key), desc.keyswitchLabel[key]);
}
for (unsigned cc = 0; cc < sfz::config::numCCs; ++cc) {
bool ccUsed = desc.ccUsed.test(cc);
self->uiReceiveValue(editIdForCCUsed(cc), float(ccUsed));
if (ccUsed) {
self->uiReceiveValue(editIdForCCDefault(cc), desc.ccDefault[cc]);
self->uiReceiveValue(editIdForCCLabel(cc), desc.ccLabel[cc]);
}
}
} }
static void static void
@ -396,7 +418,7 @@ sfizz_ui_check_sfz_update(sfizz_ui_t *self)
const InstrumentDescription desc = parseDescriptionBlob( const InstrumentDescription desc = parseDescriptionBlob(
absl::string_view(reinterpret_cast<char*>(data), size)); absl::string_view(reinterpret_cast<char*>(data), size));
sfizz_ui_update_description(desc); sfizz_ui_update_description(self, desc);
} }
} }

View file

@ -196,7 +196,32 @@ void PLUGIN_API SfizzVstEditor::update(FUnknown* changedUnknown, int32 message)
if (SfzDescriptionUpdate* update = FCast<SfzDescriptionUpdate>(changedUnknown)) { if (SfzDescriptionUpdate* update = FCast<SfzDescriptionUpdate>(changedUnknown)) {
const InstrumentDescription desc = parseDescriptionBlob(update->getDescription()); const InstrumentDescription desc = parseDescriptionBlob(update->getDescription());
// TODO(jpc) instrument description
uiReceiveValue(EditId::UINumCurves, desc.numCurves);
uiReceiveValue(EditId::UINumMasters, desc.numMasters);
uiReceiveValue(EditId::UINumGroups, desc.numGroups);
uiReceiveValue(EditId::UINumRegions, desc.numRegions);
uiReceiveValue(EditId::UINumPreloadedSamples, desc.numSamples);
for (unsigned key = 0; key < 128; ++key) {
bool keyUsed = desc.keyUsed.test(key);
bool keyswitchUsed = desc.keyswitchUsed.test(key);
uiReceiveValue(editIdForKeyUsed(key), float(keyUsed));
uiReceiveValue(editIdForKeyswitchUsed(key), float(keyswitchUsed));
if (keyUsed)
uiReceiveValue(editIdForKeyLabel(key), desc.keyLabel[key]);
if (keyswitchUsed)
uiReceiveValue(editIdForKeyswitchLabel(key), desc.keyswitchLabel[key]);
}
for (unsigned cc = 0; cc < sfz::config::numCCs; ++cc) {
bool ccUsed = desc.ccUsed.test(cc);
uiReceiveValue(editIdForCCUsed(cc), float(ccUsed));
if (ccUsed) {
uiReceiveValue(editIdForCCDefault(cc), desc.ccDefault[cc]);
uiReceiveValue(editIdForCCLabel(cc), desc.ccLabel[cc]);
}
}
} }
if (ScalaUpdate* update = FCast<ScalaUpdate>(changedUnknown)) { if (ScalaUpdate* update = FCast<ScalaUpdate>(changedUnknown)) {