I'm trying to add on volume to a current set volume, in this case we will say it's 80%. Using the alsaaudio module in Python, there is a function called getvolume
#declare alsaaudio
am = alsaaudio.Mixer()
#get current volume
current_volume = am.getvolume()
getvolume
or current_volume
in my case dumps a list such as [80L]
for 80% volume. I am trying to add volume on to the current one like this,
#adds 5 on to the current_volume
increase = current_volume + 5
am.setvolume(increase)
But my problem is, since it's a list I cannot strip or replace characters and since I am relatively new to Python, have no clue on how to strip the characters in the list and then add 5 on to that integer after converting.
I created a run-able example here:
import alsaaudio
am = alsaaudio.Mixer()
current_volume = am.getvolume()
print(repr(current_volume), type(current_volume), type(current_volume[0]))
It prints:
('[45L]', <type 'list'>, <type 'long'>)
, even though this issue is solved, thanks for your responses.
Mixer.getvolume([direction])
Returns a list with the current volume settings for each channel. The list elements are integer percentages.
https://www.programcreek.com/python/example/91452/alsaaudio.Mixer
mixer = alsaaudio.Mixer()
value = mixer.getvolume()[0]
value = value + 5
if value > 100:
value = 100
mixer.setvolume(value)