aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2016-07-27 15:50:33 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2016-07-27 15:50:33 +0200
commitdd2887c2db888065f11534b2fe180d1ca7deb191 (patch)
tree206fcedf13acba71f34f511b4bec8f20a268c3bc
parentea97edb3ea6fc9a222d7ec43ff517276a25c7f14 (diff)
downloadMusicSampler-dd2887c2db888065f11534b2fe180d1ca7deb191.tar.gz
MusicSampler-dd2887c2db888065f11534b2fe180d1ca7deb191.tar.zst
MusicSampler-dd2887c2db888065f11534b2fe180d1ca7deb191.zip
Fix absolute path when using music_path
-rw-r--r--helpers/music_file.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/helpers/music_file.py b/helpers/music_file.py
index 916b955..2d3ba72 100644
--- a/helpers/music_file.py
+++ b/helpers/music_file.py
@@ -101,10 +101,15 @@ class MusicFile:
101 def reload_music_file(self): 101 def reload_music_file(self):
102 with file_lock: 102 with file_lock:
103 try: 103 try:
104 if self.filename.startswith("/"):
105 filename = self.filename
106 else:
107 filename = Config.music_path + self.filename
108
104 debug_print("Reloading « {} »".format(self.name)) 109 debug_print("Reloading « {} »".format(self.name))
105 initial_db_gain = gain(self.initial_volume_factor * 100) 110 initial_db_gain = gain(self.initial_volume_factor * 100)
106 self.audio_segment = pydub.AudioSegment \ 111 self.audio_segment = pydub.AudioSegment \
107 .from_file(Config.music_path + self.filename) \ 112 .from_file(filename) \
108 .set_frame_rate(Config.frame_rate) \ 113 .set_frame_rate(Config.frame_rate) \
109 .set_channels(Config.channels) \ 114 .set_channels(Config.channels) \
110 .set_sample_width(Config.sample_width) \ 115 .set_sample_width(Config.sample_width) \
@@ -121,11 +126,16 @@ class MusicFile:
121 def on_enter_loading(self): 126 def on_enter_loading(self):
122 with file_lock: 127 with file_lock:
123 try: 128 try:
129 if self.filename.startswith("/"):
130 filename = self.filename
131 else:
132 filename = Config.music_path + self.filename
133
124 debug_print("Loading « {} »".format(self.name)) 134 debug_print("Loading « {} »".format(self.name))
125 self.mixer = self.mapping.mixer or Mixer() 135 self.mixer = self.mapping.mixer or Mixer()
126 initial_db_gain = gain(self.initial_volume_factor * 100) 136 initial_db_gain = gain(self.initial_volume_factor * 100)
127 self.audio_segment = pydub.AudioSegment \ 137 self.audio_segment = pydub.AudioSegment \
128 .from_file(Config.music_path + self.filename) \ 138 .from_file(filename) \
129 .set_frame_rate(Config.frame_rate) \ 139 .set_frame_rate(Config.frame_rate) \
130 .set_channels(Config.channels) \ 140 .set_channels(Config.channels) \
131 .set_sample_width(Config.sample_width) \ 141 .set_sample_width(Config.sample_width) \