X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=helpers%2Fmusic_file.py;h=32869b6891aed831a8b2768016aedf3a83a7fe45;hb=52d58baf7a39e5e09a0b4ce24b1e951d98e7618b;hp=b926c64c63a20e1adcc689a70c0e15d69a32ca1b;hpb=8e50011c8d5e5f4ac48f0856c9737d62f3e67838;p=perso%2FImmae%2FProjets%2FPython%2FMusicSampler.git diff --git a/helpers/music_file.py b/helpers/music_file.py index b926c64..32869b6 100644 --- a/helpers/music_file.py +++ b/helpers/music_file.py @@ -129,6 +129,13 @@ class MusicFile(Machine): out_data[:] = audio_segment.ljust(len(out_data), b'\0') + def seek(self, value = 0, delta = False): + # We don't want to do that while stopping + if not (self.is_loaded_playing() or self.is_loaded_paused()): + return + with self.music_lock: + self.current_frame = max(0, int(delta) * self.current_frame + int(value * self.audio_segment.frame_rate)) + def stop(self, fade_out = 0, wait = False): if self.is_loaded_playing(): ms = int(self.sound_position * 1000)