Merge pull request #646 from jpcima/send-key-ranges

Send key ranges to editor
This commit is contained in:
JP Cimalando 2021-02-22 20:06:22 +01:00 committed by GitHub
commit eab7d6e2da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 4 deletions

View file

@ -219,7 +219,8 @@ void Editor::open(CFrame& frame)
impl.frame_ = &frame;
frame.addView(impl.mainView_.get());
// request the whole CC information
// request the whole Key and CC information
impl.sendQueuedOSC("/key/slots", "", nullptr);
impl.sendQueuedOSC("/cc/slots", "", nullptr);
}
@ -244,7 +245,8 @@ void Editor::Impl::uiReceiveValue(EditId id, const EditValue& v)
currentSfzFile_ = value;
updateSfzFileLabel(value);
// request the whole CC information
// request the whole Key and CC information
sendQueuedOSC("/key/slots", "", nullptr);
sendQueuedOSC("/cc/slots", "", nullptr);
}
break;
@ -390,7 +392,10 @@ void Editor::Impl::uiReceiveMessage(const char* path, const char* sig, const sfi
{
unsigned indices[8];
if (Messages::matchOSC("/cc/slots", path, indices) && !strcmp(sig, "b")) {
if (Messages::matchOSC("/key/slots", path, indices) && !strcmp(sig, "b")) {
// TODO(jpc) key ranges
}
else if (Messages::matchOSC("/cc/slots", path, indices) && !strcmp(sig, "b")) {
const uint8_t* bitChunks = args[0].b->data;
uint32_t byteSize = args[0].b->size;
@ -962,7 +967,8 @@ void Editor::Impl::changeSfzFile(const std::string& filePath)
currentSfzFile_ = filePath;
updateSfzFileLabel(filePath);
// request the whole CC information
// request the whole Key and CC information
sendQueuedOSC("/key/slots", "", nullptr);
sendQueuedOSC("/cc/slots", "", nullptr);
}

View file

@ -249,6 +249,7 @@ void Synth::Impl::clear()
currentUsedCCs_.clear();
changedCCsThisCycle_.clear();
keyLabels_.clear();
keySlots_.clear();
keyswitchLabels_.clear();
globalOpcodes_.clear();
masterOpcodes_.clear();
@ -735,6 +736,15 @@ void Synth::Impl::finalizeSfzLoad()
// cache the set of used CCs for future access
currentUsedCCs_ = collectAllUsedCCs();
// cache the set of keys assigned
for (const RegionPtr& regionPtr : regions_) {
Range<uint8_t> keyRange = regionPtr->keyRange;
unsigned loKey = keyRange.getStart();
unsigned hiKey = keyRange.getEnd();
for (unsigned key = loKey; key <= hiKey; ++key)
keySlots_.set(key);
}
}
bool Synth::loadScalaFile(const fs::path& path)

View file

@ -38,6 +38,14 @@ void sfz::Synth::dispatchMessage(Client& client, int delay, const char* path, co
//----------------------------------------------------------------------
MATCH("/key/slots", "") {
const BitArray<128>& keys = impl.keySlots_;
sfizz_blob_t blob { keys.data(), static_cast<uint32_t>(keys.byte_size()) };
client.receive<'b'>(delay, path, &blob);
} break;
//----------------------------------------------------------------------
MATCH("/cc/slots", "") {
const BitArray<config::numCCs>& ccs = impl.currentUsedCCs_;
sfizz_blob_t blob { ccs.data(), static_cast<uint32_t>(ccs.byte_size()) };

View file

@ -216,6 +216,7 @@ struct Synth::Impl final: public Parser::Listener {
std::vector<CCNamePair> ccLabels_;
std::map<int, size_t> ccLabelsMap_;
std::vector<NoteNamePair> keyLabels_;
BitArray<128> keySlots_;
std::vector<NoteNamePair> keyswitchLabels_;
// Set as sw_default if present in the file