threading.Thread(name="MSMusicLoad", target=self.load).start()
+ def reload_properties(self, name=None, gain=1):
+ self.name = name or self.filename
+ if gain != self.initial_volume_factor:
+ self.initial_volume_factor = gain
+ self.reload_music_file()
+
+ def reload_music_file(self):
+ with file_lock:
+ try:
+ debug_print("Reloading « {} »".format(self.name))
+ initial_db_gain = gain(self.initial_volume_factor * 100)
+ self.audio_segment = pydub.AudioSegment \
+ .from_file(Config.music_path + self.filename) \
+ .set_frame_rate(Config.frame_rate) \
+ .set_channels(Config.channels) \
+ .set_sample_width(Config.sample_width) \
+ .apply_gain(initial_db_gain)
+ except Exception as e:
+ error_print("failed to reload « {} »: {}"\
+ .format(self.name, e))
+ self.loading_error = e
+ self.to_failed()
+ else:
+ debug_print("Reloaded « {} »".format(self.name))
+
# Machine related events
def on_enter_loading(self):
with file_lock:
self.mixer = self.mapping.mixer or Mixer()
initial_db_gain = gain(self.initial_volume_factor * 100)
self.audio_segment = pydub.AudioSegment \
- .from_file(self.filename) \
+ .from_file(Config.music_path + self.filename) \
.set_frame_rate(Config.frame_rate) \
.set_channels(Config.channels) \
.set_sample_width(Config.sample_width) \