diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-08-12 14:51:32 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-08-12 14:51:32 +0200 |
commit | 21ffec315b8fa8a6b46351021da915236148a7b1 (patch) | |
tree | 52951646c8f9d1ea453c58aa37c92e64ff0dd9a1 /music_sampler/mapping.py | |
parent | 4094ae4ebff7997e8c5e0fd84a1434b1b86632b1 (diff) | |
download | MusicSampler-21ffec315b8fa8a6b46351021da915236148a7b1.tar.gz MusicSampler-21ffec315b8fa8a6b46351021da915236148a7b1.tar.zst MusicSampler-21ffec315b8fa8a6b46351021da915236148a7b1.zip |
Make 'interrupt_wait' able to interrupt all waits
If 'wait_id' is not specified, interrupt_wait will now stop all wait events.
This fixes https://git.immae.eu/mantisbt/view.php?id=4
Diffstat (limited to 'music_sampler/mapping.py')
-rw-r--r-- | music_sampler/mapping.py | 35 |
1 files changed, 24 insertions, 11 deletions
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): |