]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/commitdiff
Fix absolute path when using music_path
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Wed, 27 Jul 2016 13:50:33 +0000 (15:50 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Wed, 27 Jul 2016 13:50:33 +0000 (15:50 +0200)
helpers/music_file.py

index 916b95526fcff251d09717577e2d23a77273e9c3..2d3ba727ce6486771c54e6a99e0ee83a1ee076cf 100644 (file)
@@ -101,10 +101,15 @@ class MusicFile:
     def reload_music_file(self):
         with file_lock:
             try:
+                if self.filename.startswith("/"):
+                    filename = self.filename
+                else:
+                    filename = Config.music_path + self.filename
+
                 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) \
+                        .from_file(filename) \
                         .set_frame_rate(Config.frame_rate) \
                         .set_channels(Config.channels) \
                         .set_sample_width(Config.sample_width) \
@@ -121,11 +126,16 @@ class MusicFile:
     def on_enter_loading(self):
         with file_lock:
             try:
+                if self.filename.startswith("/"):
+                    filename = self.filename
+                else:
+                    filename = Config.music_path + self.filename
+
                 debug_print("Loading « {} »".format(self.name))
                 self.mixer = self.mapping.mixer or Mixer()
                 initial_db_gain = gain(self.initial_volume_factor * 100)
                 self.audio_segment = pydub.AudioSegment \
-                        .from_file(Config.music_path + self.filename) \
+                        .from_file(filename) \
                         .set_frame_rate(Config.frame_rate) \
                         .set_channels(Config.channels) \
                         .set_sample_width(Config.sample_width) \