From 6ebe62478a49df22c55ef6a2b1200473500a7f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Wed, 27 Jul 2016 22:15:25 +0200 Subject: Use pip setup file --- MANIFEST.in | 1 + README | 14 + music_sampler.kv | 900 ----------------------------------------- music_sampler.py | 91 ----- music_sampler.spec | 4 +- music_sampler/__init__.py | 193 +-------- music_sampler/action.py | 2 +- music_sampler/app.py | 91 +++++ music_sampler/helpers.py | 192 +++++++++ music_sampler/key.py | 2 +- music_sampler/lock.py | 2 +- music_sampler/mapping.py | 2 +- music_sampler/mixer.py | 2 +- music_sampler/music_file.py | 2 +- music_sampler/music_sampler.kv | 900 +++++++++++++++++++++++++++++++++++++++++ run.py | 3 + setup.py | 40 ++ 17 files changed, 1250 insertions(+), 1191 deletions(-) create mode 100644 MANIFEST.in create mode 100644 README delete mode 100644 music_sampler.kv delete mode 100644 music_sampler.py create mode 100644 music_sampler/app.py create mode 100644 music_sampler/helpers.py create mode 100644 music_sampler/music_sampler.kv create mode 100644 run.py create mode 100644 setup.py diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..5dab67a --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include music_sampler/music_sampler.kv diff --git a/README b/README new file mode 100644 index 0000000..6017dcd --- /dev/null +++ b/README @@ -0,0 +1,14 @@ +Music Sampler is a music player which associates each key on the keyboard to a +set of actions to run. + +See full documentation in french in documentation_fr.md + +Git repository: +https://git.immae.eu/?p=perso/Immae/Projets/Python/MusicSampler.git + +Bug Tracker: +https://git.immae.eu/mantisbt/view_all_bug_page.php?project_id=1 + +Contributors: +Ismaël Bouya +Denise Maurice diff --git a/music_sampler.kv b/music_sampler.kv deleted file mode 100644 index 9057532..0000000 --- a/music_sampler.kv +++ /dev/null @@ -1,900 +0,0 @@ -#:import math math -#:import h music_sampler - -: - pad_col_sep: 0 if not self.pad_cols else self.parent.pad_x - pad_cols: False - - y: (self.parent.top-self.parent.y) - (self.row) * self.parent.key_size - (self.row - 1) * self.parent.key_sep - x: (self.col - 1) * self.parent.key_size + int(self.col - 1) * self.parent.key_sep + self.pad_col_sep - size_hint: None, None - enabled: True - line_width: 2 - row: 1 - col: 0 - key_code: 0 - key_sym: "" - key_width: 1 - key_height: 1 - width: self.key_width * (self.parent.key_size + self.parent.key_sep) - self.parent.key_sep - height: self.key_height * (self.parent.key_size + self.parent.key_sep) - self.parent.key_sep - canvas.before: - Color: - rgba: self.color - RoundedRectangle: - pos: self.x, self.y - size: self.size - canvas: - Color: - rgba: self.line_color - Line: - rounded_rectangle: self.x + self.line_width, self.y + self.line_width, self.width - 2 * self.line_width, self.height - 2 * self.line_width, 10 - width: self.line_width - Color: - rgba: self.line_cross_color - Line: - points: self.x + self.line_width + 3, self.y + self.line_width + 3, self.x + self.width - 2 * self.line_width - 3, self.y + self.height - 2 * self.line_width - 3 - width: self.line_width - Line: - points: self.x + self.line_width + 3, self.y + self.height - 2 * self.line_width - 3, self.x + self.width - 2 * self.line_width - 3, self.y + self.line_width + 3 - width: self.line_width - Label: - id: key_label - font_name: "Ubuntu" - bold: True - font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size)) - color: 0, 0, 0, 1 - text: self.parent.key_sym - text_size: self.parent.width,self.font_size - shorten: True - shorten_from: "right" - split_str: "" - center_x: self.parent.x + self.texture_size[0] /2 + 5 - center_y: self.parent.y + self.parent.height - self.texture_size[1] /2 - 5 - Label: - id: key_description_title - font_name: "Ubuntu" - font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size / 2)) - color: 0, 0, 0, 1 - text: self.parent.description_title - text_size: self.parent.width - 2*self.parent.line_width, self.font_size - halign: "right" - valign: "middle" - center_x: self.parent.x + self.texture_size[0] /2 - center_y: self.parent.y + self.parent.height - self.texture_size[1] /2 - 5 - Label: - id: key_description - font_name: "Ubuntu" - font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size / 2)) - color: 0, 0, 0, 1 - text: "\n".join(self.parent.description) - text_size: 2 * self.parent.width,self.parent.height - key_label.font_size - halign: "left" - valign: "middle" - pos: self.parent.x + 2 * self.parent.line_width + 2, self.parent.y - size_hint: None, None - size: 2 * self.parent.width - 2 * self.parent.line_width, self.parent.height - key_label.font_size - -: - canvas: - Color: - rgba: 229/255, 228/255, 226/255, 1 - Rectangle: - pos: 0, 0 - size: self.width, self.height - - key_size: int( (3 * self.width - 16) / 56) - key_sep: int( self.key_size / 24) - key_pad_sep: int( self.key_size / 7) + 1 - - border: (self.width - self.key_size * 18 - self.key_sep * 16 - self.key_pad_sep)/ 2 - - mapping_height: self.key_size * 6 + self.key_sep * 5 - mapping_width: self.key_size * 18 + self.key_sep * 16 + self.key_pad_sep - mapping_x: self.border - mapping_y: self.top - self.mapping_height - self.border - - key_list_width: 4 * (mock_ubuntu_regular.width or 0) - key_list_height: self.height - self.mapping_height - 3 * self.border - key_list_x: (self.action_list_width or 0) + 2 * self.border - key_list_y: self.border - - action_list_height: self.height - self.mapping_height - 3 * self.border - action_list_width: 3 * self.width / 4 - self.key_list_width - self.border - action_list_x: self.border - action_list_y: self.border - - play_list_height: self.action_list_height - play_list_width: self.width - self.action_list_width - 3* self.border - play_list_y: self.border - play_list_x: self.action_list_width + self.key_list_width + 3 * self.border - - min_height: min(mock_symbola.height, mock_ubuntu_regular.height, mock_ubuntu_bold.height) - symbola_line_height: self.min_height / max(mock_symbola.height,1) - ubuntu_regular_line_height: self.min_height / max(mock_ubuntu_regular.height,1) - ubuntu_bold_line_height: self.min_height / max(mock_ubuntu_bold.height,1) - Label: - id: mock_symbola - font_name: "Symbola" - font_size: math.ceil(2 * math.sqrt(self.parent.key_size or 10)) - color: 0, 0, 0, 0 - text: "A" - text_size: None, None - size_hint: None, None - size: self.texture_size - Label: - id: mock_ubuntu_regular - font_name: "Ubuntu" - font_size: math.ceil(2 * math.sqrt(self.parent.key_size or 10)) - color: 0, 0, 0, 0 - text: "A" - text_size: None, None - size_hint: None, None - size: self.texture_size - Label: - id: mock_ubuntu_bold - font_name: "Ubuntu" - bold: True - font_size: math.ceil(2 * math.sqrt(self.parent.key_size or 10)) - color: 0, 0, 0, 0 - text: "A" - text_size: None, None - size_hint: None, None - size: self.texture_size - - Mapping: - id: Mapping - pos: self.parent.mapping_x, self.parent.mapping_y - size: self.parent.mapping_width, self.parent.mapping_height - - key_size: self.parent.key_size - key_sep: self.parent.key_sep - key_pad_sep: self.parent.key_pad_sep - pad_x: self.key_size * 15 + 14 * self.key_sep + self.key_pad_sep - ActionList: - id: ActionList - pos: self.parent.action_list_x, self.parent.action_list_y - size: self.parent.action_list_width, self.parent.action_list_height - KeyList: - id: KeyList - pos: self.parent.key_list_x, self.parent.key_list_y - size: self.parent.key_list_width, self.parent.key_list_height - PlayList: - id: PlayList - pos: self.parent.play_list_x, self.parent.play_list_y - size: self.parent.play_list_width, self.parent.play_list_height - -: - size_hint: None, None - canvas: - Color: - rgba: 250./255, 250./255, 250./255, 1 - Rectangle: - pos: 0, 0 - size: self.width, self.height - Label: - id: key_list_first - font_name: "Ubuntu" - bold: True - font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) - color: 0, 0, 0, 1 - text: self.parent.first_key - text_size: None, None - valign: "top" - halign: "center" - size_hint: None, None - size: self.parent.width, self.texture_size[1] - pos: 0, self.parent.height - self.height - Label: - id: key_list_second - font_name: "Ubuntu" - font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) - color: 0, 0, 0, 1 - text: self.parent.second_key - text_size: None, None - valign: "top" - halign: "center" - size_hint: None, None - size: self.parent.width, self.texture_size[1] - pos: 0, self.parent.height - key_list_first.height - self.height - Label: - id: key_list_third - font_name: "Ubuntu" - font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) - color: 0, 0, 0, 0.75 - text: self.parent.third_key - text_size: None, None - valign: "top" - halign: "center" - size_hint: None, None - size: self.parent.width, self.texture_size[1] - pos: 0, self.parent.height - key_list_first.height - key_list_second.height - self.height - Label: - id: key_list_rest - font_name: "Ubuntu" - font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) - color: 0, 0, 0, 0.5 - text: "\n".join(self.parent.keylist[3:]) - text_size: None, None - valign: "top" - halign: "center" - size_hint: None, None - size: self.parent.width, self.texture_size[1] - pos: 0, self.parent.height - key_list_first.height - key_list_second.height - key_list_third.height - self.height - -: - size_hint: None, None - canvas: - Color: - rgba: 250./255, 250./255, 250./255, 1 - Rectangle: - pos: 0, 0 - size: self.width, self.height - - Label: - id: action_list_title - font_name: "Ubuntu" - bold: True - font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) - color: 0, 0, 0, 1 - text: self.parent.action_title - text_size: None, self.parent.height - halign: "left" - valign: "top" - size_hint: None, None - size: self.texture_size[0], self.parent.height - Label: - id: action_list_icons - font_name: "Symbola" - font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) - line_height: self.parent.parent.symbola_line_height or 1 - color: 0, 0, 0, 1 - text: "\n".join(map(lambda x: x[0], self.parent.action_list)) - text_size: None, self.parent.height - halign: "left" - valign: "top" - size_hint: None, None - size: self.texture_size[0], self.parent.height - 3 * self.line_height * self.font_size - Label: - id: action_list_names - font_name: "Ubuntu" - font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) - line_height: self.parent.parent.ubuntu_regular_line_height or 1 - color: 0, 0, 0, 1 - text: "\n".join(map(lambda x: x[1], self.parent.action_list)) - text_size: None, self.parent.height - halign: "left" - valign: "top" - size_hint: None, None - pos: 15, self.y - size: self.texture_size[0], self.parent.height - 3 * self.line_height * self.font_size - -: - size_hint: None, None - canvas: - Color: - rgba: 250./255, 250./255, 250./255, 1 - Rectangle: - pos: 0, 0 - size: self.width, self.height - - Label: - id: playlist_icons - font_name: "Symbola" - font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) - line_height: self.parent.parent.symbola_line_height or 1 - color: 0, 0, 0, 1 - text: "\n".join(map(lambda x: x[0], self.parent.playlist)) - text_size: None, self.parent.height - halign: "left" - valign: "top" - size_hint: None, None - size: self.texture_size[0], self.parent.height - Label: - id: playlist_names - font_name: "Ubuntu" # FIXME: Mettre en gras quand c'est en cours - line_height: self.parent.parent.ubuntu_regular_line_height or 1 - font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) - color: 0, 0, 0, 1 - text: "\n".join(map(lambda x: x[1], self.parent.playlist)) - text_size: None, self.parent.height - halign: "left" - valign: "top" - size_hint: None, None - pos: 15, self.y - size: self.texture_size[0], self.parent.height - Label: - canvas.before: - Color: - rgba: 250./255, 250./255, 250./255, 1 - Rectangle: - pos: self.pos - size: self.width, self.height - id: playlist_times - font_name: "Ubuntu" - line_height: self.parent.parent.ubuntu_regular_line_height or 1 - font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) - color: 0, 0, 0, 1 - text: "\n".join(map(lambda x: x[2], self.parent.playlist)) - text_size: None, self.parent.height - halign: "left" - valign: "top" - size_hint: None, None - pos: self.parent.width - 3 * self.width / 2 - 2 * (self.parent.parent.border or 0), self.y - size: self.texture_size[0], self.parent.height - -: - size_hint: None, None - key_size: 48 - key_sep: 2 - key_pad_sep: 7 - pad_x: 755 - canvas: - Color: - rgba: 250./255, 250./255, 250./255, 1 - Rectangle: - pos: 0, 0 - size: self.width, self.height - Color: - rgba: self.ready_color - Ellipse: - pos: self.width - self.key_size / 2, self.height - self.key_size /2 - size: self.key_size / 3, self.key_size / 3 - Label: - font_name: "Ubuntu" - font_size: math.ceil(2 * math.sqrt(self.parent.key_size or 10)) - color: 0, 0, 0, 1 - text: "volume: {}%".format(self.parent.master_volume) - valign: "top" - size_hint: None, None - size: self.texture_size[0], self.texture_size[1] - x: self.parent.width - self.width - 2 * self.parent.key_size / 3 - center_y: self.parent.height - self.height - Key: - id: Key_27 - key_code: 27 - key_sym: "ESC" - row: 1 - col: 1 - Key: - id: Key_282 - key_code: 282 - key_sym: "F1" - row: 1 - col: 3 - Key: - id: Key_283 - key_code: 283 - key_sym: "F2" - row: 1 - col: 4 - Key: - id: Key_284 - key_code: 284 - key_sym: "F3" - row: 1 - col: 5 - Key: - id: Key_285 - key_code: 285 - key_sym: "F4" - row: 1 - col: 6 - - Key: - id: Key_286 - key_code: 286 - key_sym: "F5" - row: 1 - col: 7.5 - Key: - id: Key_287 - key_code: 287 - key_sym: "F6" - row: 1 - col: 8.5 - Key: - id: Key_288 - key_code: 288 - key_sym: "F7" - row: 1 - col: 9.5 - Key: - id: Key_289 - key_code: 289 - key_sym: "F8" - row: 1 - col: 10.5 - - Key: - id: Key_290 - key_code: 290 - key_sym: "F9" - row: 1 - col: 12 - Key: - id: Key_291 - key_code: 291 - key_sym: "F10" - row: 1 - col: 13 - Key: - id: Key_292 - key_code: 292 - key_sym: "F11" - row: 1 - col: 14 - Key: - id: Key_293 - key_code: 293 - key_sym: "F12" - row: 1 - col: 15 - - Key: - id: Key_178 - key_code: 178 - key_sym: "²" - row: 2 - col: 1 - Key: - id: Key_38 - key_code: 38 - key_sym: "&" - row: 2 - col: 2 - Key: - id: Key_233 - key_code: 233 - key_sym: "é" - row: 2 - col: 3 - Key: - id: Key_34 - key_code: 34 - key_sym: '"' - row: 2 - col: 4 - Key: - id: Key_39 - key_code: 39 - key_sym: "'" - row: 2 - col: 5 - Key: - id: Key_40 - key_code: 40 - key_sym: "(" - row: 2 - col: 6 - Key: - id: Key_45 - key_code: 45 - key_sym: "-" - row: 2 - col: 7 - Key: - id: Key_232 - key_code: 232 - key_sym: "è" - row: 2 - col: 8 - Key: - id: Key_95 - key_code: 95 - key_sym: "_" - row: 2 - col: 9 - Key: - id: Key_231 - key_code: 231 - key_sym: "ç" - row: 2 - col: 10 - Key: - id: Key_224 - key_code: 224 - key_sym: "à" - row: 2 - col: 11 - Key: - id: Key_41 - key_code: 41 - key_sym: ")" - row: 2 - col: 12 - Key: - id: Key_61 - key_code: 61 - key_sym: "=" - row: 2 - col: 13 - Key: - id: Key_8 - key_code: 8 - key_sym: "<-" - row: 2 - col: 14 - key_width: 2 - Key: - id: Key_9 - key_code: 9 - key_sym: "tab" - row: 3 - col: 1 - key_width: 1.48 - Key: - id: Key_97 - key_code: 97 - key_sym: "a" - row: 3 - col: 2.5 - Key: - id: Key_122 - key_code: 122 - key_sym: "z" - row: 3 - col: 3.5 - Key: - id: Key_101 - key_code: 101 - key_sym: "e" - row: 3 - col: 4.5 - Key: - id: Key_114 - key_code: 114 - key_sym: "r" - row: 3 - col: 5.5 - Key: - id: Key_116 - key_code: 116 - key_sym: "t" - row: 3 - col: 6.5 - Key: - id: Key_121 - key_code: 121 - key_sym: "y" - row: 3 - col: 7.5 - Key: - id: Key_117 - key_code: 117 - key_sym: "u" - row: 3 - col: 8.5 - Key: - id: Key_105 - key_code: 105 - key_sym: "i" - row: 3 - col: 9.5 - Key: - id: Key_111 - key_code: 111 - key_sym: "o" - row: 3 - col: 10.5 - Key: - id: Key_112 - key_code: 112 - key_sym: "p" - row: 3 - col: 11.5 - Key: - id: Key_94 - key_code: 94 - key_sym: "^" - row: 3 - col: 12.5 - Key: - id: Key_36 - key_code: 36 - key_sym: "$" - row: 3 - col: 13.5 - Key: - id: Key_13 - key_code: 13 - key_sym: "Enter" - row: 4 - col: 14.8 - key_width: 1.23 - key_height: 2 - Key: - id: Key_301 - key_code: 301 - key_sym: "CAPS" - row: 4 - col: 1 - key_width: 1.75 - line_width: 1 - enabled: False - - Key: - id: Key_113 - key_code: 113 - key_sym: "q" - row: 4 - col: 2.8 - Key: - id: Key_115 - key_code: 115 - key_sym: "s" - row: 4 - col: 3.8 - Key: - id: Key_100 - key_code: 100 - key_sym: "d" - row: 4 - col: 4.8 - Key: - id: Key_102 - key_code: 102 - key_sym: "f" - row: 4 - col: 5.8 - Key: - id: Key_103 - key_code: 103 - key_sym: "g" - row: 4 - col: 6.8 - Key: - id: Key_104 - key_code: 104 - key_sym: "h" - row: 4 - col: 7.8 - Key: - id: Key_106 - key_code: 106 - key_sym: "j" - row: 4 - col: 8.8 - Key: - id: Key_107 - key_code: 107 - key_sym: "k" - row: 4 - col: 9.8 - Key: - id: Key_108 - key_code: 108 - key_sym: "l" - row: 4 - col: 10.8 - Key: - id: Key_109 - key_code: 109 - key_sym: "m" - row: 4 - col: 11.8 - Key: - id: Key_249 - key_code: 249 - key_sym: "ù" - row: 4 - col: 12.8 - Key: - id: Key_42 - key_code: 42 - key_sym: "*" - row: 4 - col: 13.8 - Key: - id: Key_304 - key_code: 304 - key_sym: "LShift" - row: 5 - col: 1 - key_width: 1.3 - line_width: 1 - enabled: False - Key: - id: Key_60 - key_code: 60 - key_sym: "<" - row: 5 - col: 2.3 - Key: - id: Key_119 - key_code: 119 - key_sym: "w" - row: 5 - col: 3.3 - Key: - id: Key_120 - key_code: 120 - key_sym: "x" - row: 5 - col: 4.3 - Key: - id: Key_99 - key_code: 99 - key_sym: "c" - row: 5 - col: 5.3 - Key: - id: Key_118 - key_code: 118 - key_sym: "v" - row: 5 - col: 6.3 - Key: - id: Key_98 - key_code: 98 - key_sym: "b" - row: 5 - col: 7.3 - Key: - id: Key_110 - key_code: 110 - key_sym: "n" - row: 5 - col: 8.3 - Key: - id: Key_44 - key_code: 44 - key_sym: "," - row: 5 - col: 9.3 - Key: - id: Key_59 - key_code: 59 - key_sym: ";" - row: 5 - col: 10.3 - Key: - id: Key_58 - key_code: 58 - key_sym: ":" - row: 5 - col: 11.3 - Key: - id: Key_33 - key_code: 33 - key_sym: "!" - row: 5 - col: 12.3 - Key: - id: Key_303 - key_code: 303 - key_sym: "RShift" - row: 5 - col: 13.3 - key_width: 2.7 - line_width: 1 - enabled: False - Key: - id: Key_306 - key_code: 306 - key_sym: "LCtrl" - row: 6 - col: 1 - key_width: 1.3 - line_width: 1 - enabled: False - Key: - id: Key_311 - key_code: 311 - key_sym: "LSuper" - row: 6 - col: 3.3 - line_width: 1 - enabled: False - Key: - id: Key_308 - key_code: 308 - key_sym: "LAlt" - row: 6 - col: 4.3 - line_width: 1 - enabled: False - Key: - id: Key_32 - key_code: 32 - key_sym: "Espace" - row: 6 - col: 5.3 - key_width: 5 - Key: - id: Key_313 - key_code: 313 - key_sym: "AltGr" - row: 6 - col: 10.3 - line_width: 1 - enabled: False - Key: - id: Key_314 - key_code: 314 - key_sym: "Compose" - row: 6 - col: 11.3 - line_width: 1 - enabled: False - Key: - id: Key_305 - key_code: 305 - key_sym: "RCtrl" - row: 6 - col: 12.3 - key_width: 1.3 - line_width: 1 - enabled: False - - - Key: - id: Key_277 - key_code: 277 - key_sym: "ins" - row: 2 - col: 1 - pad_cols: True - Key: - id: Key_278 - key_code: 278 - key_sym: "home" - row: 2 - col: 2 - pad_cols: True - Key: - id: Key_280 - key_code: 280 - key_sym: "pg_u" - row: 2 - col: 3 - pad_cols: True - Key: - id: Key_127 - key_code: 127 - key_sym: "del" - row: 3 - col: 1 - pad_cols: True - Key: - id: Key_279 - key_code: 279 - key_sym: "end" - row: 3 - col: 2 - pad_cols: True - Key: - id: Key_281 - key_code: 281 - key_sym: "pg_d" - row: 3 - col: 3 - pad_cols: True - Key: - id: Key_273 - key_code: 273 - key_sym: "up" - row: 5 - col: 2 - pad_cols: True - Key: - id: Key_274 - key_code: 274 - key_sym: "down" - row: 6 - col: 2 - pad_cols: True - Key: - id: Key_276 - key_code: 276 - key_sym: "left" - row: 6 - col: 1 - pad_cols: True - Key: - id: Key_275 - key_code: 275 - key_sym: "right" - row: 6 - col: 3 - pad_cols: True diff --git a/music_sampler.py b/music_sampler.py deleted file mode 100644 index 714598a..0000000 --- a/music_sampler.py +++ /dev/null @@ -1,91 +0,0 @@ -import music_sampler - -music_sampler.parse_args() - -import kivy -kivy.require("1.9.1") -from kivy.app import App -from kivy.uix.floatlayout import FloatLayout -from kivy.uix.relativelayout import RelativeLayout -from kivy.properties import ListProperty, StringProperty -from kivy.clock import Clock -from kivy.core.window import Window -from kivy.lang import Builder -from music_sampler.key import Key -from music_sampler.mapping import Mapping - -music_sampler.register_fonts() - -class KeyList(RelativeLayout): - keylist = ListProperty([]) - first_key = StringProperty("") - second_key = StringProperty("") - third_key = StringProperty("") - - def append(self, value): - self.keylist.insert(0, value) - - def on_keylist(self, instance, new_key_list): - if len(self.keylist) > 0: - self.first_key = self.keylist[0] - if len(self.keylist) > 1: - self.second_key = self.keylist[1] - if len(self.keylist) > 2: - self.third_key = self.keylist[2] - -class PlayList(RelativeLayout): - playlist = ListProperty([]) - - def __init__(self, **kwargs): - super(PlayList, self).__init__(**kwargs) - Clock.schedule_interval(self.update_playlist, 0.5) - - def update_playlist(self, dt): - if self.parent is None or 'Mapping' not in self.parent.ids: - return True - - open_files = self.parent.ids['Mapping'].open_files - self.playlist = [] - for music_file in open_files.values(): - if not music_file.is_in_use(): - continue - - text = "{}/{}".format( - music_sampler.duration_to_min_sec(music_file.sound_position), - music_sampler.duration_to_min_sec(music_file.sound_duration)) - - if music_file.is_loaded_paused(): - self.playlist.append(["⏸", music_file.name, text, False]) - else: - self.playlist.append(["⏵", music_file.name, text, True]) - - -class ActionList(RelativeLayout): - action_title = StringProperty("") - action_list = ListProperty([]) - - def update_list(self, key, action_descriptions): - self.action_title = "actions linked to key {}:".format(key.key_sym) - self.action_list = [] - - for [action, status] in action_descriptions: - if status == "done": - icon = "✓" - elif status == "current": - icon = "✅" - else: - icon = " " - self.action_list.append([icon, action]) - -class Screen(FloatLayout): - pass - -class MusicSamplerApp(App): - def build(self): - Window.size = (913, 563) - - return Screen() - -if __name__ == '__main__': - Builder.load_file(music_sampler.path() + "/music_sampler.kv") - MusicSamplerApp().run() diff --git a/music_sampler.spec b/music_sampler.spec index 3794397..791cd68 100644 --- a/music_sampler.spec +++ b/music_sampler.spec @@ -28,11 +28,11 @@ pyinstaller_file.write(commit_message) pyinstaller_file.close() data = [ - ('music_sampler.kv', '.'), + ('music_sampler/music_sampler.kv', '.'), ('.pyinstaller_commit', '.') ] -a = Analysis(['music_sampler.py'], +a = Analysis(['run.py'], binaries=None, datas=data, hookspath=hookspath(), diff --git a/music_sampler/__init__.py b/music_sampler/__init__.py index 4827e6c..aa551fb 100644 --- a/music_sampler/__init__.py +++ b/music_sampler/__init__.py @@ -1,192 +1 @@ -# -*- coding: utf-8 -*- -import argparse -import sys -import os -import math -import sounddevice as sd -import logging - -from . import sysfont - -class Config: - pass - -def find_font(name, style=sysfont.STYLE_NONE): - if getattr(sys, 'frozen', False): - font = sys._MEIPASS + "/fonts/{}_{}.ttf".format(name, style) - else: - font = sysfont.get_font(name, style=style) - if font is not None: - font = font[4] - return font - -def register_fonts(): - from kivy.core.text import LabelBase - - ubuntu_regular = find_font("Ubuntu", style=sysfont.STYLE_NORMAL) - ubuntu_bold = find_font("Ubuntu", style=sysfont.STYLE_BOLD) - symbola = find_font("Symbola") - - if ubuntu_regular is None: - error_print("Font Ubuntu regular could not be found, please install it.") - sys.exit() - if symbola is None: - error_print("Font Symbola could not be found, please install it.") - sys.exit() - if ubuntu_bold is None: - warn_print("Font Ubuntu Bold could not be found.") - - LabelBase.register(name="Ubuntu", - fn_regular=ubuntu_regular, - fn_bold=ubuntu_bold) - LabelBase.register(name="Symbola", - fn_regular=symbola) - - -def path(): - if getattr(sys, 'frozen', False): - return sys._MEIPASS + "/" - else: - path = os.path.dirname(os.path.realpath(__file__)) - return path + "/../" - -def parse_args(): - argv = sys.argv[1 :] - sys.argv = sys.argv[: 1] - if "--" in argv: - index = argv.index("--") - kivy_args = argv[index+1 :] - argv = argv[: index] - - sys.argv.extend(kivy_args) - - parser = argparse.ArgumentParser( - description="A Music Sampler application.", - formatter_class=argparse.ArgumentDefaultsHelpFormatter) - parser.add_argument("-c", "--config", - default="config.yml", - required=False, - help="Config file to load") - parser.add_argument("-p", "--music-path", - default=".", - required=False, - help="Folder in which to find the music files") - parser.add_argument("-d", "--debug", - nargs=0, - action=DebugModeAction, - help="Print messages in console") - parser.add_argument("-m", "--builtin-mixing", - action="store_true", - help="Make the mixing of sounds manually\ - (do it if the system cannot handle it correctly)") - parser.add_argument("-l", "--latency", - default="high", - required=False, - help="Latency: low, high or number of seconds") - parser.add_argument("-b", "--blocksize", - default=0, - type=int, - required=False, - help="Blocksize: If not 0, the number of frames to take\ - at each step for the mixer") - parser.add_argument("-f", "--frame-rate", - default=44100, - type=int, - required=False, - help="Frame rate to play the musics") - parser.add_argument("-x", "--channels", - default=2, - type=int, - required=False, - help="Number of channels to use") - parser.add_argument("-s", "--sample-width", - default=2, - type=int, - required=False, - help="Sample width (number of bytes for each frame)") - parser.add_argument("-V", "--version", - action="version", - help="Displays the current version and exits. Only use\ - in bundled package", - version=show_version()) - parser.add_argument("--device", - action=SelectDeviceAction, - help="Select this sound device" - ) - parser.add_argument("--list-devices", - nargs=0, - action=ListDevicesAction, - help="List available sound devices" - ) - parser.add_argument('--', - dest="args", - help="Kivy arguments. All arguments after this are interpreted\ - by Kivy. Pass \"-- --help\" to get Kivy's usage.") - - from kivy.logger import Logger - Logger.setLevel(logging.WARN) - - args = parser.parse_args(argv) - - Config.yml_file = args.config - - Config.latency = args.latency - Config.blocksize = args.blocksize - Config.frame_rate = args.frame_rate - Config.channels = args.channels - Config.sample_width = args.sample_width - Config.builtin_mixing = args.builtin_mixing - if args.music_path.endswith("/"): - Config.music_path = args.music_path - else: - Config.music_path = args.music_path + "/" - -class DebugModeAction(argparse.Action): - def __call__(self, parser, namespace, values, option_string=None): - from kivy.logger import Logger - Logger.setLevel(logging.DEBUG) - -class SelectDeviceAction(argparse.Action): - def __call__(self, parser, namespace, values, option_string=None): - sd.default.device = values - -class ListDevicesAction(argparse.Action): - nargs = 0 - def __call__(self, parser, namespace, values, option_string=None): - print(sd.query_devices()) - sys.exit() - -def show_version(): - if getattr(sys, 'frozen', False): - with open(path() + ".pyinstaller_commit", "r") as f: - return f.read() - else: - return "option '-v' can only be used in bundled package" - -def duration_to_min_sec(duration): - minutes = int(duration / 60) - seconds = int(duration) % 60 - if minutes < 100: - return "{:2}:{:0>2}".format(minutes, seconds) - else: - return "{}:{:0>2}".format(minutes, seconds) - -def gain(volume, old_volume=None): - if old_volume is None: - return 20 * math.log10(max(volume, 0.1) / 100) - else: - return [ - 20 * math.log10(max(volume, 0.1) / max(old_volume, 0.1)), - max(volume, 0)] - -def debug_print(message, with_trace=False): - from kivy.logger import Logger - Logger.debug('MusicSampler: ' + message, exc_info=with_trace) - -def error_print(message, with_trace=False): - from kivy.logger import Logger - Logger.error('MusicSampler: ' + message, exc_info=with_trace) - -def warn_print(message, with_trace=False): - from kivy.logger import Logger - Logger.warn('MusicSampler: ' + message, exc_info=with_trace) +from . import app diff --git a/music_sampler/action.py b/music_sampler/action.py index 4b5a71d..ef56b7c 100644 --- a/music_sampler/action.py +++ b/music_sampler/action.py @@ -1,5 +1,5 @@ from transitions.extensions import HierarchicalMachine as Machine -from . import debug_print, error_print +from .helpers import debug_print, error_print from . import actions class Action: diff --git a/music_sampler/app.py b/music_sampler/app.py new file mode 100644 index 0000000..81c47a7 --- /dev/null +++ b/music_sampler/app.py @@ -0,0 +1,91 @@ +from .helpers import parse_args, register_fonts, duration_to_min_sec, path + +parse_args() + +import kivy +kivy.require("1.9.1") +from kivy.app import App +from kivy.uix.floatlayout import FloatLayout +from kivy.uix.relativelayout import RelativeLayout +from kivy.properties import ListProperty, StringProperty +from kivy.clock import Clock +from kivy.core.window import Window +from kivy.lang import Builder +from .key import Key +from .mapping import Mapping + +register_fonts() + +class KeyList(RelativeLayout): + keylist = ListProperty([]) + first_key = StringProperty("") + second_key = StringProperty("") + third_key = StringProperty("") + + def append(self, value): + self.keylist.insert(0, value) + + def on_keylist(self, instance, new_key_list): + if len(self.keylist) > 0: + self.first_key = self.keylist[0] + if len(self.keylist) > 1: + self.second_key = self.keylist[1] + if len(self.keylist) > 2: + self.third_key = self.keylist[2] + +class PlayList(RelativeLayout): + playlist = ListProperty([]) + + def __init__(self, **kwargs): + super(PlayList, self).__init__(**kwargs) + Clock.schedule_interval(self.update_playlist, 0.5) + + def update_playlist(self, dt): + if self.parent is None or 'Mapping' not in self.parent.ids: + return True + + open_files = self.parent.ids['Mapping'].open_files + self.playlist = [] + for music_file in open_files.values(): + if not music_file.is_in_use(): + continue + + text = "{}/{}".format( + duration_to_min_sec(music_file.sound_position), + duration_to_min_sec(music_file.sound_duration)) + + if music_file.is_loaded_paused(): + self.playlist.append(["⏸", music_file.name, text, False]) + else: + self.playlist.append(["⏵", music_file.name, text, True]) + + +class ActionList(RelativeLayout): + action_title = StringProperty("") + action_list = ListProperty([]) + + def update_list(self, key, action_descriptions): + self.action_title = "actions linked to key {}:".format(key.key_sym) + self.action_list = [] + + for [action, status] in action_descriptions: + if status == "done": + icon = "✓" + elif status == "current": + icon = "✅" + else: + icon = " " + self.action_list.append([icon, action]) + +class Screen(FloatLayout): + pass + +class MusicSamplerApp(App): + def build(self): + Window.size = (913, 563) + + return Screen() + +def main(): + Builder.load_file(path() + "/music_sampler.kv") + MusicSamplerApp().run() diff --git a/music_sampler/helpers.py b/music_sampler/helpers.py new file mode 100644 index 0000000..1788084 --- /dev/null +++ b/music_sampler/helpers.py @@ -0,0 +1,192 @@ +# -*- coding: utf-8 -*- +import argparse +import sys +import os +import math +import sounddevice as sd +import logging + +from . import sysfont + +class Config: + pass + +def find_font(name, style=sysfont.STYLE_NONE): + if getattr(sys, 'frozen', False): + font = sys._MEIPASS + "/fonts/{}_{}.ttf".format(name, style) + else: + font = sysfont.get_font(name, style=style) + if font is not None: + font = font[4] + return font + +def register_fonts(): + from kivy.core.text import LabelBase + + ubuntu_regular = find_font("Ubuntu", style=sysfont.STYLE_NORMAL) + ubuntu_bold = find_font("Ubuntu", style=sysfont.STYLE_BOLD) + symbola = find_font("Symbola") + + if ubuntu_regular is None: + error_print("Font Ubuntu regular could not be found, please install it.") + sys.exit() + if symbola is None: + error_print("Font Symbola could not be found, please install it.") + sys.exit() + if ubuntu_bold is None: + warn_print("Font Ubuntu Bold could not be found.") + + LabelBase.register(name="Ubuntu", + fn_regular=ubuntu_regular, + fn_bold=ubuntu_bold) + LabelBase.register(name="Symbola", + fn_regular=symbola) + + +def path(): + if getattr(sys, 'frozen', False): + return sys._MEIPASS + "/" + else: + return os.path.dirname(os.path.realpath(__file__)) + +def parse_args(): + argv = sys.argv[1 :] + sys.argv = sys.argv[: 1] + if "--" in argv: + index = argv.index("--") + kivy_args = argv[index+1 :] + argv = argv[: index] + + sys.argv.extend(kivy_args) + + parser = argparse.ArgumentParser( + description="A Music Sampler application.", + formatter_class=argparse.ArgumentDefaultsHelpFormatter) + parser.add_argument("-c", "--config", + default="config.yml", + required=False, + help="Config file to load") + parser.add_argument("-p", "--music-path", + default=".", + required=False, + help="Folder in which to find the music files") + parser.add_argument("-d", "--debug", + nargs=0, + action=DebugModeAction, + help="Print messages in console") + parser.add_argument("-m", "--builtin-mixing", + action="store_true", + help="Make the mixing of sounds manually\ + (do it if the system cannot handle it correctly)") + parser.add_argument("-l", "--latency", + default="high", + required=False, + help="Latency: low, high or number of seconds") + parser.add_argument("-b", "--blocksize", + default=0, + type=int, + required=False, + help="Blocksize: If not 0, the number of frames to take\ + at each step for the mixer") + parser.add_argument("-f", "--frame-rate", + default=44100, + type=int, + required=False, + help="Frame rate to play the musics") + parser.add_argument("-x", "--channels", + default=2, + type=int, + required=False, + help="Number of channels to use") + parser.add_argument("-s", "--sample-width", + default=2, + type=int, + required=False, + help="Sample width (number of bytes for each frame)") + parser.add_argument("-V", "--version", + action="version", + help="Displays the current version and exits. Only use\ + in bundled package", + version=show_version()) + parser.add_argument("--device", + action=SelectDeviceAction, + help="Select this sound device" + ) + parser.add_argument("--list-devices", + nargs=0, + action=ListDevicesAction, + help="List available sound devices" + ) + parser.add_argument('--', + dest="args", + help="Kivy arguments. All arguments after this are interpreted\ + by Kivy. Pass \"-- --help\" to get Kivy's usage.") + + from kivy.logger import Logger + Logger.setLevel(logging.WARN) + + args = parser.parse_args(argv) + + Config.yml_file = args.config + + Config.latency = args.latency + Config.blocksize = args.blocksize + Config.frame_rate = args.frame_rate + Config.channels = args.channels + Config.sample_width = args.sample_width + Config.builtin_mixing = args.builtin_mixing + if args.music_path.endswith("/"): + Config.music_path = args.music_path + else: + Config.music_path = args.music_path + "/" + +class DebugModeAction(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + from kivy.logger import Logger + Logger.setLevel(logging.DEBUG) + +class SelectDeviceAction(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + sd.default.device = values + +class ListDevicesAction(argparse.Action): + nargs = 0 + def __call__(self, parser, namespace, values, option_string=None): + print(sd.query_devices()) + sys.exit() + +def show_version(): + if getattr(sys, 'frozen', False): + with open(path() + ".pyinstaller_commit", "r") as f: + return f.read() + else: + return "option '-v' can only be used in bundled package" + +def duration_to_min_sec(duration): + minutes = int(duration / 60) + seconds = int(duration) % 60 + if minutes < 100: + return "{:2}:{:0>2}".format(minutes, seconds) + else: + return "{}:{:0>2}".format(minutes, seconds) + +def gain(volume, old_volume=None): + if old_volume is None: + return 20 * math.log10(max(volume, 0.1) / 100) + else: + return [ + 20 * math.log10(max(volume, 0.1) / max(old_volume, 0.1)), + max(volume, 0)] + +def debug_print(message, with_trace=False): + from kivy.logger import Logger + Logger.debug('MusicSampler: ' + message, exc_info=with_trace) + +def error_print(message, with_trace=False): + from kivy.logger import Logger + Logger.error('MusicSampler: ' + message, exc_info=with_trace) + +def warn_print(message, with_trace=False): + from kivy.logger import Logger + Logger.warn('MusicSampler: ' + message, exc_info=with_trace) + diff --git a/music_sampler/key.py b/music_sampler/key.py index 66e792d..b05de4c 100644 --- a/music_sampler/key.py +++ b/music_sampler/key.py @@ -4,7 +4,7 @@ from kivy.properties import AliasProperty, BooleanProperty, \ from kivy.uix.behaviors import ButtonBehavior from .action import Action -from . import debug_print +from .helpers import debug_print import time import threading from transitions.extensions import HierarchicalMachine as Machine diff --git a/music_sampler/lock.py b/music_sampler/lock.py index 9beafcd..5befe33 100644 --- a/music_sampler/lock.py +++ b/music_sampler/lock.py @@ -1,6 +1,6 @@ import threading -from . import debug_print +from .helpers import debug_print class Lock: def __init__(self, lock_type): diff --git a/music_sampler/mapping.py b/music_sampler/mapping.py index bb20e67..ca471ef 100644 --- a/music_sampler/mapping.py +++ b/music_sampler/mapping.py @@ -12,7 +12,7 @@ from transitions.extensions import HierarchicalMachine as Machine from .music_file import MusicFile from .mixer import Mixer -from . import Config, gain, error_print, warn_print +from .helpers import Config, gain, error_print, warn_print from .action import Action class Mapping(RelativeLayout): diff --git a/music_sampler/mixer.py b/music_sampler/mixer.py index 9242b61..c8ec907 100644 --- a/music_sampler/mixer.py +++ b/music_sampler/mixer.py @@ -2,7 +2,7 @@ import sounddevice as sd import audioop import time -from . import Config +from .helpers import Config sample_width = Config.sample_width diff --git a/music_sampler/music_file.py b/music_sampler/music_file.py index 2d3ba72..fa6293d 100644 --- a/music_sampler/music_file.py +++ b/music_sampler/music_file.py @@ -8,7 +8,7 @@ import os.path import audioop from .lock import Lock -from . import Config, gain, debug_print, error_print +from .helpers import Config, gain, debug_print, error_print from .mixer import Mixer from .music_effect import GainEffect diff --git a/music_sampler/music_sampler.kv b/music_sampler/music_sampler.kv new file mode 100644 index 0000000..9057532 --- /dev/null +++ b/music_sampler/music_sampler.kv @@ -0,0 +1,900 @@ +#:import math math +#:import h music_sampler + +: + pad_col_sep: 0 if not self.pad_cols else self.parent.pad_x + pad_cols: False + + y: (self.parent.top-self.parent.y) - (self.row) * self.parent.key_size - (self.row - 1) * self.parent.key_sep + x: (self.col - 1) * self.parent.key_size + int(self.col - 1) * self.parent.key_sep + self.pad_col_sep + size_hint: None, None + enabled: True + line_width: 2 + row: 1 + col: 0 + key_code: 0 + key_sym: "" + key_width: 1 + key_height: 1 + width: self.key_width * (self.parent.key_size + self.parent.key_sep) - self.parent.key_sep + height: self.key_height * (self.parent.key_size + self.parent.key_sep) - self.parent.key_sep + canvas.before: + Color: + rgba: self.color + RoundedRectangle: + pos: self.x, self.y + size: self.size + canvas: + Color: + rgba: self.line_color + Line: + rounded_rectangle: self.x + self.line_width, self.y + self.line_width, self.width - 2 * self.line_width, self.height - 2 * self.line_width, 10 + width: self.line_width + Color: + rgba: self.line_cross_color + Line: + points: self.x + self.line_width + 3, self.y + self.line_width + 3, self.x + self.width - 2 * self.line_width - 3, self.y + self.height - 2 * self.line_width - 3 + width: self.line_width + Line: + points: self.x + self.line_width + 3, self.y + self.height - 2 * self.line_width - 3, self.x + self.width - 2 * self.line_width - 3, self.y + self.line_width + 3 + width: self.line_width + Label: + id: key_label + font_name: "Ubuntu" + bold: True + font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size)) + color: 0, 0, 0, 1 + text: self.parent.key_sym + text_size: self.parent.width,self.font_size + shorten: True + shorten_from: "right" + split_str: "" + center_x: self.parent.x + self.texture_size[0] /2 + 5 + center_y: self.parent.y + self.parent.height - self.texture_size[1] /2 - 5 + Label: + id: key_description_title + font_name: "Ubuntu" + font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size / 2)) + color: 0, 0, 0, 1 + text: self.parent.description_title + text_size: self.parent.width - 2*self.parent.line_width, self.font_size + halign: "right" + valign: "middle" + center_x: self.parent.x + self.texture_size[0] /2 + center_y: self.parent.y + self.parent.height - self.texture_size[1] /2 - 5 + Label: + id: key_description + font_name: "Ubuntu" + font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size / 2)) + color: 0, 0, 0, 1 + text: "\n".join(self.parent.description) + text_size: 2 * self.parent.width,self.parent.height - key_label.font_size + halign: "left" + valign: "middle" + pos: self.parent.x + 2 * self.parent.line_width + 2, self.parent.y + size_hint: None, None + size: 2 * self.parent.width - 2 * self.parent.line_width, self.parent.height - key_label.font_size + +: + canvas: + Color: + rgba: 229/255, 228/255, 226/255, 1 + Rectangle: + pos: 0, 0 + size: self.width, self.height + + key_size: int( (3 * self.width - 16) / 56) + key_sep: int( self.key_size / 24) + key_pad_sep: int( self.key_size / 7) + 1 + + border: (self.width - self.key_size * 18 - self.key_sep * 16 - self.key_pad_sep)/ 2 + + mapping_height: self.key_size * 6 + self.key_sep * 5 + mapping_width: self.key_size * 18 + self.key_sep * 16 + self.key_pad_sep + mapping_x: self.border + mapping_y: self.top - self.mapping_height - self.border + + key_list_width: 4 * (mock_ubuntu_regular.width or 0) + key_list_height: self.height - self.mapping_height - 3 * self.border + key_list_x: (self.action_list_width or 0) + 2 * self.border + key_list_y: self.border + + action_list_height: self.height - self.mapping_height - 3 * self.border + action_list_width: 3 * self.width / 4 - self.key_list_width - self.border + action_list_x: self.border + action_list_y: self.border + + play_list_height: self.action_list_height + play_list_width: self.width - self.action_list_width - 3* self.border + play_list_y: self.border + play_list_x: self.action_list_width + self.key_list_width + 3 * self.border + + min_height: min(mock_symbola.height, mock_ubuntu_regular.height, mock_ubuntu_bold.height) + symbola_line_height: self.min_height / max(mock_symbola.height,1) + ubuntu_regular_line_height: self.min_height / max(mock_ubuntu_regular.height,1) + ubuntu_bold_line_height: self.min_height / max(mock_ubuntu_bold.height,1) + Label: + id: mock_symbola + font_name: "Symbola" + font_size: math.ceil(2 * math.sqrt(self.parent.key_size or 10)) + color: 0, 0, 0, 0 + text: "A" + text_size: None, None + size_hint: None, None + size: self.texture_size + Label: + id: mock_ubuntu_regular + font_name: "Ubuntu" + font_size: math.ceil(2 * math.sqrt(self.parent.key_size or 10)) + color: 0, 0, 0, 0 + text: "A" + text_size: None, None + size_hint: None, None + size: self.texture_size + Label: + id: mock_ubuntu_bold + font_name: "Ubuntu" + bold: True + font_size: math.ceil(2 * math.sqrt(self.parent.key_size or 10)) + color: 0, 0, 0, 0 + text: "A" + text_size: None, None + size_hint: None, None + size: self.texture_size + + Mapping: + id: Mapping + pos: self.parent.mapping_x, self.parent.mapping_y + size: self.parent.mapping_width, self.parent.mapping_height + + key_size: self.parent.key_size + key_sep: self.parent.key_sep + key_pad_sep: self.parent.key_pad_sep + pad_x: self.key_size * 15 + 14 * self.key_sep + self.key_pad_sep + ActionList: + id: ActionList + pos: self.parent.action_list_x, self.parent.action_list_y + size: self.parent.action_list_width, self.parent.action_list_height + KeyList: + id: KeyList + pos: self.parent.key_list_x, self.parent.key_list_y + size: self.parent.key_list_width, self.parent.key_list_height + PlayList: + id: PlayList + pos: self.parent.play_list_x, self.parent.play_list_y + size: self.parent.play_list_width, self.parent.play_list_height + +: + size_hint: None, None + canvas: + Color: + rgba: 250./255, 250./255, 250./255, 1 + Rectangle: + pos: 0, 0 + size: self.width, self.height + Label: + id: key_list_first + font_name: "Ubuntu" + bold: True + font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) + color: 0, 0, 0, 1 + text: self.parent.first_key + text_size: None, None + valign: "top" + halign: "center" + size_hint: None, None + size: self.parent.width, self.texture_size[1] + pos: 0, self.parent.height - self.height + Label: + id: key_list_second + font_name: "Ubuntu" + font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) + color: 0, 0, 0, 1 + text: self.parent.second_key + text_size: None, None + valign: "top" + halign: "center" + size_hint: None, None + size: self.parent.width, self.texture_size[1] + pos: 0, self.parent.height - key_list_first.height - self.height + Label: + id: key_list_third + font_name: "Ubuntu" + font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) + color: 0, 0, 0, 0.75 + text: self.parent.third_key + text_size: None, None + valign: "top" + halign: "center" + size_hint: None, None + size: self.parent.width, self.texture_size[1] + pos: 0, self.parent.height - key_list_first.height - key_list_second.height - self.height + Label: + id: key_list_rest + font_name: "Ubuntu" + font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) + color: 0, 0, 0, 0.5 + text: "\n".join(self.parent.keylist[3:]) + text_size: None, None + valign: "top" + halign: "center" + size_hint: None, None + size: self.parent.width, self.texture_size[1] + pos: 0, self.parent.height - key_list_first.height - key_list_second.height - key_list_third.height - self.height + +: + size_hint: None, None + canvas: + Color: + rgba: 250./255, 250./255, 250./255, 1 + Rectangle: + pos: 0, 0 + size: self.width, self.height + + Label: + id: action_list_title + font_name: "Ubuntu" + bold: True + font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) + color: 0, 0, 0, 1 + text: self.parent.action_title + text_size: None, self.parent.height + halign: "left" + valign: "top" + size_hint: None, None + size: self.texture_size[0], self.parent.height + Label: + id: action_list_icons + font_name: "Symbola" + font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) + line_height: self.parent.parent.symbola_line_height or 1 + color: 0, 0, 0, 1 + text: "\n".join(map(lambda x: x[0], self.parent.action_list)) + text_size: None, self.parent.height + halign: "left" + valign: "top" + size_hint: None, None + size: self.texture_size[0], self.parent.height - 3 * self.line_height * self.font_size + Label: + id: action_list_names + font_name: "Ubuntu" + font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) + line_height: self.parent.parent.ubuntu_regular_line_height or 1 + color: 0, 0, 0, 1 + text: "\n".join(map(lambda x: x[1], self.parent.action_list)) + text_size: None, self.parent.height + halign: "left" + valign: "top" + size_hint: None, None + pos: 15, self.y + size: self.texture_size[0], self.parent.height - 3 * self.line_height * self.font_size + +: + size_hint: None, None + canvas: + Color: + rgba: 250./255, 250./255, 250./255, 1 + Rectangle: + pos: 0, 0 + size: self.width, self.height + + Label: + id: playlist_icons + font_name: "Symbola" + font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) + line_height: self.parent.parent.symbola_line_height or 1 + color: 0, 0, 0, 1 + text: "\n".join(map(lambda x: x[0], self.parent.playlist)) + text_size: None, self.parent.height + halign: "left" + valign: "top" + size_hint: None, None + size: self.texture_size[0], self.parent.height + Label: + id: playlist_names + font_name: "Ubuntu" # FIXME: Mettre en gras quand c'est en cours + line_height: self.parent.parent.ubuntu_regular_line_height or 1 + font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) + color: 0, 0, 0, 1 + text: "\n".join(map(lambda x: x[1], self.parent.playlist)) + text_size: None, self.parent.height + halign: "left" + valign: "top" + size_hint: None, None + pos: 15, self.y + size: self.texture_size[0], self.parent.height + Label: + canvas.before: + Color: + rgba: 250./255, 250./255, 250./255, 1 + Rectangle: + pos: self.pos + size: self.width, self.height + id: playlist_times + font_name: "Ubuntu" + line_height: self.parent.parent.ubuntu_regular_line_height or 1 + font_size: math.ceil(2 * math.sqrt(self.parent.parent.key_size or 10)) + color: 0, 0, 0, 1 + text: "\n".join(map(lambda x: x[2], self.parent.playlist)) + text_size: None, self.parent.height + halign: "left" + valign: "top" + size_hint: None, None + pos: self.parent.width - 3 * self.width / 2 - 2 * (self.parent.parent.border or 0), self.y + size: self.texture_size[0], self.parent.height + +: + size_hint: None, None + key_size: 48 + key_sep: 2 + key_pad_sep: 7 + pad_x: 755 + canvas: + Color: + rgba: 250./255, 250./255, 250./255, 1 + Rectangle: + pos: 0, 0 + size: self.width, self.height + Color: + rgba: self.ready_color + Ellipse: + pos: self.width - self.key_size / 2, self.height - self.key_size /2 + size: self.key_size / 3, self.key_size / 3 + Label: + font_name: "Ubuntu" + font_size: math.ceil(2 * math.sqrt(self.parent.key_size or 10)) + color: 0, 0, 0, 1 + text: "volume: {}%".format(self.parent.master_volume) + valign: "top" + size_hint: None, None + size: self.texture_size[0], self.texture_size[1] + x: self.parent.width - self.width - 2 * self.parent.key_size / 3 + center_y: self.parent.height - self.height + Key: + id: Key_27 + key_code: 27 + key_sym: "ESC" + row: 1 + col: 1 + Key: + id: Key_282 + key_code: 282 + key_sym: "F1" + row: 1 + col: 3 + Key: + id: Key_283 + key_code: 283 + key_sym: "F2" + row: 1 + col: 4 + Key: + id: Key_284 + key_code: 284 + key_sym: "F3" + row: 1 + col: 5 + Key: + id: Key_285 + key_code: 285 + key_sym: "F4" + row: 1 + col: 6 + + Key: + id: Key_286 + key_code: 286 + key_sym: "F5" + row: 1 + col: 7.5 + Key: + id: Key_287 + key_code: 287 + key_sym: "F6" + row: 1 + col: 8.5 + Key: + id: Key_288 + key_code: 288 + key_sym: "F7" + row: 1 + col: 9.5 + Key: + id: Key_289 + key_code: 289 + key_sym: "F8" + row: 1 + col: 10.5 + + Key: + id: Key_290 + key_code: 290 + key_sym: "F9" + row: 1 + col: 12 + Key: + id: Key_291 + key_code: 291 + key_sym: "F10" + row: 1 + col: 13 + Key: + id: Key_292 + key_code: 292 + key_sym: "F11" + row: 1 + col: 14 + Key: + id: Key_293 + key_code: 293 + key_sym: "F12" + row: 1 + col: 15 + + Key: + id: Key_178 + key_code: 178 + key_sym: "²" + row: 2 + col: 1 + Key: + id: Key_38 + key_code: 38 + key_sym: "&" + row: 2 + col: 2 + Key: + id: Key_233 + key_code: 233 + key_sym: "é" + row: 2 + col: 3 + Key: + id: Key_34 + key_code: 34 + key_sym: '"' + row: 2 + col: 4 + Key: + id: Key_39 + key_code: 39 + key_sym: "'" + row: 2 + col: 5 + Key: + id: Key_40 + key_code: 40 + key_sym: "(" + row: 2 + col: 6 + Key: + id: Key_45 + key_code: 45 + key_sym: "-" + row: 2 + col: 7 + Key: + id: Key_232 + key_code: 232 + key_sym: "è" + row: 2 + col: 8 + Key: + id: Key_95 + key_code: 95 + key_sym: "_" + row: 2 + col: 9 + Key: + id: Key_231 + key_code: 231 + key_sym: "ç" + row: 2 + col: 10 + Key: + id: Key_224 + key_code: 224 + key_sym: "à" + row: 2 + col: 11 + Key: + id: Key_41 + key_code: 41 + key_sym: ")" + row: 2 + col: 12 + Key: + id: Key_61 + key_code: 61 + key_sym: "=" + row: 2 + col: 13 + Key: + id: Key_8 + key_code: 8 + key_sym: "<-" + row: 2 + col: 14 + key_width: 2 + Key: + id: Key_9 + key_code: 9 + key_sym: "tab" + row: 3 + col: 1 + key_width: 1.48 + Key: + id: Key_97 + key_code: 97 + key_sym: "a" + row: 3 + col: 2.5 + Key: + id: Key_122 + key_code: 122 + key_sym: "z" + row: 3 + col: 3.5 + Key: + id: Key_101 + key_code: 101 + key_sym: "e" + row: 3 + col: 4.5 + Key: + id: Key_114 + key_code: 114 + key_sym: "r" + row: 3 + col: 5.5 + Key: + id: Key_116 + key_code: 116 + key_sym: "t" + row: 3 + col: 6.5 + Key: + id: Key_121 + key_code: 121 + key_sym: "y" + row: 3 + col: 7.5 + Key: + id: Key_117 + key_code: 117 + key_sym: "u" + row: 3 + col: 8.5 + Key: + id: Key_105 + key_code: 105 + key_sym: "i" + row: 3 + col: 9.5 + Key: + id: Key_111 + key_code: 111 + key_sym: "o" + row: 3 + col: 10.5 + Key: + id: Key_112 + key_code: 112 + key_sym: "p" + row: 3 + col: 11.5 + Key: + id: Key_94 + key_code: 94 + key_sym: "^" + row: 3 + col: 12.5 + Key: + id: Key_36 + key_code: 36 + key_sym: "$" + row: 3 + col: 13.5 + Key: + id: Key_13 + key_code: 13 + key_sym: "Enter" + row: 4 + col: 14.8 + key_width: 1.23 + key_height: 2 + Key: + id: Key_301 + key_code: 301 + key_sym: "CAPS" + row: 4 + col: 1 + key_width: 1.75 + line_width: 1 + enabled: False + + Key: + id: Key_113 + key_code: 113 + key_sym: "q" + row: 4 + col: 2.8 + Key: + id: Key_115 + key_code: 115 + key_sym: "s" + row: 4 + col: 3.8 + Key: + id: Key_100 + key_code: 100 + key_sym: "d" + row: 4 + col: 4.8 + Key: + id: Key_102 + key_code: 102 + key_sym: "f" + row: 4 + col: 5.8 + Key: + id: Key_103 + key_code: 103 + key_sym: "g" + row: 4 + col: 6.8 + Key: + id: Key_104 + key_code: 104 + key_sym: "h" + row: 4 + col: 7.8 + Key: + id: Key_106 + key_code: 106 + key_sym: "j" + row: 4 + col: 8.8 + Key: + id: Key_107 + key_code: 107 + key_sym: "k" + row: 4 + col: 9.8 + Key: + id: Key_108 + key_code: 108 + key_sym: "l" + row: 4 + col: 10.8 + Key: + id: Key_109 + key_code: 109 + key_sym: "m" + row: 4 + col: 11.8 + Key: + id: Key_249 + key_code: 249 + key_sym: "ù" + row: 4 + col: 12.8 + Key: + id: Key_42 + key_code: 42 + key_sym: "*" + row: 4 + col: 13.8 + Key: + id: Key_304 + key_code: 304 + key_sym: "LShift" + row: 5 + col: 1 + key_width: 1.3 + line_width: 1 + enabled: False + Key: + id: Key_60 + key_code: 60 + key_sym: "<" + row: 5 + col: 2.3 + Key: + id: Key_119 + key_code: 119 + key_sym: "w" + row: 5 + col: 3.3 + Key: + id: Key_120 + key_code: 120 + key_sym: "x" + row: 5 + col: 4.3 + Key: + id: Key_99 + key_code: 99 + key_sym: "c" + row: 5 + col: 5.3 + Key: + id: Key_118 + key_code: 118 + key_sym: "v" + row: 5 + col: 6.3 + Key: + id: Key_98 + key_code: 98 + key_sym: "b" + row: 5 + col: 7.3 + Key: + id: Key_110 + key_code: 110 + key_sym: "n" + row: 5 + col: 8.3 + Key: + id: Key_44 + key_code: 44 + key_sym: "," + row: 5 + col: 9.3 + Key: + id: Key_59 + key_code: 59 + key_sym: ";" + row: 5 + col: 10.3 + Key: + id: Key_58 + key_code: 58 + key_sym: ":" + row: 5 + col: 11.3 + Key: + id: Key_33 + key_code: 33 + key_sym: "!" + row: 5 + col: 12.3 + Key: + id: Key_303 + key_code: 303 + key_sym: "RShift" + row: 5 + col: 13.3 + key_width: 2.7 + line_width: 1 + enabled: False + Key: + id: Key_306 + key_code: 306 + key_sym: "LCtrl" + row: 6 + col: 1 + key_width: 1.3 + line_width: 1 + enabled: False + Key: + id: Key_311 + key_code: 311 + key_sym: "LSuper" + row: 6 + col: 3.3 + line_width: 1 + enabled: False + Key: + id: Key_308 + key_code: 308 + key_sym: "LAlt" + row: 6 + col: 4.3 + line_width: 1 + enabled: False + Key: + id: Key_32 + key_code: 32 + key_sym: "Espace" + row: 6 + col: 5.3 + key_width: 5 + Key: + id: Key_313 + key_code: 313 + key_sym: "AltGr" + row: 6 + col: 10.3 + line_width: 1 + enabled: False + Key: + id: Key_314 + key_code: 314 + key_sym: "Compose" + row: 6 + col: 11.3 + line_width: 1 + enabled: False + Key: + id: Key_305 + key_code: 305 + key_sym: "RCtrl" + row: 6 + col: 12.3 + key_width: 1.3 + line_width: 1 + enabled: False + + + Key: + id: Key_277 + key_code: 277 + key_sym: "ins" + row: 2 + col: 1 + pad_cols: True + Key: + id: Key_278 + key_code: 278 + key_sym: "home" + row: 2 + col: 2 + pad_cols: True + Key: + id: Key_280 + key_code: 280 + key_sym: "pg_u" + row: 2 + col: 3 + pad_cols: True + Key: + id: Key_127 + key_code: 127 + key_sym: "del" + row: 3 + col: 1 + pad_cols: True + Key: + id: Key_279 + key_code: 279 + key_sym: "end" + row: 3 + col: 2 + pad_cols: True + Key: + id: Key_281 + key_code: 281 + key_sym: "pg_d" + row: 3 + col: 3 + pad_cols: True + Key: + id: Key_273 + key_code: 273 + key_sym: "up" + row: 5 + col: 2 + pad_cols: True + Key: + id: Key_274 + key_code: 274 + key_sym: "down" + row: 6 + col: 2 + pad_cols: True + Key: + id: Key_276 + key_code: 276 + key_sym: "left" + row: 6 + col: 1 + pad_cols: True + Key: + id: Key_275 + key_code: 275 + key_sym: "right" + row: 6 + col: 3 + pad_cols: True diff --git a/run.py b/run.py new file mode 100644 index 0000000..b486c50 --- /dev/null +++ b/run.py @@ -0,0 +1,3 @@ +import music_sampler + +music_sampler.app.main() diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..a4cdb3c --- /dev/null +++ b/setup.py @@ -0,0 +1,40 @@ +from setuptools import setup + +def readme(): + with open('README') as f: + return f.read() + +setup(name='music_sampler', + setup_requires=['setuptools_scm'], + use_scm_version=True, + description='A music player which associates each key on the keyboard ' + 'to a set of actions to run', + long_description=readme(), + classifiers= [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: End Users/Desktop', + 'License :: OSI Approved :: MIT License', + 'Operating System :: POSIX :: Linux', + 'Programming Language :: Python :: 3.5', + 'Topic :: Multimedia :: Sound/Audio :: Players' + ], + keywords='music sampler keyboard', + url='https://git.immae.eu/?p=perso/Immae/Projets/Python/MusicSampler.git', + author='Ismaël Bouya', + author_email='ismael.bouya@normalesup.org', + license='MIT', + packages=['music_sampler', 'music_sampler.actions'], + install_requires=[ + 'Kivy>=1.9.1', + 'pydub>=0.16.4', + 'Pygame>=1.9.2.dev1', + 'sounddevice>=0.3.3', + 'TRANSITIONS>=0.4.1', + 'PyYAML>=3.11' + ], + entry_points={ + 'console_scripts': ['music_sampler=music_sampler.app:main'], + }, + include_package_data=True, + zip_safe=False) + -- cgit v1.2.3