X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=helpers%2Fmusic_file.py;h=cff897ad67c98ac05438de3a2d27ca0d98f01d95;hb=0cb786e3c003745a3bde2b7f6ab06871147ce6f4;hp=a37a708cb5365ae519a76186ce5768a60280be08;hpb=1e44fe7e6c1464b49582a163615e8cb3ed279d3e;p=perso%2FImmae%2FProjets%2FPython%2FMusicSampler.git diff --git a/helpers/music_file.py b/helpers/music_file.py index a37a708..cff897a 100644 --- a/helpers/music_file.py +++ b/helpers/music_file.py @@ -128,7 +128,10 @@ class MusicFile(Machine): self.set_gain(gain(volume) + self.mapping.master_gain, absolute=True) self.volume = volume self.current_loop = 0 - self.loop_left = loop + if loop < 0: + self.last_loop = float('inf') + else: + self.last_loop = loop with self.music_lock: self.current_audio_segment = self.audio_segment @@ -166,8 +169,8 @@ class MusicFile(Machine): with self.music_lock: [data, nb_frames] = self.get_next_sample(frame_count) if nb_frames < frame_count: - if self.is_loaded_playing() and self.loop_left != 0: - self.loop_left -= 1 + if self.is_loaded_playing() and\ + self.current_loop < self.last_loop: self.current_loop += 1 self.current_frame = 0 [new_data, new_nb_frames] = self.get_next_sample(