]>
git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blob - music_sampler.py
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
13 from kivy
.lang
import Builder
14 from helpers
.key
import Key
15 from helpers
.mapping
import Mapping
17 class KeyList(RelativeLayout
):
18 keylist
= ListProperty([])
19 first_key
= StringProperty("")
20 second_key
= StringProperty("")
21 third_key
= StringProperty("")
23 def append(self
, value
):
24 self
.keylist
.insert(0, value
)
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]
34 class PlayList(RelativeLayout
):
35 playlist
= ListProperty([])
37 def __init__(self
, **kwargs
):
38 super(PlayList
, self
).__init
__(**kwargs
)
39 Clock
.schedule_interval(self
.update_playlist
, 0.5)
41 def update_playlist(self
, dt
):
42 if self
.parent
is None or 'Mapping' not in self
.parent
.ids
:
45 open_files
= self
.parent
.ids
['Mapping'].open_files
47 for music_file
in open_files
.values():
48 if not music_file
.is_in_use():
51 text
= "{}/{}".format(
52 helpers
.duration_to_min_sec(music_file
.sound_position
),
53 helpers
.duration_to_min_sec(music_file
.sound_duration
))
55 if music_file
.is_loaded_paused():
56 self
.playlist
.append(["⏸", music_file
.name
, text
, False])
58 self
.playlist
.append(["⏵", music_file
.name
, text
, True])
61 class ActionList(RelativeLayout
):
62 action_title
= StringProperty("")
63 action_list
= ListProperty([])
65 def update_list(self
, key
, action_descriptions
):
66 self
.action_title
= "actions linked to key {}:".format(key
.key_sym
)
69 for [action
, status
] in action_descriptions
:
72 elif status
== "current":
76 self
.action_list
.append([icon
, action
])
78 class Screen(FloatLayout
):
81 class MusicSamplerApp(App
):
83 Window
.size
= (913, 563)
87 if __name__
== '__main__':
88 Builder
.load_file(helpers
.path() + "/music_sampler.kv")
89 MusicSamplerApp().run()