diff --git a/plugins/common/plugin/InstrumentDescription.cpp b/plugins/common/plugin/InstrumentDescription.cpp index e104cc10..7378fd03 100644 --- a/plugins/common/plugin/InstrumentDescription.cpp +++ b/plugins/common/plugin/InstrumentDescription.cpp @@ -98,6 +98,8 @@ std::string getDescriptionBlob(sfizz_synth_t* handle) synth.sendMessage(*client, 0, "/num_masters", "", nullptr); synth.sendMessage(*client, 0, "/num_curves", "", nullptr); synth.sendMessage(*client, 0, "/num_samples", "", nullptr); + synth.sendMessage(*client, 0, "/root_path", "", nullptr); + synth.sendMessage(*client, 0, "/image", "", nullptr); synth.sendMessage(*client, 0, "/key/slots", "", nullptr); synth.sendMessage(*client, 0, "/sw/last/slots", "", nullptr); synth.sendMessage(*client, 0, "/cc/slots", "", nullptr); @@ -140,6 +142,10 @@ InstrumentDescription parseDescriptionBlob(absl::string_view blob) desc.numCurves = uint32_t(args[0].i); else if (Messages::matchOSC("/num_samples", path, indices) && !strcmp(sig, "i")) desc.numSamples = uint32_t(args[0].i); + else if (Messages::matchOSC("/root_path", path, indices) && !strcmp(sig, "s")) + desc.rootPath = args[0].s; + else if (Messages::matchOSC("/image", path, indices) && !strcmp(sig, "s")) + desc.image = args[0].s; else if (Messages::matchOSC("/key/slots", path, indices) && !strcmp(sig, "b")) copyArgToBitSpan(args[0], desc.keyUsed.span()); else if (Messages::matchOSC("/sw/last/slots", path, indices) && !strcmp(sig, "b")) @@ -172,6 +178,9 @@ std::ostream& operator<<(std::ostream& os, const InstrumentDescription& desc) os << " curves: " << desc.numCurves << "\n"; os << " samples: " << desc.numSamples << "\n"; + os << " root_path: " << desc.rootPath << "\n"; + os << " image: " << desc.image << "\n"; + os << " keys:\n"; for (unsigned i = 0; i < 128; ++i) { if (desc.keyUsed.test(i)) { diff --git a/plugins/common/plugin/InstrumentDescription.h b/plugins/common/plugin/InstrumentDescription.h index 88478a2d..b943dcba 100644 --- a/plugins/common/plugin/InstrumentDescription.h +++ b/plugins/common/plugin/InstrumentDescription.h @@ -22,6 +22,8 @@ struct InstrumentDescription { uint32_t numMasters {}; uint32_t numCurves {}; uint32_t numSamples {}; + std::string rootPath; + std::string image; BitArray<128> keyUsed {}; BitArray<128> keyswitchUsed {}; BitArray ccUsed {}; diff --git a/src/sfizz/Synth.cpp b/src/sfizz/Synth.cpp index ea7914ac..e1bc441f 100644 --- a/src/sfizz/Synth.cpp +++ b/src/sfizz/Synth.cpp @@ -246,6 +246,7 @@ void Synth::Impl::clear() effectBuses_[0]->setSampleRate(sampleRate_); effectBuses_[0]->clearInputs(samplesPerBlock_); resources_.clear(); + rootPath_.clear(); numGroups_ = 0; numMasters_ = 0; currentSwitch_ = absl::nullopt; @@ -547,7 +548,11 @@ bool Synth::loadSfzString(const fs::path& path, absl::string_view text) void Synth::Impl::finalizeSfzLoad() { - resources_.filePool.setRootDirectory(parser_.originalDirectory()); + const fs::path& rootDirectory = parser_.originalDirectory(); + resources_.filePool.setRootDirectory(rootDirectory); + + // a string representation used for OSC purposes + rootPath_ = rootDirectory.u8string(); size_t currentRegionIndex = 0; size_t currentRegionCount = layers_.size(); diff --git a/src/sfizz/SynthMessaging.cpp b/src/sfizz/SynthMessaging.cpp index 70fc6ed5..5cead784 100644 --- a/src/sfizz/SynthMessaging.cpp +++ b/src/sfizz/SynthMessaging.cpp @@ -76,10 +76,16 @@ void sfz::Synth::dispatchMessage(Client& client, int delay, const char* path, co //---------------------------------------------------------------------- + MATCH("/root_path", "") { + client.receive<'s'>(delay, path, impl.rootPath_.c_str()); + } break; + MATCH("/image", "") { client.receive<'s'>(delay, path, impl.image_.c_str()); } break; + //---------------------------------------------------------------------- + MATCH("/sw/last/slots", "") { const BitArray<128>& switches = impl.swLastSlots_; sfizz_blob_t blob { switches.data(), static_cast(switches.byte_size()) }; diff --git a/src/sfizz/SynthPrivate.h b/src/sfizz/SynthPrivate.h index 74fa5e34..3b8835a6 100644 --- a/src/sfizz/SynthPrivate.h +++ b/src/sfizz/SynthPrivate.h @@ -278,6 +278,9 @@ struct Synth::Impl final: public Parser::Listener { // Singletons passed as references to the voices Resources resources_; + // Root path + std::string rootPath_; + // Control opcodes std::string defaultPath_ { "" }; std::string image_ { "" };