aboutsummaryrefslogtreecommitdiff
path: root/helpers/music_file.py
diff options
context:
space:
mode:
Diffstat (limited to 'helpers/music_file.py')
-rw-r--r--helpers/music_file.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/helpers/music_file.py b/helpers/music_file.py
index 6da547b..f1aa341 100644
--- a/helpers/music_file.py
+++ b/helpers/music_file.py
@@ -6,7 +6,7 @@ from transitions.extensions import HierarchicalMachine as Machine
6import os.path 6import os.path
7 7
8from .lock import Lock 8from .lock import Lock
9from . import gain 9from . import Config, gain
10 10
11file_lock = Lock("file") 11file_lock = Lock("file")
12 12
@@ -48,7 +48,7 @@ class MusicFile(Machine):
48 try: 48 try:
49 print("Loading « {} »".format(self.name)) 49 print("Loading « {} »".format(self.name))
50 db_gain = gain(self.volume_factor * 100) 50 db_gain = gain(self.volume_factor * 100)
51 self.audio_segment = pydub.AudioSegment.from_file(self.filename).set_frame_rate(44100).set_channels(2).set_sample_width(2).apply_gain(db_gain) 51 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)
52 self.audio_segment_frame_width = self.audio_segment.frame_width 52 self.audio_segment_frame_width = self.audio_segment.frame_width
53 self.sound_duration = self.audio_segment.duration_seconds 53 self.sound_duration = self.audio_segment.duration_seconds
54 except Exception as e: 54 except Exception as e:
@@ -121,6 +121,7 @@ class MusicFile(Machine):
121 data += new_data 121 data += new_data
122 nb_frames += new_nb_frames 122 nb_frames += new_nb_frames
123 elif nb_frames == 0: 123 elif nb_frames == 0:
124 # FIXME: too slow
124 threading.Thread(name = "MSFinishedCallback", target=self.finished_callback).start() 125 threading.Thread(name = "MSFinishedCallback", target=self.finished_callback).start()
125 126
126 return data.ljust(out_data_length, b'\0') 127 return data.ljust(out_data_length, b'\0')