diff options
-rw-r--r-- | helpers/mapping.py | 14 | ||||
-rw-r--r-- | music_sampler.kv | 5 |
2 files changed, 18 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 | ||
diff --git a/music_sampler.kv b/music_sampler.kv index 87c6e93..7d7e95c 100644 --- a/music_sampler.kv +++ b/music_sampler.kv | |||
@@ -318,6 +318,11 @@ | |||
318 | Rectangle: | 318 | Rectangle: |
319 | pos: 0, 0 | 319 | pos: 0, 0 |
320 | size: self.width, self.height | 320 | size: self.width, self.height |
321 | Color: | ||
322 | rgba: self.ready_color | ||
323 | Ellipse: | ||
324 | pos: self.width - self.key_size / 2, self.height - self.key_size /2 | ||
325 | size: self.key_size / 3, self.key_size / 3 | ||
321 | Key: | 326 | Key: |
322 | id: Key_27 | 327 | id: Key_27 |
323 | key_code: 27 | 328 | key_code: 27 |