aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2016-07-27 02:27:23 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2016-07-27 02:27:23 +0200
commit940bb6ad6cbd823ed245577093bd8959e189d43f (patch)
treea3e80900fbb33518d83a0ea3240172bdc821bce6
parent62a8b07a2264101fd6d9c201267966e3c5de0cd4 (diff)
downloadMusicSampler-940bb6ad6cbd823ed245577093bd8959e189d43f.tar.gz
MusicSampler-940bb6ad6cbd823ed245577093bd8959e189d43f.tar.zst
MusicSampler-940bb6ad6cbd823ed245577093bd8959e189d43f.zip
Add music-path option to the command line
-rw-r--r--helpers/__init__.py8
-rw-r--r--helpers/music_file.py4
2 files changed, 10 insertions, 2 deletions
diff --git a/helpers/__init__.py b/helpers/__init__.py
index 534e168..f1a968b 100644
--- a/helpers/__init__.py
+++ b/helpers/__init__.py
@@ -33,6 +33,10 @@ def parse_args():
33 default="config.yml", 33 default="config.yml",
34 required=False, 34 required=False,
35 help="Config file to load") 35 help="Config file to load")
36 parser.add_argument("-p", "--music-path",
37 default=".",
38 required=False,
39 help="Folder in which to find the music files")
36 parser.add_argument("-d", "--debug", 40 parser.add_argument("-d", "--debug",
37 nargs=0, 41 nargs=0,
38 action=DebugModeAction, 42 action=DebugModeAction,
@@ -98,6 +102,10 @@ def parse_args():
98 Config.channels = args.channels 102 Config.channels = args.channels
99 Config.sample_width = args.sample_width 103 Config.sample_width = args.sample_width
100 Config.builtin_mixing = args.builtin_mixing 104 Config.builtin_mixing = args.builtin_mixing
105 if args.music_path.endswith("/"):
106 Config.music_path = args.music_path
107 else:
108 Config.music_path = args.music_path + "/"
101 109
102class DebugModeAction(argparse.Action): 110class DebugModeAction(argparse.Action):
103 def __call__(self, parser, namespace, values, option_string=None): 111 def __call__(self, parser, namespace, values, option_string=None):
diff --git a/helpers/music_file.py b/helpers/music_file.py
index ba86142..916b955 100644
--- a/helpers/music_file.py
+++ b/helpers/music_file.py
@@ -104,7 +104,7 @@ class MusicFile:
104 debug_print("Reloading « {} »".format(self.name)) 104 debug_print("Reloading « {} »".format(self.name))
105 initial_db_gain = gain(self.initial_volume_factor * 100) 105 initial_db_gain = gain(self.initial_volume_factor * 100)
106 self.audio_segment = pydub.AudioSegment \ 106 self.audio_segment = pydub.AudioSegment \
107 .from_file(self.filename) \ 107 .from_file(Config.music_path + self.filename) \
108 .set_frame_rate(Config.frame_rate) \ 108 .set_frame_rate(Config.frame_rate) \
109 .set_channels(Config.channels) \ 109 .set_channels(Config.channels) \
110 .set_sample_width(Config.sample_width) \ 110 .set_sample_width(Config.sample_width) \
@@ -125,7 +125,7 @@ class MusicFile:
125 self.mixer = self.mapping.mixer or Mixer() 125 self.mixer = self.mapping.mixer or Mixer()
126 initial_db_gain = gain(self.initial_volume_factor * 100) 126 initial_db_gain = gain(self.initial_volume_factor * 100)
127 self.audio_segment = pydub.AudioSegment \ 127 self.audio_segment = pydub.AudioSegment \
128 .from_file(self.filename) \ 128 .from_file(Config.music_path + self.filename) \
129 .set_frame_rate(Config.frame_rate) \ 129 .set_frame_rate(Config.frame_rate) \
130 .set_channels(Config.channels) \ 130 .set_channels(Config.channels) \
131 .set_sample_width(Config.sample_width) \ 131 .set_sample_width(Config.sample_width) \