problem with display {sampling} value
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} ?
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}?
44100:16:2 - {bitrate} - 44100, {depth} - 16, {channels} - 2
You mean:
44100:16:2 - {sampling rate} - 44100, {bit} - 16, {channels} - 2
On Thu, Sep 11, 2014 at 6:04 AM, podly [email protected] wrote:
44100:16:2 - {bitrate} - 44100, {depth} - 16, {channels} - 2
— Reply to this email directly or view it on GitHub https://github.com/rbarrois/mpdlcd/issues/11#issuecomment-55244053.
yap, exactly.
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)
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}
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.