Open renekliment opened 7 years ago
@enclarify Could you please have a look at this? You're the SoX guru and also the general volume design might need a change and I believe you are better at it in this case. Thank you.
@renekliment I see the access of the volume attribute that's causing the issue. The simple fix is to just maintain a volume attribute with the with the originally requested % volume that can be queried in the current way. I will also do some more testing of raising and lowering the volume with the alexa commands to ensure the volume management is intuitive. You are correct that currenctly the volume is scaled between -30dB and +30dB where a value of 100% equals 0dB
Here's how I fixed this in my sox setup with everything running on Ubuntu 16.04 LTS. In soxhandler.py
in __init__
:
self.volume = None
in on_setup(self)
, change
if self.__config['sound']['default_volume']:
self.on_set_volume(self.__config['sound']['default_volume'])
to
if self.__config['sound']['default_volume']:
self.volume = self.__config['sound']['default_volume']
self.on_set_volume(self.__config['sound']['default_volume'])
and then change on_set_volume(self,volume)
to
def on_set_volume(self, volume):
self.volume_gain = self.__calculate_volume_gain(volume)
self.volume = volume
I was also having issues playing the only radio streams I listen to - BBC. There's a warning about sox and streams in the wiki but as they're all available (in my case) as mp3 streams, I can change the on_play
method has the sox_cmd line of sox_cmd = ['sox', '-t', 'mp3', '-q', audio_file]
Hope this helps someone.
Couple of things:
When I tell Alexa to volume up I get
because the attribute name is different.
Then
I'm not sure I understand it correctly ... if you give it max = 100 (%), it returns 0. So you go from
- MAX_VOLUME_GAIN
to0
on a linear scale?