self.music_lock = Lock("music__" + filename)
self.wait_event = threading.Event()
self.db_gain = 0
+ self.volume_factor = 1
threading.Thread(name="MSMusicLoad", target=self.load).start()
return 0
def play(self, fade_in=0, volume=100, loop=0, start_at=0):
- self.db_gain = gain(volume) + self.mapping.master_gain
+ self.set_gain(gain(volume) + self.mapping.master_gain, absolute=True)
self.volume = volume
self.loop = loop
self.stop_playing()
self.stopped()
- def set_gain(self, db_gain):
- self.db_gain += db_gain
+ def set_gain(self, db_gain, absolute=False):
+ if absolute:
+ self.db_gain = db_gain
+ else:
+ self.db_gain += db_gain
self.volume_factor = 10 ** (self.db_gain / 20)
def set_volume(self, value, delta=False):