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
Update to MP3, FLAC, Ogg and WMA Formats to use BPM tags. #708
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice addition, thanks!
But could you please simplify the conversion to an integer? There's int()
in Perl to do this. Did I miss something?
Slim/Formats/FLAC.pm
Outdated
if (defined $tags->{BPM}) { | ||
# Make the BPM an integer by dropping digits after decimal point. | ||
if ($tags->{BPM} =~ m|^\d+\.\d+$|) { | ||
($tags->{BPM} = $tags->{BPM}) =~ s/^(\d+)(\.\d+)$/$1/; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this something simpler like:
$tags->{BPM} = int($tags->{BPM}) if defined $tags->{BPM};
Slim/Formats/MP3.pm
Outdated
if (defined $tags->{BPM}) { | ||
# Make the BPM an integer by dropping digits after decimal point. | ||
if ($tags->{BPM} =~ m|^\d+\.\d+$|) { | ||
($tags->{BPM} = $tags->{BPM}) =~ s/^(\d+)(\.\d+)$/$1/; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int()
Slim/Formats/Ogg.pm
Outdated
if (defined $tags->{BPM}) { | ||
# Make the BPM an integer by dropping digits after decimal point. | ||
if ($tags->{BPM} =~ m|^\d+\.\d+$|) { | ||
($tags->{BPM} = $tags->{BPM}) =~ s/^(\d+)(\.\d+)$/$1/; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int()
Slim/Formats/WMA.pm
Outdated
if (defined $tags->{BPM}) { | ||
# Make the BPM an integer by dropping digits after decimal point. | ||
if ($tags->{BPM} =~ m|^\d+\.\d+$|) { | ||
($tags->{BPM} = $tags->{BPM}) =~ s/^(\d+)(\.\d+)$/$1/; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int()
Could you also include APE in your change? APE also uses the BPM tag (see https://picard-docs.musicbrainz.org/v2.6/en/appendices/tag_mapping.html#bpm-4). I was also wondering why BPM should be a whole number? Is there a use case for integer BPMs instead of the decimal number? |
I don't know for the initial reason. But the database schema defines it as smallint. A schema change would require a full wipe & rescan on an update. I usually try to avoid this without very good reason. Floating point BPM isn't good enough in my opinion... |
That makes it clear, thanks |
Thank you for the comments and suggestions. We've updated the PR to include APE file format and changed the integer conversion as suggested. |
Thanks! |
Changes to 4 files in Slim/Formats to enable slimserver to use Beat-Per-Minute (BPM) tempo tag information in MP3, FLAC, Ogg and WMA files. The Linux package BPM-TOOLS can be used to tag files with BPM information and this PR enables slimserver to take advantage of this.