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

added codec and bitrate to radio stations in browse #2094

Merged
merged 3 commits into from Apr 9, 2021

Conversation

crieke
Copy link
Collaborator

@crieke crieke commented Mar 16, 2021

When the info is available, codec and bitrates are displayed in radio browser.
This is not always accurate and propagates the info from the used radio directories.

bitrate display is currently utilzing the artist field.
As a dirty fix, album info also contains a single space, to move the bitrate info further to the right side.

var category = {
service: 'webradio',
type: 'webradio',
title: name,
artist: '',
artist: self.formatCodecString(streamcodec) + ' (' + bitrate + ' kbps)',
Copy link
Collaborator

@ashthespy ashthespy Mar 23, 2021

Choose a reason for hiding this comment

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

You could add a bitrate field and fix the logic over at statemachine.js so it actually gets used?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was also a bit surprised to see bitrates going into the 'artist' field. I see it's just continuing the current (ab)use of the field, so fair enough if this is deemed urgent I guess. The statemachine.js code uses different terms btw - 'samplerate' and 'bitdepth'. It would be nice to have them consistent but that's for a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I looked into this a bit more. Mostly the code uses 'samplerate' and 'bitdepth' (one assumes bitdepth=samplerate*bitdepth, or maybe one has to multiply by the number of channels as well?).
If a stream only supplies a bitrate and not the other two, then presumably it's not possible to figure those values out?
Unless there's a convention I'm not aware of that allows assuming a bitdepth or samplerate...

Below are some brief notes from a bit of grep & less

app/plugins/miscellanea/wizard/wizard_steps/conf/spotify.json                   
  spotify uses the bitrate term                                                 
                                                                                
app/plugins/music_service/mpd/index.js                                          
                                                                                
  ControllerMpd.prototype.parseTrackInfo = function (objTrackInfo)              
    returns mpd track info                                                      
    it uses the bitrate term if the term exists in the argument object          
    not necessarily only in the streaming case                                  
    It doesn't check for samplerate or bitdepth, or set them.                   
                                                                                
  ControllerMpd.prototype.parseState = function (objState)                      
    returns a json associative array with a bitrate field,                      
      if the argument object has a bitrate field it assumes Kbps.               
    It doesn't check for samplerate or bitdepth, or set them.                   
                                                                                
app/plugins/user_interface/mpdemulation/helper.js                               
  sets a dummy bitrate of 0                                                     
  does this weird thing where it makes a string like so                         
  status.audio = message.samplerate + ':' + message.bitdepth + ':' + message.      channels
  the comment says the default is 44000:24:2                                    
                                                                                
app/statemachine.js                                                             
  CoreStateMachine.prototype.getState = function ()                             
    it looks at self to see if it's in 'consume' state                          
      if so and the current object is a webradio                                
        it sets samplerate and bitdepth fields to ''                            
                                                                                
  CoreStateMachine.prototype.syncState = function (stateService, sService)      
    does similar things, but only in play mode?                                 
                                                                                
  we have objects that have all three fields                                    
  strangely getState does not always return an object that has bitrate,         
  but it seems to always return samplerate & bitdepth                           
                                                                                
                                                                                
app/plugins/audio_interface/alsa_controller/UIConfig.json                       
  samplerate not used as a word, grep picked it up as a substring of               target_samplerate etc
                                                                                
app/plugins/audio_interface/alsa_controller/index.js                            
  ditto                                                                         
                                                                                
app/plugins/music_service/airplay_emulation/index.js                            
  a few functions that return an object with samplerate & bitdepth but not bitrate
                                                                                
app/playqueue.js                                                                
  the objects here always get a samplerate & bitdepth, never a bitrate          

Copy link
Collaborator

Choose a reason for hiding this comment

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

Apologies if this is all obvious, but I think the confusion about bitrate is that it is defined by the file and encoding, not the audio output.

  • Sample Rate: The number of audio samples per second.
  • Bit depth: The number of bits used to encode each sample in the output audio stream - unless you're playing raw/pcm audio this will be bigger than the number of bits per sample in the input audio stream.
  • Channels: The number of channels in the audio.
  • Bit Rate: This is the data rate for the incoming audio stream. This may be something like 128kbps for MP3 web radio, or 700+kbps for a CD quality FLAC file. This gives an idea of the quality of the incoming audio. The output audio bit rate would be much higher, typically 1.4Mbps for 44100:16:2 audio, but this isn't usually an interesting number

I think it's therefore necessary to provide sample rate, bit depth, channel count, and bit rate. They all mean different things and may be helpful to the user. Normally you should be able to query the stream for all four things. The bit rate will likely vary throughout the input stream, but the sample rate, output bit depth and channel count should remain constant.

@volumio
Copy link
Owner

volumio commented Apr 9, 2021

Merging. As Tim pointed rightfully out, this is different info.
It can be easily later refactored when we add the relevant info into the UI

@volumio volumio merged commit 067290a into master Apr 9, 2021
@volumio volumio deleted the feature/webradio_Browse_AddBitrate branch April 9, 2021 10:40
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.

None yet

5 participants