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

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

merged 25 commits into from
Nov 17, 2023

Conversation

mirk0dex
Copy link
Contributor

@mirk0dex mirk0dex commented Jun 26, 2023

  • Added floating-point vorbis BPM tags to files in lmms/data/samples/beats
  • Added rounded BPM to filenames, surrounded by square brackets and separated from the rest of the filename by an underscore, as requested by @ttepatti.

To achieve this, I used the bpm-tools utils and verified that the values were correct using LMMS itself. When the tempos were not correct, I fired up the DAW and started looking, manually, for one fitting the loop. When I found one, I once again used bpm-tools (but this time with a range that suited the approximate tempo) and detected the precise value.

I then proceed to add the vorbis tags, and rename the files.

All tempos should be accurate. Only loops I'd double-check are the breaks: finding the right BPM wasn't easy there.

@mirk0dex
Copy link
Contributor Author

I found out that LMMS has an "assets" repo. Gonna use that.

@mirk0dex mirk0dex reopened this Jun 26, 2023
@mirk0dex
Copy link
Contributor Author

mirk0dex commented Jun 26, 2023

Not sure whether it's OK for me to leave this here or not. I can't find the beat loops in https://github.com/LMMS/assets, so I'm keeping the PR open.

@zonkmachine
Copy link
Member

Hi, thanks for looking into this!

Now that the names are changed we need some form of upgrade routine so old projects that use the samples will find them. How is your coding? :)

@mirk0dex
Copy link
Contributor Author

mirk0dex commented Sep 16, 2023 via email

@zonkmachine
Copy link
Member

zonkmachine commented Sep 16, 2023

OK. When we need to upgrade a project file to work with a new feature, name changes quite commonly, the job is done here: https://github.com/LMMS/lmms/blob/master/src/core/DataFile.cpp

Here is a recent PR that addressed an issue with elements that had been renamed but the upgrade didn't work:
#6851

Here is a minimal demo project with just a loop that needs to be upgraded to the new name:
beatupgrade.mmp.txt
<sampleclip muted="0" off="0" src="factorysample:beats/electro_beat01.ogg" pos="0" sample_rate="44100" len="384"/>

Have fun!

@mirk0dex
Copy link
Contributor Author

mirk0dex commented Sep 16, 2023 via email

@mirk0dex
Copy link
Contributor Author

mirk0dex commented Sep 17, 2023

I created an upgrade procedure. It simply loops through all elements and if they contain one of the changed strings, it appends " - X BPM" to the sample names.

Unfortunately, it looks like Emacs drastically changed the file's indentation and code arrangement, for some reason. If you want me to, I can restore the original version and use vim or something to copy and paste my function in it.

Also, I haven't tested any of the code yet, because I'm currently using Void GNU/Linux, and building LMMS here is a pain in the neck.

Edit: BTW, here's the updated file: https://github.com/mirk0dex/lmms/blob/master/src/core/DataFile.cpp. The function's name is upgrade_loopsRename().

@zonkmachine
Copy link
Member

If you want me to, I can restore the original version and use vim or something to copy and paste my function in it.

Want. The problem is that it's one commit and it's not easy to find your intended changes among all the format changes. The format changes, at a glance, do look like they follow the coding standard.

@mirk0dex
Copy link
Contributor Author

If you want me to, I can restore the original version and use vim or something to copy and paste my function in it.

Done.

I pasted it at the end of the file. I also committed it to the correct branch this time.

@zonkmachine
Copy link
Member

If you want me to, I can restore the original version and use vim or something to copy and paste my function in it.

Done.

I pasted it at the end of the file. I also committed it to the correct branch this time.

Did this actually compile? You can't just add a function to DataFile.cpp without declaring it in DataFile.h
Search src/core/Datafile.cpp and include/DataFile.h for occurences of upgrade_sampleAndHold(). Try and *mirror what's done and stick your stuff after.

src/core/DataFile.cpp Outdated Show resolved Hide resolved
@zonkmachine
Copy link
Member

@mirk0dex Does this actually compile for you?

/builds/lmms/src/core/DataFile.cpp:1966:39: error: template argument 1 is invalid
 1966 |         std::vector<std::pair<string, string>> loopBPMs{

@mirk0dex
Copy link
Contributor Author

@mirk0dex Does this actually compile for you?

/builds/lmms/src/core/DataFile.cpp:1966:39: error: template argument 1 is invalid
 1966 |         std::vector<std::pair<string, string>> loopBPMs{

I haven't tried compiling anything, yet. Is there any way I can just compile that file, or check for errors without having to build everything?

@mirk0dex
Copy link
Contributor Author

Maybe using std::string instead of just string will do the trick?

@zonkmachine
Copy link
Member

@mirk0dex Does this actually compile for you?

/builds/lmms/src/core/DataFile.cpp:1966:39: error: template argument 1 is invalid
 1966 |         std::vector<std::pair<string, string>> loopBPMs{

I haven't tried compiling anything, yet. Is there any way I can just compile that file, or check for errors without having to build everything?

No. You should make sure that things build before committing it to a project or be sure to mention that you haven't tested it yet.

@mirk0dex
Copy link
Contributor Author

@mirk0dex Does this actually compile for you?

/builds/lmms/src/core/DataFile.cpp:1966:39: error: template argument 1 is invalid
 1966 |         std::vector<std::pair<string, string>> loopBPMs{

I haven't tried compiling anything, yet. Is there any way I can just compile that file, or check for errors without having to build everything?

No. You should make sure that things build before committing it to a project or be sure to mention that you haven't tested it yet.

I did say it in a previous message. Apologies for the inconvenience. Anyways, tomorrow I will have my Arch system with me, so I will be able to compile everything with ease.

@zonkmachine
Copy link
Member

Maybe using std::string instead of just string will do the trick?

QString is what the rest of the file is using. Stick to that. And then compile it. You actually need to do that. If you have problem compiling it you need to bring it up at our Discord site. This is not the right place.

@zonkmachine
Copy link
Member

I tested the function. It now works as it should.

<sampleclip off="0" sample_rate="44100" len="384" muted="0" src="factorysample:beats/electro_beat01 - 120 BPM.ogg" pos="0"/>

Right. This now upgrades. Loops can be imported into our builtin sampler, the audio file processor. This doesn't seem to upgrade.

          <instrument name="audiofileprocessor">
            <audiofileprocessor eframe="1" lframe="0" reversed="0" amp="100" stutter="0" interp="1" src="factorysample:beats/909beat01.ogg" looped="0" sframe="0">
              <key/>
            </audiofileprocessor>
          </instrument>

New project to test. I forgot to mention that we add .txt to the end of project files instead of zipping as github doesn't recognize .mmp. Just drop the suffix and go...
beatupgrade2.mmp.txt

Copy link
Member

@zonkmachine zonkmachine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some remarks on coding style but this looks good and tests out fine. The Vorbis tags look fine although I don't know the usefulness of bpm measured to 3 decimals precision. The upgrade works. I've run out of things to test now. Approved.

{
// Add " - X BPM" to filename
srcVal.replace(toReplace,
toReplace + BPMPREF + currentPair.second + BPMSUFF);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lines above can be written together. We go to 120 characters for a line.

include/DataFile.h Outdated Show resolved Hide resolved
src/core/DataFile.cpp Outdated Show resolved Hide resolved
src/core/DataFile.cpp Outdated Show resolved Hide resolved
src/core/DataFile.cpp Outdated Show resolved Hide resolved
src/core/DataFile.cpp Outdated Show resolved Hide resolved
src/core/DataFile.cpp Outdated Show resolved Hide resolved
@mirk0dex
Copy link
Contributor Author

mirk0dex commented Sep 22, 2023 via email

Copy link
Member

@zonkmachine zonkmachine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully the last review.

include/DataFile.h Show resolved Hide resolved
@mirk0dex mirk0dex changed the title Added BPM tags to built-in beat loops (#5439) Add BPM tags to built-in beat loops (#5439) Nov 14, 2023
src/core/DataFile.cpp Outdated Show resolved Hide resolved
src/core/DataFile.cpp Outdated Show resolved Hide resolved
@zonkmachine zonkmachine merged commit a64bbc7 into LMMS:master Nov 17, 2023
9 checks passed
@zonkmachine
Copy link
Member

No. You should make sure that things build before committing it to a project or be sure to mention that you haven't tested it yet.

I did say it in a previous message. Apologies for the inconvenience. Anyways, tomorrow I will have my Arch system with me, so I will be able to compile everything with ease.

For the record, yes you did. I came through as a bit more salty than intended. Sorry!

Thanks for contributing to lmms and for sticking with us through the review process.

@mirk0dex
Copy link
Contributor Author

No worries, I understand!

It was fun to contribute to the project, thanks to you all for this amazing piece of software.

michaelgregorius added a commit to michaelgregorius/lmms that referenced this pull request May 1, 2024
Fix the upgrade routine that was introduced with pull request LMMS#6747 which added the BPM value to some file names.

This also simplifies the implementation by using a map.
michaelgregorius added a commit that referenced this pull request May 1, 2024
Fix the upgrade routine that was introduced with pull request #6747 which added the BPM value to some file names.

This also simplifies the implementation by using a map.

Note: this also removes the code about the prefix `factorysample:`. If it is used in some files these entries will also have to be added to the map.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add BPM tags to built-in .ogg samples
4 participants