Skip to content

Commit

Permalink
eliminated category and name from resource ID
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanPudashkin committed Dec 20, 2024
1 parent 12b3b9c commit cc07633
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/framework/musesampler/internal/musesamplerresolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ AudioResourceMetaList MuseSamplerResolver::resolveResources() const
}

AudioResourceMeta meta;
meta.id = buildMuseInstrumentId(internalCategory, internalName, instrumentId).toStdString();
meta.id = std::to_string(instrumentId);
meta.type = AudioResourceType::MuseSamplerSoundPack;
meta.vendor = "MuseSounds";
meta.attributes = {
Expand Down Expand Up @@ -307,7 +307,7 @@ std::vector<Instrument> MuseSamplerResolver::instruments() const
JsonObject obj = doc.rootObject();

Instrument instrument;
instrument.id = buildMuseInstrumentId(instrument.category, instrument.name, id);
instrument.id = String::number(id);
instrument.soundId = String::fromUtf8(m_libHandler->getMpeSoundId(msInstrument));
instrument.musicXmlId = String::fromUtf8(m_libHandler->getMusicXmlSoundId(msInstrument));
instrument.name = obj.value("FriendlyName").toString();
Expand Down Expand Up @@ -336,13 +336,3 @@ void MuseSamplerResolver::loadSoundPresetAttributes(SoundPresetAttributes& attri
}
}
}

String MuseSamplerResolver::buildMuseInstrumentId(const String& category, const String& name, int uniqueId) const
{
StringList list;
list.append(category);
list.append(name);
list.append(String::fromStdString(std::to_string(uniqueId)));

return list.join(u"\\");
}
18 changes: 18 additions & 0 deletions src/project/internal/projectaudiosettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ static const std::map<AudioResourceType, QString> RESOURCE_TYPE_MAP = {
{ AudioResourceType::MusePlugin, "muse_plugin" },
};

static void doCompatibilityConversions(AudioResourceMeta& meta)
{
if (meta.type == AudioResourceType::MuseSamplerSoundPack) {
// MS 4.5: resource name and category have been excluded from ID
// Old format: category\\name\\uid
if (meta.id.find("\\") == std::string::npos) {
return;
}

const String& museUID = meta.attributeVal(u"museUID");
if (!museUID.empty()) {
meta.id = museUID.toStdString();
}
}
}

const AudioOutputParams& ProjectAudioSettings::masterAudioOutputParams() const
{
return m_masterOutputParams;
Expand Down Expand Up @@ -258,6 +274,8 @@ Ret ProjectAudioSettings::read(const engraving::MscReader& reader)
AudioInputParams inParams = inputParamsFromJson(trackObject.value("in").toObject());
AudioOutputParams outParams = outputParamsFromJson(trackObject.value("out").toObject());

doCompatibilityConversions(inParams.resourceMeta);

m_trackInputParamsMap.emplace(id, std::move(inParams));
m_trackOutputParamsMap.emplace(id, std::move(outParams));
}
Expand Down

0 comments on commit cc07633

Please sign in to comment.