def tick(self): if self.volume_changed: self.volume_changed = False self.client.call( requests.SetVolume( list(self.audio_sources.values())[0], self.levels[0])) self.client.call( requests.SetVolume( list(self.audio_sources.values())[1], self.levels[1]))
def DecVolume(self, *args): v = float(self.GetVolume(args[0])) if v >= 0.1: v -= 0.1 elif v > 0: v = 0 return self.ws.call(requests.SetVolume(args[0], v))
def IncVolume(self, *args): v = float(self.GetVolume(args[0])) if v <= 0.9: v += 0.1 elif v < 1.0: v = 1.0 return self.ws.call(requests.SetVolume(args[0], v))
def audio_fade_out(self, name, transition_time=2): volume = self.get_audio_volume(name) if transition_time > 0: steps = volume / transition_time / 10 else: steps = volume for i in range((transition_time * 10) + 1): res_volume = volume - ((i + 1) * steps) self._call(requests.SetVolume(name, res_volume, False)) sleep(0.1) return self.audio_mute(name) and self.get_audio_volume(name) == 0
def Sources_SetVolume(self, volume, SourceName="", *args, **kwargs): #Not tested try: volume = volume / 127 minvolume = 0 maxvolume = 1 if "MinVolume" in kwargs: minvolume = kwargs["MinVolume"] if "MaxVolume" in kwargs: maxvolume = kwargs["MaxVolume"] volume = minvolume + volume * (maxvolume - minvolume) self.ws.call(requests.SetVolume(SourceName, volume)) PrintWithTime(f"Set volume of source {SourceName} to {volume}") except Exception as e: PrintWithTime(f"Couldn't set volume of source {SourceName} to {volume}. Error : {e}")
def audio_fade_in(self, name, transition_time=2): if not self.audio_unmute(name): return False volume = self.get_audio_volume(name) if transition_time > 0: steps = (1 - volume) / transition_time / 10 else: steps = (1 - volume) for i in range((transition_time * 10) + 1): res_volume = volume + ((i + 1) * steps) self._call(requests.SetVolume(name, res_volume, False)) sleep(0.1) return self.get_audio_volume(name) > 0.95
def SetSourceVolume(Action, Value, ws): if "SourceName" in Action: if Value == None: if "SourceVolume" in Action: Value = Action["SourceVolume"] else: Value = 0 elif "MaxValue" in Action: if "MinValue" in Action: Value = (Action["MaxValue"] - Action["MinValue"]) / 127 * Value + Action["MinValue"] else: Value = Action["MaxValue"] / 127 * Value try: ws.call(requests.SetVolume(Action["SourceName"], Value)) except: print("Couldn't set source volume: " + str(Value * 100) + "%") else: PrintWithTime("Source volume was changed to " + str(Value * 100) + "%") else: print("No SourceName argument in action config")
def SetSourceVolume(self, SourceName, volume): try: self.ws.call(requests.SetVolume(SourceName, volume)) except Exception as e: print(e)
def set_volume(self, name, val): self.connection.call(requests.SetVolume(name, val))
def change_volume_m(self, value): volume = float(value) / 100 self.ws.call( requests.SetVolume(source=self.aud_sources.getMic1(), volume=volume))
def setVolume(self, source, vol): mapvol = map_scale(vol, 0, 127, 0, 1) deviceID, control, value self.ws.call(requests.SetVolume(source, mapvol))