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

problem with display {sampling} value #11

Open
podly opened this issue Sep 3, 2014 · 7 comments
Open

problem with display {sampling} value #11

podly opened this issue Sep 3, 2014 · 7 comments

Comments

@podly
Copy link

podly commented Sep 3, 2014

It is impossible to display {sampling} value.
I think, there is a bug in display_fields.py

line 264:

super(BitRateField, self).__init__(width=width, **kwargs)

should be:

super(SamplingField, self).__init__(width=width, **kwargs)

It would be also nice to have possibility to display rest of 44100:16:2 - maybe {depth} and {channels} ?

rbarrois added a commit that referenced this issue Sep 7, 2014
@rbarrois
Copy link
Owner

rbarrois commented Sep 7, 2014

Hi!

Thanks for the report, I've fixed the call to super().

Could you give an example of what you'd like to display from {depth} and {channels}?

@podly
Copy link
Author

podly commented Sep 11, 2014

44100:16:2 - {bitrate} - 44100, {depth} - 16, {channels} - 2

@ranperry
Copy link

You mean:

44100:16:2 - {sampling rate} - 44100, {bit} - 16, {channels} - 2

On Thu, Sep 11, 2014 at 6:04 AM, podly notifications@github.com wrote:

44100:16:2 - {bitrate} - 44100, {depth} - 16, {channels} - 2


Reply to this email directly or view it on GitHub
#11 (comment).

@podly
Copy link
Author

podly commented Sep 11, 2014

yap, exactly.

@sprocket1597
Copy link

wasnt happy with sample rate being displayed as 44100.00 instead of 44.1 (also wanted 96 not 96.0), so changed to this:

def _format_sampling(self, sampling='44100:16:2'):
    rate = float(sampling.split(':')[0]) / 1000
    return ('%f' % rate).rstrip('0').rstrip('.')

to get depth and channels I added this code in display_fields.py.

@register_field
class DepthField(Field):
base_name = 'depth'
target_hooks = ['status']

def _format_sampling(self, sampling='44100:16:2'):
    rate = sampling.split(':')[1]
    return '%.0f' % float(rate)

def __init__(self, **kwargs):
    width = len(self._format_sampling())
    super(DepthField, self).__init__(width=width, **kwargs)

def __init__(self, **kwargs):
    width = len(self._format_sampling())
    super(DepthField, self).__init__(width=width, **kwargs)

def add_to_screen(self, screen, left, top):
    return screen.add_string_widget(self.name,
        self._format_sampling(), x=left, y=top)

def hook_changed(self, hook_name, widget, new_data):
    if hook_name == 'status':
        self.status_changed(widget, new_data)
    super(DepthField, self).hook_changed(hook_name, widget, new_data)

def status_changed(self, widget, new_status):
    txt = self._format_sampling(new_status.get('audio') or '0:0:0')
    logger.debug(u"Setting widget %r to %r", widget.ref, txt)
    widget.set_text(txt)

@register_field
 class ChannelField(Field):
base_name = 'channel'
target_hooks = ['status']

def _format_sampling(self, sampling='44100:16:2'):
    rate = sampling.split(':')[2]
    return '%.0f' % float(rate)

def __init__(self, **kwargs):
    width = len(self._format_sampling())
    super(ChannelField, self).__init__(width=width, **kwargs)

def __init__(self, **kwargs):
    width = len(self._format_sampling())
    super(ChannelField, self).__init__(width=width, **kwargs)

def add_to_screen(self, screen, left, top):
    return screen.add_string_widget(self.name,
        self._format_sampling(), x=left, y=top)

def hook_changed(self, hook_name, widget, new_data):
    if hook_name == 'status':
        self.status_changed(widget, new_data)
    super(ChannelField, self).hook_changed(hook_name, widget, new_data)

def status_changed(self, widget, new_status):
    txt = self._format_sampling(new_status.get('audio') or '0:0:0')
    logger.debug(u"Setting widget %r to %r", widget.ref, txt)
    widget.set_text(txt)

@zillion168
Copy link

Hi, I am new come to here.^0^
As above comment, I had add the code to the display_fields.py and modify the mpdlcd.conf as follow, but the 2 fields is not works, is other need to modify to show it?

pattern2 = {depth}{channel} {elapsed}
{song format="%(title)s",speed=2} {state}

@ghost
Copy link

ghost commented Sep 19, 2018

Many thanks to all concerned for the opportunity to display the details of the track playing - just one small problem.
Having made the changes as per sprocket 1597 everything works well until crashing when playing a DSD file. - I think there may be other files that cause problems but I have yet to track them down.

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

No branches or pull requests

5 participants