]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blobdiff - helpers/music_file.py
Add new configurations parameters
[perso/Immae/Projets/Python/MusicSampler.git] / helpers / music_file.py
index 6da547b8473678b78985272ed7b72f548ab4b368..f1aa341ee26f194d6af50a35d512f4fd44fe177f 100644 (file)
@@ -6,7 +6,7 @@ from transitions.extensions import HierarchicalMachine as Machine
 import os.path
 
 from .lock import Lock
-from . import gain
+from . import Config, gain
 
 file_lock = Lock("file")
 
@@ -48,7 +48,7 @@ class MusicFile(Machine):
             try:
                 print("Loading « {} »".format(self.name))
                 db_gain = gain(self.volume_factor * 100)
-                self.audio_segment = pydub.AudioSegment.from_file(self.filename).set_frame_rate(44100).set_channels(2).set_sample_width(2).apply_gain(db_gain)
+                self.audio_segment = pydub.AudioSegment.from_file(self.filename).set_frame_rate(Config.frame_rate).set_channels(Config.channels).set_sample_width(Config.sample_width).apply_gain(db_gain)
                 self.audio_segment_frame_width = self.audio_segment.frame_width
                 self.sound_duration = self.audio_segment.duration_seconds
             except Exception as e:
@@ -121,6 +121,7 @@ class MusicFile(Machine):
                     data += new_data
                     nb_frames += new_nb_frames
                 elif nb_frames == 0:
+                    # FIXME: too slow
                     threading.Thread(name = "MSFinishedCallback", target=self.finished_callback).start()
 
             return data.ljust(out_data_length, b'\0')