]>
Commit | Line | Data |
---|---|---|
cc008de4 IB |
1 | import helpers |
2 | ||
3 | helpers.parse_args() | |
4 | ||
d8046b94 IB |
5 | import kivy |
6 | kivy.require("1.9.1") | |
4b2d79ca IB |
7 | from kivy.app import App |
8 | from kivy.uix.floatlayout import FloatLayout | |
9 | from kivy.uix.relativelayout import RelativeLayout | |
10 | from kivy.properties import ListProperty, StringProperty | |
11 | from kivy.clock import Clock | |
12 | from kivy.core.window import Window | |
bb69f62e | 13 | from kivy.lang import Builder |
4b2d79ca IB |
14 | from helpers.key import Key |
15 | from helpers.mapping import Mapping | |
bb69f62e | 16 | |
35bde798 IB |
17 | helpers.register_fonts() |
18 | ||
65ec4d2a IB |
19 | class KeyList(RelativeLayout): |
20 | keylist = ListProperty([]) | |
21 | first_key = StringProperty("") | |
22 | second_key = StringProperty("") | |
23 | third_key = StringProperty("") | |
24 | ||
25 | def append(self, value): | |
98ff4305 | 26 | self.keylist.insert(0, value) |
65ec4d2a IB |
27 | |
28 | def on_keylist(self, instance, new_key_list): | |
29 | if len(self.keylist) > 0: | |
30 | self.first_key = self.keylist[0] | |
31 | if len(self.keylist) > 1: | |
32 | self.second_key = self.keylist[1] | |
33 | if len(self.keylist) > 2: | |
34 | self.third_key = self.keylist[2] | |
35 | ||
4b2d79ca IB |
36 | class PlayList(RelativeLayout): |
37 | playlist = ListProperty([]) | |
38 | ||
39 | def __init__(self, **kwargs): | |
40 | super(PlayList, self).__init__(**kwargs) | |
41 | Clock.schedule_interval(self.update_playlist, 0.5) | |
42 | ||
43 | def update_playlist(self, dt): | |
44 | if self.parent is None or 'Mapping' not in self.parent.ids: | |
45 | return True | |
46 | ||
47 | open_files = self.parent.ids['Mapping'].open_files | |
48 | self.playlist = [] | |
49 | for music_file in open_files.values(): | |
20586193 | 50 | if not music_file.is_in_use(): |
4b2d79ca | 51 | continue |
98ff4305 IB |
52 | |
53 | text = "{}/{}".format( | |
54 | helpers.duration_to_min_sec(music_file.sound_position), | |
2e404903 | 55 | helpers.duration_to_min_sec(music_file.sound_duration)) |
98ff4305 | 56 | |
20586193 | 57 | if music_file.is_loaded_paused(): |
98ff4305 | 58 | self.playlist.append(["⏸", music_file.name, text, False]) |
4b2d79ca | 59 | else: |
98ff4305 | 60 | self.playlist.append(["⏵", music_file.name, text, True]) |
189bf90c | 61 | |
189bf90c | 62 | |
4b2d79ca IB |
63 | class ActionList(RelativeLayout): |
64 | action_title = StringProperty("") | |
65 | action_list = ListProperty([]) | |
189bf90c | 66 | |
b17aed6a | 67 | def update_list(self, key, action_descriptions): |
4b2d79ca IB |
68 | self.action_title = "actions linked to key {}:".format(key.key_sym) |
69 | self.action_list = [] | |
189bf90c | 70 | |
b17aed6a IB |
71 | for [action, status] in action_descriptions: |
72 | if status == "done": | |
4b2d79ca | 73 | icon = "✓" |
b17aed6a | 74 | elif status == "current": |
4b2d79ca IB |
75 | icon = "✅" |
76 | else: | |
77 | icon = " " | |
b17aed6a | 78 | self.action_list.append([icon, action]) |
189bf90c | 79 | |
4b2d79ca IB |
80 | class Screen(FloatLayout): |
81 | pass | |
189bf90c | 82 | |
4b2d79ca IB |
83 | class MusicSamplerApp(App): |
84 | def build(self): | |
85 | Window.size = (913, 563) | |
9de92b6d | 86 | |
4b2d79ca | 87 | return Screen() |
9de92b6d | 88 | |
4b2d79ca | 89 | if __name__ == '__main__': |
e4846541 | 90 | Builder.load_file(helpers.path() + "/music_sampler.kv") |
4b2d79ca | 91 | MusicSamplerApp().run() |