aboutsummaryrefslogtreecommitdiff
path: root/music_sampler
diff options
context:
space:
mode:
Diffstat (limited to 'music_sampler')
-rw-r--r--music_sampler/actions/interrupt_wait.py5
-rw-r--r--music_sampler/actions/wait.py3
-rw-r--r--music_sampler/locales/fr/LC_MESSAGES/music_sampler.po4
-rw-r--r--music_sampler/mapping.py35
-rw-r--r--music_sampler/music_file.py3
5 files changed, 34 insertions, 16 deletions
diff --git a/music_sampler/actions/interrupt_wait.py b/music_sampler/actions/interrupt_wait.py
index f85a3c4..b367628 100644
--- a/music_sampler/actions/interrupt_wait.py
+++ b/music_sampler/actions/interrupt_wait.py
@@ -2,4 +2,7 @@ def run(action, wait_id=None, **kwargs):
2 action.mapping.interrupt_wait(wait_id) 2 action.mapping.interrupt_wait(wait_id)
3 3
4def description(action, wait_id=None, **kwargs): 4def description(action, wait_id=None, **kwargs):
5 return _("interrupt wait with id {}").format(wait_id) 5 if wait_id is None:
6 return _("interrupt all waits")
7 else:
8 return _("interrupt wait with id {}").format(wait_id)
diff --git a/music_sampler/actions/wait.py b/music_sampler/actions/wait.py
index e6d07f2..bcee649 100644
--- a/music_sampler/actions/wait.py
+++ b/music_sampler/actions/wait.py
@@ -1,8 +1,7 @@
1import threading 1import threading
2 2
3def run(action, duration=0, music=None, set_wait_id=None, **kwargs): 3def run(action, duration=0, music=None, set_wait_id=None, **kwargs):
4 if set_wait_id is not None: 4 action.mapping.add_wait(action, wait_id=set_wait_id)
5 action.mapping.add_wait_id(set_wait_id, action)
6 5
7 action.sleep_event = threading.Event() 6 action.sleep_event = threading.Event()
8 action.sleep_event_timer = threading.Timer( 7 action.sleep_event_timer = threading.Timer(
diff --git a/music_sampler/locales/fr/LC_MESSAGES/music_sampler.po b/music_sampler/locales/fr/LC_MESSAGES/music_sampler.po
index f603a3d..888d7a5 100644
--- a/music_sampler/locales/fr/LC_MESSAGES/music_sampler.po
+++ b/music_sampler/locales/fr/LC_MESSAGES/music_sampler.po
@@ -91,6 +91,10 @@ msgstr "L'argument '-V' ne peut être utilisé que dans la version compilée"
91msgid "interrupt wait with id {}" 91msgid "interrupt wait with id {}"
92msgstr "Interrompre l'attente d'identifiant {}" 92msgstr "Interrompre l'attente d'identifiant {}"
93 93
94#: music_sampler/actions/interrupt_wait.py:5
95msgid "interrupt all waits"
96msgstr "Interrompre toutes les attentes"
97
94#: music_sampler/actions/pause.py:8 98#: music_sampler/actions/pause.py:8
95msgid "pausing « {} »" 99msgid "pausing « {} »"
96msgstr "mise en pause de « {} »" 100msgstr "mise en pause de « {} »"
diff --git a/music_sampler/mapping.py b/music_sampler/mapping.py
index 50b68a9..a04c2f6 100644
--- a/music_sampler/mapping.py
+++ b/music_sampler/mapping.py
@@ -197,17 +197,30 @@ class Mapping(RelativeLayout):
197 music.set_gain_with_effect(db_gain, fade=fade) 197 music.set_gain_with_effect(db_gain, fade=fade)
198 198
199 # Wait handler methods 199 # Wait handler methods
200 def add_wait_id(self, wait_id, action_or_wait): 200 def add_wait(self, action_or_wait, wait_id=None):
201 self.wait_ids[wait_id] = action_or_wait 201 if wait_id is not None:
202 202 self.wait_ids[wait_id] = [action_or_wait]
203 def interrupt_wait(self, wait_id): 203 else:
204 if wait_id in self.wait_ids: 204 if None not in self.wait_ids:
205 action_or_wait = self.wait_ids[wait_id] 205 self.wait_ids[None] = []
206 del(self.wait_ids[wait_id]) 206 self.wait_ids[None].append(action_or_wait)
207 if isinstance(action_or_wait, Action): 207
208 action_or_wait.interrupt() 208 def interrupt_wait(self, wait_id=None):
209 else: 209 if wait_id is None:
210 action_or_wait.set() 210 ids_to_interrupt = list(self.wait_ids.keys())
211 elif wait_id in self.wait_ids:
212 ids_to_interrupt = [wait_id]
213 else:
214 ids_to_interrupt = []
215
216 for _wait_id in ids_to_interrupt:
217 action_or_waits = self.wait_ids[_wait_id]
218 del(self.wait_ids[_wait_id])
219 for action_or_wait in action_or_waits:
220 if isinstance(action_or_wait, Action):
221 action_or_wait.interrupt()
222 else:
223 action_or_wait.set()
211 224
212 # Methods to control running keys 225 # Methods to control running keys
213 def start_running(self, key, start_time): 226 def start_running(self, key, start_time):
diff --git a/music_sampler/music_file.py b/music_sampler/music_file.py
index fa6293d..4ba65e3 100644
--- a/music_sampler/music_file.py
+++ b/music_sampler/music_file.py
@@ -241,8 +241,7 @@ class MusicFile:
241 self.current_audio_segment = new_audio_segment 241 self.current_audio_segment = new_audio_segment
242 self.stop_playing() 242 self.stop_playing()
243 if wait: 243 if wait:
244 if set_wait_id is not None: 244 self.mapping.add_wait(self.wait_event, wait_id=set_wait_id)
245 self.mapping.add_wait_id(set_wait_id, self.wait_event)
246 self.wait_end() 245 self.wait_end()
247 else: 246 else:
248 self.stopped() 247 self.stopped()