Skip to content

Commit

Permalink
Add support for "factorysample:" prefix
Browse files Browse the repository at this point in the history
Add support to upgrade files with `src` tags that are prefixed with "factorysample:".
  • Loading branch information
michaelgregorius committed May 1, 2024
1 parent 9ca9143 commit 20136cf
Showing 1 changed file with 52 additions and 34 deletions.
86 changes: 52 additions & 34 deletions src/core/DataFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1871,45 +1871,63 @@ void DataFile::upgrade_sampleAndHold()
}


// Change loops' filenames in <sampleclip>s
void DataFile::upgrade_loopsRename()
static QMap<QString, QString> buildReplacementMap()
{
auto createEntry = [](const QString& originalName, const QString& bpm, const QString& extension = "ogg")
{
const QString replacement = originalName + " - " + bpm + " BPM." + extension;
return std::pair{originalName + "." + extension, replacement};
static constexpr auto loopBPMs = std::array{
std::pair{"bassloops/briff01", "140"},
std::pair{"bassloops/briff01", "140"},
std::pair{"bassloops/rave_bass01", "180"},
std::pair{"bassloops/rave_bass02", "180"},
std::pair{"bassloops/tb303_01", "123"},
std::pair{"bassloops/techno_bass01", "140"},
std::pair{"bassloops/techno_bass02", "140"},
std::pair{"bassloops/techno_synth01", "140"},
std::pair{"bassloops/techno_synth02", "140"},
std::pair{"bassloops/techno_synth03", "130"},
std::pair{"bassloops/techno_synth04", "140"},
std::pair{"beats/909beat01", "122"},
std::pair{"beats/break01", "168"},
std::pair{"beats/break02", "141"},
std::pair{"beats/break03", "168"},
std::pair{"beats/electro_beat01", "120"},
std::pair{"beats/electro_beat02", "119"},
std::pair{"beats/house_loop01", "142"},
std::pair{"beats/jungle01", "168"},
std::pair{"beats/rave_hihat01", "180"},
std::pair{"beats/rave_hihat02", "180"},
std::pair{"beats/rave_kick01", "180"},
std::pair{"beats/rave_kick02", "180"},
std::pair{"beats/rave_snare01", "180"},
std::pair{"latin/latin_brass01", "140"},
std::pair{"latin/latin_guitar01", "126"},
std::pair{"latin/latin_guitar02", "140"},
std::pair{"latin/latin_guitar03", "120"},
};

static const QMap<QString, QString> namesToNamesWithBPMsMap {
{ createEntry("bassloops/briff01", "140") },
{ createEntry("bassloops/rave_bass01", "180") },
{ createEntry("bassloops/rave_bass02", "180") },
{ createEntry("bassloops/tb303_01", "123") },
{ createEntry("bassloops/techno_bass01", "140") },
{ createEntry("bassloops/techno_bass02", "140") },
{ createEntry("bassloops/techno_synth01", "140") },
{ createEntry("bassloops/techno_synth02", "140") },
{ createEntry("bassloops/techno_synth03", "130") },
{ createEntry("bassloops/techno_synth04", "140") },
{ createEntry("beats/909beat01", "122") },
{ createEntry("beats/break01", "168") },
{ createEntry("beats/break02", "141") },
{ createEntry("beats/break03", "168") },
{ createEntry("beats/electro_beat01", "120") },
{ createEntry("beats/electro_beat02", "119") },
{ createEntry("beats/house_loop01", "142") },
{ createEntry("beats/jungle01", "168") },
{ createEntry("beats/rave_hihat01", "180") },
{ createEntry("beats/rave_hihat02", "180") },
{ createEntry("beats/rave_kick01", "180") },
{ createEntry("beats/rave_kick02", "180") },
{ createEntry("beats/rave_snare01", "180") },
{ createEntry("latin/latin_brass01", "140") },
{ createEntry("latin/latin_guitar01", "126") },
{ createEntry("latin/latin_guitar02", "140") },
{ createEntry("latin/latin_guitar03", "120") }
QMap<QString, QString> namesToNamesWithBPMsMap;

auto insertEntry = [&namesToNamesWithBPMsMap](const QString& originalName, const QString& bpm, const QString& prefix = "", const QString& extension = "ogg")
{
const QString original = prefix + originalName + "." + extension;
const QString replacement = prefix + originalName + " - " + bpm + " BPM." + extension;

namesToNamesWithBPMsMap.insert(original, replacement);
};

for (const auto & loopBPM : loopBPMs)
{
insertEntry(loopBPM.first, loopBPM.second);
insertEntry(loopBPM.first, loopBPM.second, "factorysample:");
}

return namesToNamesWithBPMsMap;
}

// Change loops' filenames in <sampleclip>s
void DataFile::upgrade_loopsRename()
{
static const QMap<QString, QString> namesToNamesWithBPMsMap = buildReplacementMap();

// Replace loop sample names
for (const auto& [elem, srcAttrs] : ELEMENTS_WITH_RESOURCES)
{
Expand Down

0 comments on commit 20136cf

Please sign in to comment.