diff options
-rw-r--r-- | config.yml | 375 | ||||
-rw-r--r-- | documentation_en.md | 3 | ||||
-rw-r--r-- | documentation_fr.md | 3 | ||||
-rw-r--r-- | music_sampler/mapping.py | 100 |
4 files changed, 228 insertions, 253 deletions
@@ -82,52 +82,83 @@ key_properties: | |||
82 | - | 82 | - |
83 | - Music 1 | 83 | - Music 1 |
84 | include: light_blue | 84 | include: light_blue |
85 | actions: | ||
86 | - play: | ||
87 | include: music1 | ||
88 | # Play the songs | ||
85 | 'z': | 89 | 'z': |
86 | description: | 90 | description: |
87 | - | 91 | - |
88 | - Music 2 | 92 | - Music 2 |
89 | include: light_blue | 93 | include: light_blue |
94 | actions: | ||
95 | - play: | ||
96 | include: music2 | ||
90 | 'e': | 97 | 'e': |
91 | description: | 98 | description: |
92 | - | 99 | - |
93 | - Noise | 100 | - Noise |
94 | include: light_blue | 101 | include: light_blue |
102 | actions: | ||
103 | - play: | ||
104 | include: noise | ||
105 | # Load the songs | ||
95 | 'q': | 106 | 'q': |
96 | description: | 107 | description: |
97 | - | 108 | - |
98 | - Load | 109 | - Load |
99 | - Music 1 | 110 | - Music 1 |
100 | include: light_blue | 111 | include: light_blue |
112 | actions: | ||
113 | - load_music: | ||
114 | include: music1 | ||
101 | 's': | 115 | 's': |
102 | description: | 116 | description: |
103 | - | 117 | - |
104 | - Load | 118 | - Load |
105 | - Music 2 | 119 | - Music 2 |
106 | include: light_blue | 120 | include: light_blue |
121 | actions: | ||
122 | - load_music: | ||
123 | include: music2 | ||
107 | 'd': | 124 | 'd': |
108 | description: | 125 | description: |
109 | - | 126 | - |
110 | - Load | 127 | - Load |
111 | - Noise | 128 | - Noise |
112 | include: light_blue | 129 | include: light_blue |
130 | actions: | ||
131 | - load_music: | ||
132 | include: noise | ||
133 | # Unload the songs | ||
113 | 'w': | 134 | 'w': |
114 | description: | 135 | description: |
115 | - | 136 | - |
116 | - Unload | 137 | - Unload |
117 | - Music 1 | 138 | - Music 1 |
118 | include: light_blue | 139 | include: light_blue |
140 | actions: | ||
141 | - unload_music: | ||
142 | include: music1 | ||
119 | 'x': | 143 | 'x': |
120 | description: | 144 | description: |
121 | - | 145 | - |
122 | - Unload | 146 | - Unload |
123 | - Music 2 | 147 | - Music 2 |
124 | include: light_blue | 148 | include: light_blue |
149 | actions: | ||
150 | - unload_music: | ||
151 | include: music2 | ||
125 | 'c': | 152 | 'c': |
126 | description: | 153 | description: |
127 | - | 154 | - |
128 | - Unload | 155 | - Unload |
129 | - Noise | 156 | - Noise |
130 | include: light_blue | 157 | include: light_blue |
158 | actions: | ||
159 | - unload_music: | ||
160 | include: noise | ||
161 | # Crossfade from any music to music 2 | ||
131 | 't': | 162 | 't': |
132 | description: | 163 | description: |
133 | - | 164 | - |
@@ -135,27 +166,70 @@ key_properties: | |||
135 | - music 2 | 166 | - music 2 |
136 | include: green | 167 | include: green |
137 | repeat_delay: 5 | 168 | repeat_delay: 5 |
169 | actions: | ||
170 | - stop: | ||
171 | fade_out: 5 | ||
172 | - play: | ||
173 | include: music2 | ||
174 | fade_in: 5 | ||
175 | # Fade out, then wait and start music 2 | ||
138 | 'y': | 176 | 'y': |
139 | description: | 177 | description: |
140 | - | 178 | - |
141 | - Stop wait | 179 | - Stop wait |
142 | - music 2 | 180 | - music 2 |
143 | include: green | 181 | include: green |
182 | actions: | ||
183 | - wait: | ||
184 | include: music2 | ||
144 | 185 | ||
186 | # Play music 1, starting at 30 seconds then seeks at 60 after 5 seconds | ||
145 | 'g': | 187 | 'g': |
146 | description: | 188 | description: |
147 | - | 189 | - |
148 | - Music 1 | 190 | - Music 1 |
149 | - Seek 30/60 | 191 | - Seek 30/60 |
150 | include: purple | 192 | include: purple |
193 | actions: | ||
194 | - play: | ||
195 | include: music1 | ||
196 | start_at: 30 | ||
197 | - wait: | ||
198 | duration: 5 | ||
199 | - seek: | ||
200 | include: music1 | ||
201 | delta: false | ||
202 | value: 60 | ||
151 | 203 | ||
204 | # Lowers the volume of music 1 and 2 (if playing), during the duration of noise + 1 second | ||
152 | 'i': | 205 | 'i': |
153 | description: | 206 | description: |
154 | - | 207 | - |
155 | - Noise | 208 | - Noise |
156 | - +low vol | 209 | - +low vol |
157 | include: green | 210 | include: green |
211 | actions: | ||
212 | - volume: | ||
213 | include: music1 | ||
214 | value: 50 | ||
215 | - volume: | ||
216 | include: music2 | ||
217 | value: 50 | ||
218 | - play: | ||
219 | include: noise | ||
220 | - wait: | ||
221 | include: noise | ||
222 | duration: 1 | ||
223 | - volume: | ||
224 | include: music1 | ||
225 | value: 100 | ||
226 | fade: 1 | ||
227 | - volume: | ||
228 | include: music2 | ||
229 | value: 100 | ||
230 | fade: 1 | ||
158 | 231 | ||
232 | # Stops all musics, then plays noise repeated twice (3 times) | ||
159 | 'h': | 233 | 'h': |
160 | description: | 234 | description: |
161 | - | 235 | - |
@@ -163,48 +237,102 @@ key_properties: | |||
163 | - 3 times | 237 | - 3 times |
164 | include: purple | 238 | include: purple |
165 | repeat_delay: 2 | 239 | repeat_delay: 2 |
240 | actions: | ||
241 | - stop: | ||
242 | fade_out: 0.5 | ||
243 | - play: | ||
244 | include: noise | ||
245 | loop: 2 | ||
166 | 246 | ||
247 | # Play music 1 and 2, after stopping all musics with a fade_out (and wait for this fade out) | ||
167 | 'm': | 248 | 'm': |
168 | description: | 249 | description: |
169 | - | 250 | - |
170 | - Musics | 251 | - Musics |
171 | - 1 & 2 | 252 | - 1 & 2 |
172 | include: purple | 253 | include: purple |
254 | actions: | ||
255 | - stop: | ||
256 | fade_out: 2 | ||
257 | wait: true | ||
258 | - play: | ||
259 | include: music1 | ||
260 | - wait: | ||
261 | include: music1 | ||
262 | set_wait_id: m | ||
263 | - play: | ||
264 | include: music2 | ||
173 | 265 | ||
266 | # Lowers the volume of music 1 and 2 (if playing) down to 10% with a 5 seconds fade, then back to 100% | ||
174 | 'n': | 267 | 'n': |
175 | description: | 268 | description: |
176 | - | 269 | - |
177 | - Low vol | 270 | - Low vol |
178 | - Up vol | 271 | - Up vol |
179 | include: green | 272 | include: green |
273 | actions: | ||
274 | - volume: | ||
275 | include: music1 | ||
276 | value: 10 | ||
277 | fade: 5 | ||
278 | - volume: | ||
279 | include: music2 | ||
280 | value: 10 | ||
281 | fade: 5 | ||
282 | - wait: | ||
283 | duration: 5 | ||
284 | - volume: | ||
285 | include: music1 | ||
286 | value: 100 | ||
287 | fade: 5 | ||
288 | - volume: | ||
289 | include: music2 | ||
290 | value: 100 | ||
291 | fade: 5 | ||
292 | # skip waiting for the end of music1 | ||
180 | 'ù': | 293 | 'ù': |
181 | description: | 294 | description: |
182 | - | 295 | - |
183 | - stop | 296 | - stop |
184 | - wait | 297 | - wait |
298 | actions: | ||
299 | - interrupt_wait: | ||
300 | wait_id: m | ||
185 | 301 | ||
186 | 'home': | 302 | 'home': |
187 | description: | 303 | description: |
188 | - | 304 | - |
189 | - vlc | 305 | - vlc |
190 | include: orange | 306 | include: orange |
307 | actions: | ||
308 | - run_command: | ||
309 | command: vlc *.mp3 | ||
310 | wait: true | ||
191 | 311 | ||
192 | 312 | ||
193 | ## Some general useful keys | 313 | ## Some general useful keys |
194 | 314 | ||
315 | # Emergency stop! | ||
195 | 'ESC': | 316 | 'ESC': |
196 | description: | 317 | description: |
197 | - "!" | 318 | - "!" |
198 | - STOP! | 319 | - STOP! |
199 | include: red | 320 | include: red |
200 | repeat_delay: 0 | 321 | repeat_delay: 0 |
322 | actions: | ||
323 | - stop_all_actions: | ||
324 | other_only: true | ||
325 | - stop: | ||
201 | 326 | ||
327 | # Pause and unpause | ||
202 | 'F5': | 328 | 'F5': |
203 | description: | 329 | description: |
204 | - "||" | 330 | - "||" |
205 | - PAUSE | 331 | - PAUSE |
206 | include: light_green | 332 | include: light_green |
207 | repeat_delay: 0 | 333 | repeat_delay: 0 |
334 | actions: | ||
335 | - pause: | ||
208 | 336 | ||
209 | 'F6': | 337 | 'F6': |
210 | description: | 338 | description: |
@@ -212,7 +340,10 @@ key_properties: | |||
212 | - UNPAUSE | 340 | - UNPAUSE |
213 | include: light_green | 341 | include: light_green |
214 | repeat_delay: 0 | 342 | repeat_delay: 0 |
343 | actions: | ||
344 | - unpause: | ||
215 | 345 | ||
346 | # Stopping all musics, with a short fade (sounds natural) | ||
216 | 'F1': | 347 | 'F1': |
217 | description: | 348 | description: |
218 | - | 349 | - |
@@ -220,7 +351,11 @@ key_properties: | |||
220 | - fade | 351 | - fade |
221 | include: orange | 352 | include: orange |
222 | repeat_delay: 0 | 353 | repeat_delay: 0 |
354 | actions: | ||
355 | - stop: | ||
356 | fade_out: 1 | ||
223 | 357 | ||
358 | # Stopping all actions | ||
224 | 'F2': | 359 | 'F2': |
225 | description: | 360 | description: |
226 | - | 361 | - |
@@ -228,7 +363,10 @@ key_properties: | |||
228 | - actions | 363 | - actions |
229 | include: orange | 364 | include: orange |
230 | repeat_delay: 0 | 365 | repeat_delay: 0 |
366 | actions: | ||
367 | - stop_all_actions: | ||
231 | 368 | ||
369 | # Skip wait | ||
232 | 'F4': | 370 | 'F4': |
233 | description: | 371 | description: |
234 | - | 372 | - |
@@ -236,29 +374,45 @@ key_properties: | |||
236 | - wait | 374 | - wait |
237 | include: pink | 375 | include: pink |
238 | repeat_delay: 0 | 376 | repeat_delay: 0 |
377 | actions: | ||
378 | - interrupt_wait: | ||
239 | 379 | ||
240 | 'F8': | 380 | 'F8': |
241 | description: | 381 | description: |
242 | - | 382 | - |
243 | - Pause | 383 | - Pause |
244 | - wait | 384 | - wait |
385 | actions: | ||
386 | - pause_wait: | ||
387 | |||
245 | 'F9': | 388 | 'F9': |
246 | description: | 389 | description: |
247 | - | 390 | - |
248 | - Unpause | 391 | - Unpause |
249 | - wait | 392 | - wait |
393 | actions: | ||
394 | - unpause_wait: | ||
395 | |||
250 | 'F10': | 396 | 'F10': |
251 | description: | 397 | description: |
252 | - | 398 | - |
253 | - Reset | 399 | - Reset |
254 | - wait | 400 | - wait |
401 | actions: | ||
402 | - reset_wait: | ||
255 | 403 | ||
404 | # Changing volume | ||
256 | 'F12': | 405 | 'F12': |
257 | description: | 406 | description: |
258 | - | 407 | - |
259 | - vol+ | 408 | - vol+ |
260 | include: yellow | 409 | include: yellow |
261 | repeat_delay: 0 | 410 | repeat_delay: 0 |
411 | actions: | ||
412 | - volume: | ||
413 | delta: true | ||
414 | value: +10 | ||
415 | fade: 0.5 | ||
262 | 416 | ||
263 | 'F11': | 417 | 'F11': |
264 | description: | 418 | description: |
@@ -266,13 +420,23 @@ key_properties: | |||
266 | - "vol-" | 420 | - "vol-" |
267 | include: yellow | 421 | include: yellow |
268 | repeat_delay: 0 | 422 | repeat_delay: 0 |
269 | 423 | actions: | |
424 | - volume: | ||
425 | delta: true | ||
426 | value: -10 | ||
427 | fade: 0.5 | ||
428 | |||
429 | # Seek +- 10 seconds | ||
270 | 'right': | 430 | 'right': |
271 | description: | 431 | description: |
272 | - | 432 | - |
273 | - +10s | 433 | - +10s |
274 | include: blue | 434 | include: blue |
275 | repeat_delay: 0 | 435 | repeat_delay: 0 |
436 | actions: | ||
437 | - seek: | ||
438 | value: 10 | ||
439 | delta: true | ||
276 | 440 | ||
277 | 'left': | 441 | 'left': |
278 | description: | 442 | description: |
@@ -280,208 +444,7 @@ key_properties: | |||
280 | - -10s | 444 | - -10s |
281 | include: blue | 445 | include: blue |
282 | repeat_delay: 0 | 446 | repeat_delay: 0 |
283 | 447 | actions: | |
284 | ################################################################# | 448 | - seek: |
285 | ##### Keys: what do the key actually do when you press them ##### | 449 | value: -10 |
286 | 450 | delta: true | |
287 | keys: | ||
288 | # Play the songs | ||
289 | 'a': | ||
290 | - play: | ||
291 | include: music1 | ||
292 | 'z': | ||
293 | - play: | ||
294 | include: music2 | ||
295 | 'e': | ||
296 | - play: | ||
297 | include: noise | ||
298 | |||
299 | # Load the songs | ||
300 | 'q': | ||
301 | - load_music: | ||
302 | include: music1 | ||
303 | 's': | ||
304 | - load_music: | ||
305 | include: music2 | ||
306 | 'd': | ||
307 | - load_music: | ||
308 | include: noise | ||
309 | |||
310 | # Unload the songs | ||
311 | 'w': | ||
312 | - unload_music: | ||
313 | include: music1 | ||
314 | 'x': | ||
315 | - unload_music: | ||
316 | include: music2 | ||
317 | 'c': | ||
318 | - unload_music: | ||
319 | include: noise | ||
320 | |||
321 | # Crossfade from any music to music 2 | ||
322 | 't': | ||
323 | - stop: | ||
324 | fade_out: 5 | ||
325 | - play: | ||
326 | include: music2 | ||
327 | fade_in: 5 | ||
328 | |||
329 | # Fade out, then wait and start music 2 | ||
330 | 'y': | ||
331 | - wait: | ||
332 | include: music2 | ||
333 | |||
334 | # Play the noise, stop music 1, wait a bit then start music 2 | ||
335 | |||
336 | # Play music 1, starting at 30 seconds then seeks at 60 after 5 seconds | ||
337 | 'g': | ||
338 | - play: | ||
339 | include: music1 | ||
340 | start_at: 30 | ||
341 | - wait: | ||
342 | duration: 5 | ||
343 | - seek: | ||
344 | include: music1 | ||
345 | delta: false | ||
346 | value: 60 | ||
347 | |||
348 | # Play music 1 and 2, after stopping all musics with a fade_out (and wait for this fade out) | ||
349 | 'm': | ||
350 | - stop: | ||
351 | fade_out: 2 | ||
352 | wait: true | ||
353 | - play: | ||
354 | include: music1 | ||
355 | - wait: | ||
356 | include: music1 | ||
357 | set_wait_id: m | ||
358 | - play: | ||
359 | include: music2 | ||
360 | |||
361 | # skip waiting for the end of music1 | ||
362 | 'ù': | ||
363 | - interrupt_wait: | ||
364 | wait_id: m | ||
365 | |||
366 | # Lowers the volume of music 1 and 2 (if playing), during the duration of noise + 1 second | ||
367 | 'i': | ||
368 | - volume: | ||
369 | include: music1 | ||
370 | value: 50 | ||
371 | - volume: | ||
372 | include: music2 | ||
373 | value: 50 | ||
374 | - play: | ||
375 | include: noise | ||
376 | - wait: | ||
377 | include: noise | ||
378 | duration: 1 | ||
379 | - volume: | ||
380 | include: music1 | ||
381 | value: 100 | ||
382 | fade: 1 | ||
383 | - volume: | ||
384 | include: music2 | ||
385 | value: 100 | ||
386 | fade: 1 | ||
387 | |||
388 | # Lowers the volume of music 1 and 2 (if playing) down to 10% with a 5 seconds fade, then back to 100% | ||
389 | 'n' : | ||
390 | - volume: | ||
391 | include: music1 | ||
392 | value: 10 | ||
393 | fade: 5 | ||
394 | - volume: | ||
395 | include: music2 | ||
396 | value: 10 | ||
397 | fade: 5 | ||
398 | - wait: | ||
399 | duration: 5 | ||
400 | - volume: | ||
401 | include: music1 | ||
402 | value: 100 | ||
403 | fade: 5 | ||
404 | - volume: | ||
405 | include: music2 | ||
406 | value: 100 | ||
407 | fade: 5 | ||
408 | |||
409 | # Stops all musics, then plays noise repeated twice (3 times) | ||
410 | 'h': | ||
411 | - stop: | ||
412 | fade_out: 0.5 | ||
413 | - play: | ||
414 | include: noise | ||
415 | loop: 2 | ||
416 | |||
417 | 'home': | ||
418 | - run_command: | ||
419 | command: vlc *.mp3 | ||
420 | wait: true | ||
421 | |||
422 | |||
423 | ##### Useful keys (good to have them all the time) | ||
424 | |||
425 | # Emergency stop! | ||
426 | 'ESC': | ||
427 | - stop_all_actions: | ||
428 | other_only: true | ||
429 | - stop: | ||
430 | |||
431 | |||
432 | |||
433 | # Pause and unpause | ||
434 | 'F5': | ||
435 | - pause: | ||
436 | |||
437 | 'F6': | ||
438 | - unpause: | ||
439 | |||
440 | # Stopping all musics, with a short fade (sounds natural) | ||
441 | 'F1': | ||
442 | - stop: | ||
443 | fade_out: 1 | ||
444 | |||
445 | # Stopping all actions | ||
446 | 'F2': | ||
447 | - stop_all_actions: | ||
448 | |||
449 | # Skip wait | ||
450 | 'F4': | ||
451 | - interrupt_wait: | ||
452 | |||
453 | 'F8': | ||
454 | - pause_wait: | ||
455 | |||
456 | 'F9': | ||
457 | - unpause_wait: | ||
458 | |||
459 | 'F10': | ||
460 | - reset_wait: | ||
461 | |||
462 | # Changing volume | ||
463 | 'F12': | ||
464 | - volume: | ||
465 | delta: true | ||
466 | value: +10 | ||
467 | fade: 0.5 | ||
468 | |||
469 | 'F11': | ||
470 | - volume: | ||
471 | delta: true | ||
472 | value: -10 | ||
473 | fade: 0.5 | ||
474 | |||
475 | |||
476 | # Seek +- 10 seconds | ||
477 | 'right': | ||
478 | - seek: | ||
479 | value: 10 | ||
480 | delta: true | ||
481 | |||
482 | 'left': | ||
483 | - seek: | ||
484 | value: -10 | ||
485 | delta: true | ||
486 | |||
487 | |||
diff --git a/documentation_en.md b/documentation_en.md index e92b85c..ac12909 100644 --- a/documentation_en.md +++ b/documentation_en.md | |||
@@ -225,6 +225,7 @@ protected for 2 seconds after each stroke. | |||
225 | - `repeat_delay: x` (default 0) : protection delay. Once all its actions are | 225 | - `repeat_delay: x` (default 0) : protection delay. Once all its actions are |
226 | done, the key will remain disabled (semi-transparent and crossed) for that | 226 | done, the key will remain disabled (semi-transparent and crossed) for that |
227 | amount of time (in seconds). | 227 | amount of time (in seconds). |
228 | - `actions: list`: List of actions to run with the key. | ||
228 | 229 | ||
229 | #### `common` key property | 230 | #### `common` key property |
230 | 231 | ||
@@ -237,6 +238,8 @@ This section lets you describe for each key, the list of actions associated to | |||
237 | it. Note that except for `wait` and some particular cases (see below), all the | 238 | it. Note that except for `wait` and some particular cases (see below), all the |
238 | actions are almost instantaneous. | 239 | actions are almost instantaneous. |
239 | 240 | ||
241 | *This section is deprecated and replaced by an `actions` key containing a list | ||
242 | in `key_properties` section for each key.* | ||
240 | 243 | ||
241 | #### Examples | 244 | #### Examples |
242 | 245 | ||
diff --git a/documentation_fr.md b/documentation_fr.md index cc2bf8f..d7d2f2c 100644 --- a/documentation_fr.md +++ b/documentation_fr.md | |||
@@ -247,6 +247,7 @@ secondes d'intervalle, le second appui est ignoré. | |||
247 | - `repeat_delay: x` (par défaut : 0) : délai de "sécurité" en cas d'appuis | 247 | - `repeat_delay: x` (par défaut : 0) : délai de "sécurité" en cas d'appuis |
248 | successifs sur la touche. La touche est désactivée (grisée et barrée) pendant | 248 | successifs sur la touche. La touche est désactivée (grisée et barrée) pendant |
249 | toute la durée des actions puis le délai de x secondes. | 249 | toute la durée des actions puis le délai de x secondes. |
250 | - `actions: liste`: Liste des actions à effectuer en appuyant sur la touche. | ||
250 | 251 | ||
251 | ### Propriété `common` | 252 | ### Propriété `common` |
252 | 253 | ||
@@ -259,6 +260,8 @@ Cette section sert à décrire, pour chaque touche, la liste des actions | |||
259 | successives. Notez que la plupart des actions (hors `wait` et quelques cas | 260 | successives. Notez que la plupart des actions (hors `wait` et quelques cas |
260 | particuliers, voir plus bas) sont quasi-instantanées. | 261 | particuliers, voir plus bas) sont quasi-instantanées. |
261 | 262 | ||
263 | *Cette section est obsolète et remplacée par une clé `actions` contenant une | ||
264 | liste dans la section `key_properties` pour chaque touche.* | ||
262 | 265 | ||
263 | #### Exemples | 266 | #### Exemples |
264 | 267 | ||
diff --git a/music_sampler/mapping.py b/music_sampler/mapping.py index a526ad2..193f5e5 100644 --- a/music_sampler/mapping.py +++ b/music_sampler/mapping.py | |||
@@ -320,13 +320,60 @@ class Mapping(RelativeLayout): | |||
320 | else: | 320 | else: |
321 | return {} | 321 | return {} |
322 | 322 | ||
323 | def check_mapped_key(mapped_keys, key): | 323 | def check_mapped_key(actions, key): |
324 | if not isinstance(mapped_keys[key], list): | 324 | if not isinstance(actions, list): |
325 | warn_print("key config '{}' is not an array, ignored" | 325 | warn_print("key config '{}' is not an array, ignored" |
326 | .format(key)) | 326 | .format(key)) |
327 | return [] | 327 | return [] |
328 | else: | 328 | else: |
329 | return mapped_keys[key] | 329 | return actions |
330 | |||
331 | def append_actions_to_key(mapped_key, actions, aliases, seen_files, music_properties, key_properties): | ||
332 | for index, action in enumerate(check_mapped_key(actions, mapped_key)): | ||
333 | if not isinstance(action, dict) or\ | ||
334 | not len(action) == 1 or\ | ||
335 | not isinstance(list(action.values())[0] or {}, dict): | ||
336 | warn_print("action number {} of key '{}' is invalid, " | ||
337 | "ignored".format(index + 1, mapped_key)) | ||
338 | continue | ||
339 | append_action_to_key(action, mapped_key, aliases, seen_files, music_properties, key_properties) | ||
340 | |||
341 | def append_action_to_key(action, mapped_key, aliases, seen_files, music_properties, key_properties): | ||
342 | action_name = list(action)[0] | ||
343 | action_args = {} | ||
344 | if action[action_name] is None: | ||
345 | action[action_name] = {} | ||
346 | |||
347 | include_aliases(action[action_name], aliases) | ||
348 | |||
349 | for argument in action[action_name]: | ||
350 | if argument == 'file': | ||
351 | filename = str(action[action_name]['file']) | ||
352 | if filename not in seen_files: | ||
353 | music_property = check_music_property( | ||
354 | music_properties[filename], | ||
355 | filename) | ||
356 | |||
357 | if filename in self.open_files: | ||
358 | self.open_files[filename]\ | ||
359 | .reload_properties(**music_property) | ||
360 | |||
361 | seen_files[filename] =\ | ||
362 | self.open_files[filename] | ||
363 | else: | ||
364 | seen_files[filename] = MusicFile( | ||
365 | filename, self, **music_property) | ||
366 | |||
367 | if filename not in key_properties[mapped_key]['files']: | ||
368 | key_properties[mapped_key]['files'] \ | ||
369 | .append(seen_files[filename]) | ||
370 | |||
371 | action_args['music'] = seen_files[filename] | ||
372 | else: | ||
373 | action_args[argument] = action[action_name][argument] | ||
374 | |||
375 | key_properties[mapped_key]['actions'] \ | ||
376 | .append([action_name, action_args]) | ||
330 | 377 | ||
331 | def check_music_property(music_property, filename): | 378 | def check_music_property(music_property, filename): |
332 | if not isinstance(music_property, dict): | 379 | if not isinstance(music_property, dict): |
@@ -400,52 +447,11 @@ class Mapping(RelativeLayout): | |||
400 | check_key_property(key_prop, key) | 447 | check_key_property(key_prop, key) |
401 | 448 | ||
402 | key_properties[key]["properties"].update(key_prop) | 449 | key_properties[key]["properties"].update(key_prop) |
450 | if 'actions' in key_prop: | ||
451 | append_actions_to_key(key, key_prop['actions'], aliases, seen_files, music_properties, key_properties) | ||
403 | 452 | ||
404 | for mapped_key in check_mapped_keys(config): | 453 | for mapped_key in check_mapped_keys(config): |
405 | for index, action in enumerate(check_mapped_key( | 454 | append_actions_to_key(mapped_key, config['keys'][mapped_key], aliases, seen_files, music_properties, key_properties) |
406 | config['keys'], mapped_key)): | ||
407 | if not isinstance(action, dict) or\ | ||
408 | not len(action) == 1 or\ | ||
409 | not isinstance(list(action.values())[0] or {}, dict): | ||
410 | warn_print("action number {} of key '{}' is invalid, " | ||
411 | "ignored".format(index + 1, mapped_key)) | ||
412 | continue | ||
413 | |||
414 | action_name = list(action)[0] | ||
415 | action_args = {} | ||
416 | if action[action_name] is None: | ||
417 | action[action_name] = {} | ||
418 | |||
419 | include_aliases(action[action_name], aliases) | ||
420 | |||
421 | for argument in action[action_name]: | ||
422 | if argument == 'file': | ||
423 | filename = str(action[action_name]['file']) | ||
424 | if filename not in seen_files: | ||
425 | music_property = check_music_property( | ||
426 | music_properties[filename], | ||
427 | filename) | ||
428 | |||
429 | if filename in self.open_files: | ||
430 | self.open_files[filename]\ | ||
431 | .reload_properties(**music_property) | ||
432 | |||
433 | seen_files[filename] =\ | ||
434 | self.open_files[filename] | ||
435 | else: | ||
436 | seen_files[filename] = MusicFile( | ||
437 | filename, self, **music_property) | ||
438 | |||
439 | if filename not in key_properties[mapped_key]['files']: | ||
440 | key_properties[mapped_key]['files'] \ | ||
441 | .append(seen_files[filename]) | ||
442 | |||
443 | action_args['music'] = seen_files[filename] | ||
444 | else: | ||
445 | action_args[argument] = action[action_name][argument] | ||
446 | |||
447 | key_properties[mapped_key]['actions'] \ | ||
448 | .append([action_name, action_args]) | ||
449 | 455 | ||
450 | return (key_properties, seen_files) | 456 | return (key_properties, seen_files) |
451 | 457 | ||