Skip to content

Commit

Permalink
Merge pull request #14884 from vpereverzev/musesounds_mappings
Browse files Browse the repository at this point in the history
[MU4] preparation_for_musesounds_mappings
  • Loading branch information
vpereverzev committed Dec 2, 2022
1 parent 9de7022 commit 85598a7
Show file tree
Hide file tree
Showing 8 changed files with 479 additions and 401 deletions.
15 changes: 9 additions & 6 deletions src/engraving/playback/mapping/stringssetupdataresolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,17 @@ PlaybackSetupData StringsSetupDataResolver::doResolve(const Instrument* instrume
{ "strings", { SoundId::StringsGroup, SoundCategory::Strings, {}, {} } },
{ "double-bass", { SoundId::Contrabass, SoundCategory::Strings, { SoundSubCategory::Orchestral }, {} } },
{ "contrabass", { SoundId::Contrabass, SoundCategory::Strings, { SoundSubCategory::Orchestral }, {} } },
{ "contrabasses", { SoundId::ContrabassSection, SoundCategory::Strings, { SoundSubCategory::Orchestral }, {} } },
{ "contrabasses", { SoundId::Contrabass, SoundCategory::Strings, { SoundSubCategory::Orchestral,
SoundSubCategory::Section }, {} } },
{ "violin", { SoundId::Violin, SoundCategory::Strings, { SoundSubCategory::Orchestral }, {} } },
{ "violins", { SoundId::ViolinSection, SoundCategory::Strings, { SoundSubCategory::Orchestral }, {} } },
{ "violins", { SoundId::Violin, SoundCategory::Strings, { SoundSubCategory::Orchestral,
SoundSubCategory::Section }, {} } },
{ "viola", { SoundId::Viola, SoundCategory::Strings, { SoundSubCategory::Orchestral }, {} } },
{ "violas", { SoundId::ViolaSection, SoundCategory::Strings, { SoundSubCategory::Orchestral }, {} } },
{ "violas", { SoundId::Viola, SoundCategory::Strings, { SoundSubCategory::Orchestral,
SoundSubCategory::Section }, {} } },
{ "violoncello", { SoundId::Violoncello, SoundCategory::Strings, { SoundSubCategory::Orchestral }, {} } },
{ "violoncellos", { SoundId::VioloncelloSection, SoundCategory::Strings, { SoundSubCategory::Orchestral }, {} } },
{ "violoncellos", { SoundId::Violoncello, SoundCategory::Strings, { SoundSubCategory::Orchestral,
SoundSubCategory::Section }, {} } },

{ "treble-viol", { SoundId::Viol, SoundCategory::Strings, {}, {} } },
{ "alto-viol", { SoundId::Viol, SoundCategory::Strings, { SoundSubCategory::Alto }, {} } },
Expand Down Expand Up @@ -271,8 +275,7 @@ PlaybackSetupData StringsSetupDataResolver::doResolve(const Instrument* instrume
}

static const std::unordered_set<SoundId> supportPrimaryAndSecondaryCategories {
SoundId::Violin,
SoundId::ViolinSection,
SoundId::Violin
};

if (mu::contains(supportPrimaryAndSecondaryCategories, search->second.id)) {
Expand Down
4 changes: 2 additions & 2 deletions src/engraving/playback/mapping/voicessetupdataresolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ PlaybackSetupData VoicesSetupDataResolver::doResolve(const Instrument* instrumen
SoundSubCategory::Boy }, {} } },
{ "soprano", { SoundId::Choir, SoundCategory::Voices, { SoundSubCategory::Soprano }, {} } },
{ "soprano-c-clef", { SoundId::Choir, SoundCategory::Voices, { SoundSubCategory::Soprano }, {} } },
{ "mezzo-soprano", { SoundId::Choir, SoundCategory::Voices, { SoundSubCategory::Mezzo_Soprano }, {} } },
{ "mezzo-soprano-c-clef", { SoundId::Choir, SoundCategory::Voices, { SoundSubCategory::Mezzo_Soprano }, {} } },
{ "mezzo-soprano", { SoundId::Choir, SoundCategory::Voices, { SoundSubCategory::Soprano }, {} } },
{ "mezzo-soprano-c-clef", { SoundId::Choir, SoundCategory::Voices, { SoundSubCategory::Soprano }, {} } },
{ "countertenor", { SoundId::Choir, SoundCategory::Voices, { SoundSubCategory::Counter_Tenor }, {} } },
{ "alto", { SoundId::Choir, SoundCategory::Voices, { SoundSubCategory::Alto }, {} } },
{ "alto-c-clef", { SoundId::Choir, SoundCategory::Voices, { SoundSubCategory::Alto }, {} } },
Expand Down
44 changes: 27 additions & 17 deletions src/engraving/playback/mapping/windssetupdataresolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,24 @@ PlaybackSetupData WindsSetupDataResolver::doResolve(const Instrument* instrument

{ "piccolo-clarinet", { SoundId::Clarinet, SoundCategory::Winds, {}, {} } },
{ "soprano-clarinet", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Sopranino }, {} } },
{ "eb-clarinet", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Sopranino }, {} } },
{ "eb-clarinet", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Sopranino,
SoundSubCategory::In_E_flat }, {} } },
{ "d-clarinet", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Sopranino }, {} } },
{ "c-clarinet", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Sopranino }, {} } },
{ "bb-clarinet", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Sopranino }, {} } },
{ "bb-clarinet", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Soprano,
SoundSubCategory::In_B_flat }, {} } },
{ "clarinet", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Soprano }, {} } },
{ "a-clarinet", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Soprano }, {} } },
{ "g-clarinet", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Soprano }, {} } },
{ "basset-clarinet", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Soprano }, {} } },
{ "basset-horn", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Soprano }, {} } },
{ "alto-clarinet", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Alto }, {} } },
{ "bass-clarinet", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Bass }, {} } },
{ "bb-bass-clarinet", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Bass }, {} } },
{ "bb-bass-clarinet-bass-clef", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Bass }, {} } },
{ "bass-clarinet", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Bass,
SoundSubCategory::In_B_flat }, {} } },
{ "bb-bass-clarinet", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Bass,
SoundSubCategory::In_B_flat }, {} } },
{ "bb-bass-clarinet-bass-clef", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Bass,
SoundSubCategory::In_B_flat }, {} } },
{ "a-bass-clarinet", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Bass }, {} } },
{ "a-bass-clarinet-bass-clef", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Bass }, {} } },
{ "contra-alto-clarinet", { SoundId::Clarinet, SoundCategory::Winds, { SoundSubCategory::Contra_Alto }, {} } },
Expand Down Expand Up @@ -264,18 +269,23 @@ PlaybackSetupData WindsSetupDataResolver::doResolve(const Instrument* instrument

{ "brass", { SoundId::BrassGroup, SoundCategory::Winds, {}, {} } },

{ "c-horn-alto", { SoundId::Horn, SoundCategory::Winds, { SoundSubCategory::Alto }, {} } },
{ "bb-horn-alto", { SoundId::Horn, SoundCategory::Winds, { SoundSubCategory::Alto }, {} } },
{ "a-horn", { SoundId::Horn, SoundCategory::Winds, {}, {} } },
{ "ab-horn", { SoundId::Horn, SoundCategory::Winds, {}, {} } },
{ "g-horn", { SoundId::Horn, SoundCategory::Winds, {}, {} } },
{ "e-horn", { SoundId::Horn, SoundCategory::Winds, {}, {} } },
{ "eb-horn", { SoundId::Horn, SoundCategory::Winds, {}, {} } },
{ "d-horn", { SoundId::Horn, SoundCategory::Winds, {}, {} } },
{ "horn", { SoundId::Horn, SoundCategory::Winds, { SoundSubCategory::French }, {} } },
{ "c-horn", { SoundId::Horn, SoundCategory::Winds, {}, {} } },
{ "c-horn-bass", { SoundId::Horn, SoundCategory::Winds, { SoundSubCategory::Bass }, {} } },
{ "bb-horn-basso", { SoundId::Horn, SoundCategory::Winds, { SoundSubCategory::Bass }, {} } },
{ "c-horn-alto", { SoundId::Horn, SoundCategory::Winds, { SoundSubCategory::Alto,
SoundSubCategory::In_C }, {} } },
{ "bb-horn-alto", { SoundId::Horn, SoundCategory::Winds, { SoundSubCategory::Alto,
SoundSubCategory::In_B_flat }, {} } },
{ "a-horn", { SoundId::Horn, SoundCategory::Winds, { SoundSubCategory::In_A }, {} } },
{ "ab-horn", { SoundId::Horn, SoundCategory::Winds, { SoundSubCategory::In_A_flat }, {} } },
{ "g-horn", { SoundId::Horn, SoundCategory::Winds, { SoundSubCategory::In_G }, {} } },
{ "e-horn", { SoundId::Horn, SoundCategory::Winds, { SoundSubCategory::In_E }, {} } },
{ "eb-horn", { SoundId::Horn, SoundCategory::Winds, { SoundSubCategory::In_E_flat }, {} } },
{ "d-horn", { SoundId::Horn, SoundCategory::Winds, { SoundSubCategory::In_D }, {} } },
{ "horn", { SoundId::Horn, SoundCategory::Winds, { SoundSubCategory::French,
SoundSubCategory::In_F }, {} } },
{ "c-horn", { SoundId::Horn, SoundCategory::Winds, { SoundSubCategory::In_C }, {} } },
{ "c-horn-bass", { SoundId::Horn, SoundCategory::Winds, { SoundSubCategory::Bass,
SoundSubCategory::In_C }, {} } },
{ "bb-horn-basso", { SoundId::Horn, SoundCategory::Winds, { SoundSubCategory::Bass,
SoundSubCategory::In_B_flat }, {} } },
{ "vienna-horn", { SoundId::Horn, SoundCategory::Winds, { SoundSubCategory::Vienna }, {} } },

{ "bb-wagner-tuba", { SoundId::Tuba, SoundCategory::Winds, { SoundSubCategory::Wagner }, {} } },
Expand Down
47 changes: 37 additions & 10 deletions src/framework/audio/internal/synthesizers/fluidsynth/soundmapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,17 @@ static const auto& mappingByCategory(const mpe::SoundCategory category)

{ { mpe::SoundId::StringsGroup, { } }, { midi::Program(0, 48) } },
{ { mpe::SoundId::Contrabass, { mpe::SoundSubCategory::Orchestral } }, { midi::Program(0, 43) } },
{ { mpe::SoundId::ContrabassSection, { mpe::SoundSubCategory::Orchestral } }, { midi::Program(50, 48) } },
{ { mpe::SoundId::Contrabass, { mpe::SoundSubCategory::Orchestral,
mpe::SoundSubCategory::Section } }, { midi::Program(50, 48) } },
{ { mpe::SoundId::Violin, { mpe::SoundSubCategory::Orchestral } }, { midi::Program(0, 40) } },
{ { mpe::SoundId::ViolinSection, { mpe::SoundSubCategory::Orchestral } }, { midi::Program(20, 48) } },
{ { mpe::SoundId::Violin, { mpe::SoundSubCategory::Orchestral,
mpe::SoundSubCategory::Section } }, { midi::Program(20, 48) } },
{ { mpe::SoundId::Viola, { mpe::SoundSubCategory::Orchestral } }, { midi::Program(0, 41) } },
{ { mpe::SoundId::ViolaSection, { mpe::SoundSubCategory::Orchestral } }, { midi::Program(30, 48) } },
{ { mpe::SoundId::Viola, { mpe::SoundSubCategory::Orchestral,
mpe::SoundSubCategory::Section } }, { midi::Program(30, 48) } },
{ { mpe::SoundId::Violoncello, { mpe::SoundSubCategory::Orchestral } }, { midi::Program(0, 42) } },
{ { mpe::SoundId::VioloncelloSection, { mpe::SoundSubCategory::Orchestral } }, { midi::Program(40, 48) } },
{ { mpe::SoundId::Violoncello, { mpe::SoundSubCategory::Orchestral,
mpe::SoundSubCategory::Section } }, { midi::Program(40, 48) } },

{ { mpe::SoundId::Viol, { } }, { midi::Program(0, 40) } },
{ { mpe::SoundId::Viol, { mpe::SoundSubCategory::Alto } }, { midi::Program(0, 41) } },
Expand Down Expand Up @@ -377,9 +381,15 @@ static const auto& mappingByCategory(const mpe::SoundCategory category)

{ { mpe::SoundId::Clarinet, {} }, { midi::Program(0, 71) } },
{ { mpe::SoundId::Clarinet, { mpe::SoundSubCategory::Sopranino } }, { midi::Program(0, 71) } },
{ { mpe::SoundId::Clarinet, { mpe::SoundSubCategory::Sopranino,
mpe::SoundSubCategory::In_E_flat } }, { midi::Program(0, 71) } },
{ { mpe::SoundId::Clarinet, { mpe::SoundSubCategory::Soprano } }, { midi::Program(0, 71) } },
{ { mpe::SoundId::Clarinet, { mpe::SoundSubCategory::Soprano,
mpe::SoundSubCategory::In_B_flat } }, { midi::Program(0, 71) } },
{ { mpe::SoundId::Clarinet, { mpe::SoundSubCategory::Alto } }, { midi::Program(0, 71) } },
{ { mpe::SoundId::Clarinet, { mpe::SoundSubCategory::Bass } }, { midi::Program(0, 71) } },
{ { mpe::SoundId::Clarinet, { mpe::SoundSubCategory::Bass,
mpe::SoundSubCategory::In_B_flat } }, { midi::Program(0, 71) } },
{ { mpe::SoundId::Clarinet, { mpe::SoundSubCategory::Contra_Alto } }, { midi::Program(0, 71) } },
{ { mpe::SoundId::Clarinet, { mpe::SoundSubCategory::Contra_Bass } }, { midi::Program(0, 71) } },

Expand Down Expand Up @@ -449,9 +459,25 @@ static const auto& mappingByCategory(const mpe::SoundCategory category)
{ { mpe::SoundId::BrassGroup, {} }, { midi::Program(0, 61) } },

{ { mpe::SoundId::Horn, {} }, { midi::Program(0, 60), midi::Program(0, 59) } },
{ { mpe::SoundId::Horn, { mpe::SoundSubCategory::French } }, { midi::Program(0, 60), midi::Program(0, 59) } },
{ { mpe::SoundId::Horn, { mpe::SoundSubCategory::In_A } }, { midi::Program(0, 60), midi::Program(0, 59) } },
{ { mpe::SoundId::Horn, { mpe::SoundSubCategory::In_A_flat } }, { midi::Program(0, 60), midi::Program(0, 59) } },
{ { mpe::SoundId::Horn, { mpe::SoundSubCategory::In_G } }, { midi::Program(0, 60), midi::Program(0, 59) } },
{ { mpe::SoundId::Horn, { mpe::SoundSubCategory::In_E } }, { midi::Program(0, 60), midi::Program(0, 59) } },
{ { mpe::SoundId::Horn, { mpe::SoundSubCategory::In_E_flat } }, { midi::Program(0, 60), midi::Program(0, 59) } },
{ { mpe::SoundId::Horn, { mpe::SoundSubCategory::In_D } }, { midi::Program(0, 60), midi::Program(0, 59) } },
{ { mpe::SoundId::Horn, { mpe::SoundSubCategory::In_C } }, { midi::Program(0, 60), midi::Program(0, 59) } },
{ { mpe::SoundId::Horn, { mpe::SoundSubCategory::French,
mpe::SoundSubCategory::In_F } }, { midi::Program(0, 60), midi::Program(0, 59) } },
{ { mpe::SoundId::Horn, { mpe::SoundSubCategory::Alto } }, { midi::Program(0, 60), midi::Program(0, 59) } },
{ { mpe::SoundId::Horn, { mpe::SoundSubCategory::Alto,
mpe::SoundSubCategory::In_C } }, { midi::Program(0, 60), midi::Program(0, 59) } },
{ { mpe::SoundId::Horn, { mpe::SoundSubCategory::Alto,
mpe::SoundSubCategory::In_B_flat } }, { midi::Program(0, 60), midi::Program(0, 59) } },
{ { mpe::SoundId::Horn, { mpe::SoundSubCategory::Bass } }, { midi::Program(0, 60), midi::Program(0, 59) } },
{ { mpe::SoundId::Horn, { mpe::SoundSubCategory::Bass,
mpe::SoundSubCategory::In_B_flat } }, { midi::Program(0, 60), midi::Program(0, 59) } },
{ { mpe::SoundId::Horn, { mpe::SoundSubCategory::Bass,
mpe::SoundSubCategory::In_C } }, { midi::Program(0, 60), midi::Program(0, 59) } },
{ { mpe::SoundId::Horn, { mpe::SoundSubCategory::Vienna } }, { midi::Program(0, 60), midi::Program(0, 59) } },

{ { mpe::SoundId::Tuba, { mpe::SoundSubCategory::Wagner } }, { midi::Program(0, 56) } },
Expand Down Expand Up @@ -912,31 +938,31 @@ inline const ArticulationMapping& articulationSounds(const mpe::PlaybackSetupDat
}
}

if (setupData.id == mpe::SoundId::ViolinSection) {
if (setupData.id == mpe::SoundId::Violin && setupData.contains(mpe::SoundSubCategory::Section)) {
return VIOLIN_SECTION;
}

if (setupData.id == mpe::SoundId::Violin) {
return VIOLIN;
}

if (setupData.id == mpe::SoundId::ViolaSection) {
if (setupData.id == mpe::SoundId::Viola && setupData.contains(mpe::SoundSubCategory::Section)) {
return VIOLA_SECTION;
}

if (setupData.id == mpe::SoundId::Viola) {
return VIOLA;
}

if (setupData.id == mpe::SoundId::VioloncelloSection) {
if (setupData.id == mpe::SoundId::Violoncello && setupData.contains(mpe::SoundSubCategory::Section)) {
return VIOLONCELLO_SECTION;
}

if (setupData.id == mpe::SoundId::Violoncello) {
return VIOLONCELLO;
}

if (setupData.id == mpe::SoundId::ContrabassSection) {
if (setupData.id == mpe::SoundId::Contrabass && setupData.contains(mpe::SoundSubCategory::Section)) {
return CONTRABASS_SECTION;
}

Expand Down Expand Up @@ -1000,7 +1026,8 @@ struct ChannelMap {

midi::channel_t resolveChannelForEvent(const mpe::NoteEvent& event)
{
if (event.expressionCtx().articulations.contains(mpe::ArticulationType::Standard)) {
if (event.expressionCtx().articulations.contains(mpe::ArticulationType::Standard)
|| event.expressionCtx().articulations.empty()) {
if (m_standardPrograms.empty()) {
return 0;
}
Expand Down
45 changes: 32 additions & 13 deletions src/framework/mpe/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,17 @@ struct PlaybackSetupData

bool operator<(const PlaybackSetupData& other) const
{
if (id < other.id) {
if (other.id > id) {
return true;
} else if (other.id == id) {
if (other.category > category) {
return true;
} else if (other.category == category) {
return other.subCategorySet > subCategorySet;
}
}

if (category < other.category) {
return true;
}

return subCategorySet < other.subCategorySet;
return false;
}

bool isValid() const
Expand All @@ -314,10 +316,18 @@ struct PlaybackSetupData

String toString() const
{
String result = String(u"%1.%2.%3")
.arg(soundIdToString(id))
.arg(soundCategoryToString(category))
.arg(subCategorySet.toString());
String result;

if (!subCategorySet.empty()) {
result = String(u"%1.%2.%3")
.arg(soundCategoryToString(category))
.arg(soundIdToString(id))
.arg(subCategorySet.toString());
} else {
result = String(u"%1.%2")
.arg(soundCategoryToString(category))
.arg(soundIdToString(id));
}

return result;
}
Expand All @@ -330,10 +340,19 @@ struct PlaybackSetupData

StringList subStrList = str.split(u".");

if (subStrList.size() < 2) {
return PlaybackSetupData();
}

SoundSubCategories subCategories;
if (subStrList.size() == 3) {
subCategories = SoundSubCategories::fromString(subStrList.at(2));
}

PlaybackSetupData result = {
soundIdFromString(subStrList.at(0)),
soundCategoryFromString(subStrList.at(1)),
SoundSubCategories::fromString(subStrList.at(2)),
soundIdFromString(subStrList.at(1)),
soundCategoryFromString(subStrList.at(0)),
std::move(subCategories),
std::nullopt
};

Expand Down
Loading

0 comments on commit 85598a7

Please sign in to comment.