diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-06-27 13:19:00 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-06-27 13:19:00 +0200 |
commit | 30d8796f2a29a7e1baad56106eb4ffc2ef0c632c (patch) | |
tree | fcac510f2ab209e3216c93f2a164150a166443ae /helpers | |
parent | e5edd8b96e0e5e8be4adadab5a2f56e83cfdd264 (diff) | |
download | MusicSampler-30d8796f2a29a7e1baad56106eb4ffc2ef0c632c.tar.gz MusicSampler-30d8796f2a29a7e1baad56106eb4ffc2ef0c632c.tar.zst MusicSampler-30d8796f2a29a7e1baad56106eb4ffc2ef0c632c.zip |
Add indicator of whether all keys are ready
Diffstat (limited to 'helpers')
-rw-r--r-- | helpers/mapping.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/helpers/mapping.py b/helpers/mapping.py index 28f4acd..e800778 100644 --- a/helpers/mapping.py +++ b/helpers/mapping.py | |||
@@ -1,6 +1,7 @@ | |||
1 | from kivy.uix.relativelayout import RelativeLayout | 1 | from kivy.uix.relativelayout import RelativeLayout |
2 | from kivy.properties import NumericProperty | 2 | from kivy.properties import NumericProperty, ListProperty |
3 | from kivy.core.window import Window | 3 | from kivy.core.window import Window |
4 | from kivy.clock import Clock | ||
4 | 5 | ||
5 | import threading | 6 | import threading |
6 | import pygame | 7 | import pygame |
@@ -12,6 +13,7 @@ from .music_file import * | |||
12 | 13 | ||
13 | class Mapping(RelativeLayout): | 14 | class Mapping(RelativeLayout): |
14 | expected_keys = NumericProperty(0) | 15 | expected_keys = NumericProperty(0) |
16 | ready_color = ListProperty([1, 165/255, 0, 1]) | ||
15 | 17 | ||
16 | def __init__(self, **kwargs): | 18 | def __init__(self, **kwargs): |
17 | self.key_config, self.channel_number, self.open_files = self.parse_config() | 19 | self.key_config, self.channel_number, self.open_files = self.parse_config() |
@@ -19,6 +21,7 @@ class Mapping(RelativeLayout): | |||
19 | self._keyboard = Window.request_keyboard(self._keyboard_closed, self) | 21 | self._keyboard = Window.request_keyboard(self._keyboard_closed, self) |
20 | self._keyboard.bind(on_key_down=self._on_keyboard_down) | 22 | self._keyboard.bind(on_key_down=self._on_keyboard_down) |
21 | self.running = [] | 23 | self.running = [] |
24 | Clock.schedule_interval(self.not_all_keys_ready, 1) | ||
22 | 25 | ||
23 | 26 | ||
24 | pygame.mixer.init(frequency = 44100) | 27 | pygame.mixer.init(frequency = 44100) |
@@ -57,6 +60,15 @@ class Mapping(RelativeLayout): | |||
57 | return key | 60 | return key |
58 | return None | 61 | return None |
59 | 62 | ||
63 | def not_all_keys_ready(self, dt): | ||
64 | for key in self.children: | ||
65 | if not type(key).__name__ == "Key": | ||
66 | continue | ||
67 | if not key.is_key_ready: | ||
68 | return True | ||
69 | self.ready_color = [0, 1, 0, 1] | ||
70 | return False | ||
71 | |||
60 | def stop_all_running(self): | 72 | def stop_all_running(self): |
61 | self.running = [] | 73 | self.running = [] |
62 | 74 | ||