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