I have a certain program which changes the volume of a computer using the pulsectl
module in python. The following is the code:
if(distance > self.threshold):
self.pulse.volume_change_all_chans(self.sink, 0.02)
else:
self.pulse.volume_change_all_chans(self.sink, -0.02)
Using this code leads to a minimum value of 0 and a maximum value can go up to infinity. What I would like to do is that the maximum value of volume should be set at one. It shouldn't increase even a bit beyond one.
For ex, if my current volume is 0.99
and the condition in if
statement is True
, then, my volume changes to 1.1
. This shouldn't happen. It should increase maximum to 1.0
. Never beyond it.
Also, the current value of value of volume can be obtained by self.pulse.volume_get_all_chans(self.sink)
How can i do this without writing too many if else conditions in python.