Skip to content

Only display 'VBR' / 'CBR' qualifier for lossy formats. - #1646

Merged
michaelherger merged 2 commits into
LMS-Community:public/9.2from
SamInPgh:public/9.2
Aug 31, 2026
Merged

Only display 'VBR' / 'CBR' qualifier for lossy formats.#1646
michaelherger merged 2 commits into
LMS-Community:public/9.2from
SamInPgh:public/9.2

Conversation

@SamInPgh

Copy link
Copy Markdown
Contributor

When displaying bitrates, no distinction is made as to whether the 'CBR' or 'VBR' qualifier is appropriate for the format type and it is often confusingly shown for lossless formats such as FLAC.

When displaying bitrates, no distinction is made as to whether the 'CBR' or 'VBR' qualifier is appropriate for the format type and it is often confusingly displayed for lossless formats such as FLAC.

Signed-off-by: Sam Y <syahres@gmail.com>
@pssc

pssc commented Aug 27, 2026 via email

Copy link
Copy Markdown

Comment thread Slim/Schema/RemoteTrack.pm Outdated
Comment on lines +481 to +485
my $mode = '';
if (Slim::Music::Info::isLossy($format) ) { # only relevant for lossy formats
$mode = defined $vbrScale ? ' VBR' : ' CBR';
}
return int ($bitrate/1000) . Slim::Utils::Strings::string('KBPS') . $mode;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not use Slim::Schema::Track->buildPrettyBitRate()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There's nothing preventing it. As in the change to Track.pm however, I was trying to minimize changes to the existing logic which, in this case, could certainly be made less redundant by doing what you suggest. I'll look into it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. Thanks for the suggestion.

Comment thread Slim/Schema/Track.pm Outdated
my ( $self, $bitrate, $vbrScale ) = @_;

my $mode = defined $vbrScale ? 'VBR' : 'CBR';
my ( $self, $bitrate, $vbrScale, $format ) = @_;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We're using the convention of using $self when dealing with an object instance, or $class when this is just a class method. As we're not accessing that variable itself, it should be $class for a static method.

Yes, sometimes we have $selfOrClass. But we don't need this here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm just adding an additional argument to the function while trying to minimize any changes to existing code, as per the old American saying "If it ain't broke, don't fix it." So you're suggesting that I should change the pre-existing $self argument to $class in the function definition?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@pssc

pssc commented Aug 27, 2026 via email

Copy link
Copy Markdown

@SamInPgh

Copy link
Copy Markdown
Contributor Author

@pssc

Hi,

What about this usecase?

WAV lossless CBR
FLAC lohssless VBR.

Phill.

WAV is always CBR and FLAC is always VBR, so the qualifier is redundant and meaningless.

@SamInPgh

Copy link
Copy Markdown
Contributor Author

@pssc

That will cause regressions for anything that was parsing the bitrate value
into a numeric, to say reconfigure an output path or engiuage low bitrate
enhavment features , this might anyway depending on how the values were
parsed with removing the CBR/VBR...

If you know of any such potential regression problems, please point them out so I can try to address them. My research and testing thus far has not revealed any. Keep in mind that this PR is for LMS 9.2.0, which is, by definition, a beta release.

Use buildPrettyBitRate() method in both Track.pm and RemoteTrack.pm to avoid logic duplication. Also change $self to $class in the signature as it's a static method.

Signed-off-by: Sam Y <syahres@gmail.com>
@michaelherger

Copy link
Copy Markdown
Member

I'm sorry for asking the most basic question again: shouldn't it be in the UIs responsibility to show things or not? The server shall return whatever it knows about the stream, but let the front end decide whether it's relevant to their users or not?

@SamInPgh

Copy link
Copy Markdown
Contributor Author

I'm sorry for asking the most basic question again: shouldn't it be in the UIs responsibility to show things or not? The server shall return whatever it knows about the stream, but let the front end decide whether it's relevant to their users or not?

Up to a point, "yes". The goal being pursued is to have a higher degree of consistency among the UI's in how individual attributes are displayed --- not which of them are displayed, which is admittedly up to the UI. In this case, we are trying to standardize how the "bitrate" attribute is displayed, and this PR is only the first step in that direction. For starters, all "WAV" files are inherently always CBR, with a constant bitrate value equal to "samplerate * samplesize * channels". On the other hand, "FLAC" files are inherently always VBR. So it is redundant and confusing to display the "CBR/VBR" qualifier for these formats, not to mention the screen real estate being wasted by doing so. Even worse, before these changes, LMS (buildPrettyBitRate) would often show a FLAC file as "CBR" because it wasn't given access to the file format when making its decision. I don't know if you have stopped following the Material Skin forum thread but the discussion on how to display both the source and post-transcoding technical info brought this "CBR/VBR" issue to the forefront recently when this last anomaly was pointed out. You might want to start reading the the thread at this point if you're interested. See the quoted screenshot on the first post for an example of a FLAC file incorrectly showing a CBR bitrate.

I should also point out that this PR is just the beginning of getting the bitrate attribute to be displayed consistently and accurately. There is a little more to be done in standardizing the format stored in the $song object that I will be pursuing after this. After that, the bitrate format returned in the metadata by the Radio Paradise plugin will be addressed. Currently, for interactive FLAC files, it looks something like "850k VBR FLAC" To be conistent with LMS going forward, it should be changed to just "850kbps", as both "VBR" and "FLAC" are redundant here, albeit for different reasons. I know that RP is "your baby" so I will tread lightly and consult with you on those changes.

In closing, I ask that you again trust me on this. I do not use AI at all ("not that there's anything wrong with that", to quote Jerry Seinfeld - do they broadcast "Seinfeld" in Switzerland?), and I will take full responsibility for fixing any problems caused by my changes (unlike AI). ;-) Now that Craig has made all the changes necessary to support displaying both the pre- and post-transcoding technical info (as has the developer of the "Echo Classic" skin), I am eager to also make this change available to the LMS 9.2.0 users, who are serving as de-facto beta testers for all of this and whose feedback has been very productive and helpful thus far. Thanks.

@michaelherger

Copy link
Copy Markdown
Member

Ok, got it. I've started kind of a poll (https://forums.lyrion.org/forum/user-forums/3rd-party-software/106269-announce-material-skin?p=1833088#post1833088). Let's see.

Technically this PR is fine. And I can certainly live with whatever that string is...

(now I have to go and fix/remove that string in RP - awaiting the result for consistency)

@michaelherger

Copy link
Copy Markdown
Member

Radio Paradise preparation: michaelherger/RadioParadise@595afcb - does make sense?

@SamInPgh

Copy link
Copy Markdown
Contributor Author

Radio Paradise preparation: michaelherger/RadioParadise@595afcb - does make sense?

Using buildPrettyBitRate() there is not going to work, as it will be dependent on changes made in LMS 9.2.0, specifically the addition of the isLossy() function. I would just hardcode the string there as '####kbps' for FLAC, although I know that's not ideal.

I apologize if my middle-of-the-night response to your forum post was out of line. I was half asleep when I wrote it and didn't fully understand that you were conducting an informal poll there. That's what happens when you're old and make the mistake of looking at your phone during a nighttime pit stop. 🥴

@michaelherger

Copy link
Copy Markdown
Member

buildPrettyBitRate() has been around for 16 years. It's not perfect (yet), but better than dealing with that stuff in the plugin myself.

And as the people has spoken I'm going to merge this PR - which should improve the display "for free". Oh, but only if I tell it the format...

Thanks!

@michaelherger
michaelherger merged commit 5770023 into LMS-Community:public/9.2 Aug 31, 2026
1 check passed
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.

3 participants