Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BPM tags to built-in beat loops (#5439) #6747

Merged
merged 25 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
75f90b2
Added BPM tags to built-in beat loops (#5439)
Jun 26, 2023
ce50c97
Updated file naming
Jun 26, 2023
0a5a64a
Added BPM tags to bassloops
Jun 26, 2023
4787ab5
Moved BPM to its own tag
Jun 26, 2023
e93d8b1
Added BPM tags to latin loops
Jun 26, 2023
e89aa16
Merge branch 'LMMS:master' into bpm-tags
mirk0dex Sep 17, 2023
d739f6f
Created upgrade routine for loop new filenames with BPM
Sep 17, 2023
465c46d
Restored original DataFile.cpp, added loop filename update function
Sep 17, 2023
de33282
Declared update_loopsRename() in DataFile.h; added it to UPGRADE_METHODS
Sep 17, 2023
92e7b6d
Moved upgrade_loopsRename() to after upgrade_sampleAndHold()
Sep 17, 2023
89a0026
Merge branch 'LMMS:master' into bpm-tags
mirk0dex Sep 19, 2023
89a3b0f
Fixed previous issues with upgrade_loopsRename()
Sep 19, 2023
c2d64b4
Added support for audiofileprocessor in upgrade_loopsRename()
Sep 21, 2023
051b1de
Moved upgrade_loopsRename() to below upgrade_sampleAndHold()
Sep 22, 2023
b3aab05
Explicitly made elem and srcAttrs constant
mirk0dex Sep 22, 2023
72ff308
Removed useless variables
Sep 22, 2023
e9b77db
Merge branch 'master' into bpm-tags
mirk0dex Nov 1, 2023
b6eb8a2
Replaced std::vector with std::array
mirk0dex Nov 1, 2023
670dfea
Made check less loose
mirk0dex Nov 1, 2023
983cafc
Replaced normal loop with range-based
mirk0dex Nov 1, 2023
86d6f95
Merge branch 'LMMS:master' into bpm-tags
mirk0dex Nov 1, 2023
846f072
Made loopBPMs static
mirk0dex Nov 1, 2023
a3cad7c
Moved upgrade_loopsRename() before upgrade_midiCCIndexing()
mirk0dex Nov 1, 2023
48f0b88
Moved include_loopsRename() down
mirk0dex Nov 13, 2023
19cb17b
Reduced nesting; removed pointless casting
mirk0dex Nov 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 2 additions & 1 deletion include/DataFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ class LMMS_EXPORT DataFile : public QDomDocument
void upgrade_mixerRename();
void upgrade_bbTcoRename();
void upgrade_sampleAndHold();
void upgrade_midiCCIndexing();
void upgrade_midiCCIndexing();
zonkmachine marked this conversation as resolved.
Show resolved Hide resolved
void upgrade_loopsRename();

// List of all upgrade methods
static const std::vector<UpgradeMethod> UPGRADE_METHODS;
Expand Down
78 changes: 75 additions & 3 deletions src/core/DataFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ const std::vector<DataFile::UpgradeMethod> DataFile::UPGRADE_METHODS = {
&DataFile::upgrade_automationNodes , &DataFile::upgrade_extendedNoteRange,
&DataFile::upgrade_defaultTripleOscillatorHQ,
&DataFile::upgrade_mixerRename , &DataFile::upgrade_bbTcoRename,
&DataFile::upgrade_sampleAndHold , &DataFile::upgrade_midiCCIndexing
&DataFile::upgrade_sampleAndHold , &DataFile::upgrade_midiCCIndexing,
&DataFile::upgrade_loopsRename
};

// Vector of all versions that have upgrade routines.
Expand Down Expand Up @@ -1804,7 +1805,79 @@ void DataFile::upgrade_sampleAndHold()
// Correct old random wave LFO speeds
if (e.attribute("wave").toInt() == 6)
{
e.setAttribute("speed",0.01f);
e.setAttribute("speed", 0.01f);
}
}
}


// Change loops' filenames in <sampleclip>s
void DataFile::upgrade_loopsRename()
{
static constexpr auto loopBPMs = std::array{
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"},
};

const QString prefix = "factorysample:",
extension = ".ogg";

// Replace loop sample names
for (const auto& [elem, srcAttrs] : ELEMENTS_WITH_RESOURCES)
{
auto elements = elementsByTagName(elem);

for (const auto& srcAttr : srcAttrs)
{
for (int i = 0; i < elements.length(); ++i)
{
auto item = elements.item(i).toElement();

if (item.isNull()) { continue; }
if (item.hasAttribute(srcAttr))
sakertooth marked this conversation as resolved.
Show resolved Hide resolved
{
for (const auto& cur : loopBPMs)
{
auto x = (QString) cur.first, // loop name
y = (QString) cur.second, // BPM
sakertooth marked this conversation as resolved.
Show resolved Hide resolved
srcVal = item.attribute(srcAttr),
pattern = prefix + x + extension;

if (srcVal == pattern)
{
// Add " - X BPM" to filename
item.setAttribute(srcAttr,
prefix + x + " - " + y + " BPM" +
extension);
}
}
}
}
}
}
}
Expand Down Expand Up @@ -1981,5 +2054,4 @@ unsigned int DataFile::legacyFileVersion()
return std::distance( UPGRADE_VERSIONS.begin(), firstRequiredUpgrade );
}


} // namespace lmms
Loading