aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.yml106
-rw-r--r--helpers/__init__.py13
-rw-r--r--helpers/music_file.py7
3 files changed, 83 insertions, 43 deletions
diff --git a/config.yml b/config.yml
index d5e6664..c7d2c5f 100644
--- a/config.yml
+++ b/config.yml
@@ -1,54 +1,75 @@
1aliases: 1aliases:
2 intro_jonglacro: 2 intro_jonglacro:
3 file: "PIRATE_01-1-intro_jonglacro.mp3" 3 file: "PIRATE_01-1-intro_jonglacro.mp3"
4 name: Intro Jonglacro
5 jonglacro_suite: 4 jonglacro_suite:
6 file: "PIRATE_01-2-jonglacro_suite.mp3" 5 file: "PIRATE_01-2-jonglacro_suite.mp3"
7 name: Jonglacro suite
8 lancer_prisonniere: 6 lancer_prisonniere:
9 file: "PIRATE_02-lancers_de_prisonniere.mp3" 7 file: "PIRATE_02-lancers_de_prisonniere.mp3"
10 name: Lancer prisonnière
11 quete: 8 quete:
12 file: "PIRATE_03-quete.mp3" 9 file: "PIRATE_03-1-quete.mp3"
13 name: Quête 10 monstre:
11 file: "PIRATE_03-2-monstre.mp3"
14 entree_ondine: 12 entree_ondine:
15 file: "PIRATE_04-entree_ondine.mp3" 13 file: "PIRATE_04-entree_ondine.mp3"
16 name: Entrée Ondine
17 cour_ondine: 14 cour_ondine:
18 file: "PIRATE_05-cour_a_londine.mp3" 15 file: "PIRATE_05-cour_a_londine.mp3"
19 name: Cour à l'Ondine
20 fouille_jonglage: 16 fouille_jonglage:
21 file: "PIRATE_07-fouille_jonglage.mp3" 17 file: "PIRATE_07-fouille_jonglage.mp3"
22 name: Fouille jonglage
23 liberation_prisonniere: 18 liberation_prisonniere:
24 file: "PIRATE_08-liberation_prisonniere.mp3" 19 file: "PIRATE_08-1-liberation_prisonniere.mp3"
25 name: Libération prisonnière 20 paf:
21 file: "PIRATE_08-2-paf_tombe.mp3"
26 duo_pirate_ondine: 22 duo_pirate_ondine:
27 file: "PIRATE_09-duo_pirate_ondine.mp3" 23 file: "PIRATE_09-duo_pirate_ondine.mp3"
28 name: Duo pirate Ondine
29 trio_jalousie: 24 trio_jalousie:
30 file: "PIRATE_10-trios_jalousie.mp3" 25 file: "PIRATE_10-1-trios_jalousie.mp3"
31 name: Trio Jalousie 26 coup:
27 file: "PIRATE_10-2-coup.mp3"
32 piquage_2_4: 28 piquage_2_4:
33 file: "PIRATE_11-piquage_2_4.mp3" 29 file: "PIRATE_11-piquage_2_4.mp3"
34 name: Piquage 2-4
35 baston: 30 baston:
36 file: "PIRATE_12-1-baston.mp3" 31 file: "PIRATE_12-1-baston.mp3"
37 name: Baston
38 baston_ascension: 32 baston_ascension:
39 file: "PIRATE_12-3-baston_ascension.mp3" 33 file: "PIRATE_12-3-baston_ascension.mp3"
40 name: Baston ascension 34 volume: 50
41 bruit:
42 file: "PIRATE_bruit.wav"
43 name: Bruit
44 paf:
45 file: "PIRATE_paf.mp3"
46 name: Paf
47 coup:
48 file: "PIRATE_coup.wav"
49 name: Coup
50 ralenti: 35 ralenti:
51 file: "PIRATE_12-2-ralenti.mp3" 36 file: "PIRATE_12-2-ralenti.mp3"
37
38music_properties:
39 "PIRATE_01-1-intro_jonglacro.mp3":
40 name: Intro Jonglacro
41 "PIRATE_01-2-jonglacro_suite.mp3":
42 name: Jonglacro suite
43 "PIRATE_02-lancers_de_prisonniere.mp3":
44 name: Lancer prisonnière
45 "PIRATE_03-1-quete.mp3":
46 name: Quête
47 "PIRATE_03-2-monstre.mp3":
48 name: Monstre
49 "PIRATE_04-entree_ondine.mp3":
50 name: Entrée Ondine
51 "PIRATE_05-cour_a_londine.mp3":
52 name: Cour à l'Ondine
53 "PIRATE_07-fouille_jonglage.mp3":
54 name: Fouille jonglage
55 "PIRATE_08-1-liberation_prisonniere.mp3":
56 name: Libération prisonnière
57 "PIRATE_08-2-paf_tombe.mp3":
58 name: Paf tombe
59 "PIRATE_09-duo_pirate_ondine.mp3":
60 name: Duo pirate Ondine
61 "PIRATE_10-1-trios_jalousie.mp3":
62 name: Trio Jalousie
63 "PIRATE_10-2-coup.mp3":
64 name: Coup
65 "PIRATE_11-piquage_2_4.mp3":
66 name: Piquage 2-4
67 "PIRATE_12-1-baston.mp3":
68 name: Baston
69 "PIRATE_12-3-baston_ascension.mp3":
70 name: Baston ascension
71 gain: 2
72 "PIRATE_12-2-ralenti.mp3":
52 name: Ralenti 73 name: Ralenti
53 74
54key_properties: 75key_properties:
@@ -220,7 +241,7 @@ keys:
220 'e': 241 'e':
221 - stop: 242 - stop:
222 include: jonglacro_suite 243 include: jonglacro_suite
223 fade_out: 5 244 fade_out: 3
224 'r': 245 'r':
225 - play: 246 - play:
226 include: lancer_prisonniere 247 include: lancer_prisonniere
@@ -236,7 +257,7 @@ keys:
236 include: quete 257 include: quete
237 value: 50 258 value: 50
238 - play: 259 - play:
239 include: bruit 260 include: monstre
240 - wait: 261 - wait:
241 duration: 2 262 duration: 2
242 - volume: 263 - volume:
@@ -253,9 +274,9 @@ keys:
253 'o': 274 'o':
254 - stop: 275 - stop:
255 include: entree_ondine 276 include: entree_ondine
256 fade_out: 5 277 fade_out: 4
257 - wait: 278 - wait:
258 duration: 5 279 duration: 4
259 - play: 280 - play:
260 include: cour_ondine 281 include: cour_ondine
261 'p': 282 'p':
@@ -273,11 +294,14 @@ keys:
273 - play: 294 - play:
274 include: liberation_prisonniere 295 include: liberation_prisonniere
275 'f': 296 'f':
276 - volume:
277 include: liberation_prisonniere
278 value: 20
279 - play: 297 - play:
280 include: paf 298 include: paf
299 - wait:
300 duration: 0.2
301 - volume:
302 include: liberation_prisonniere
303 value: 30
304
281 'g': 305 'g':
282 - stop: 306 - stop:
283 include: liberation_prisonniere 307 include: liberation_prisonniere
@@ -290,7 +314,7 @@ keys:
290 include: duo_pirate_ondine 314 include: duo_pirate_ondine
291 fade_out: 2 315 fade_out: 2
292 - wait: 316 - wait:
293 duration: 2 317 duration: 1.5
294 - play: 318 - play:
295 include: trio_jalousie 319 include: trio_jalousie
296 'k': 320 'k':
@@ -307,30 +331,36 @@ keys:
307 'm': 331 'm':
308 - stop: 332 - stop:
309 include: piquage_2_4 333 include: piquage_2_4
310 fade_out: 5 334 fade_out: 4
311 - wait: 335 - wait:
312 duration: 7 336 duration: 6
313 - play: 337 - play:
314 include: baston 338 include: baston
315 'w': 339 'w':
316 - stop: 340 - stop:
317 include: baston 341 include: baston
318 fade_out: 1 342 fade_out: 0.5
319 - wait: 343 - wait:
320 duration: 1 344 duration: 0.5
321 - play: 345 - play:
322 include: ralenti 346 include: ralenti
323 'x': 347 'x':
324 - stop: 348 - stop:
325 include: ralenti 349 include: ralenti
326 fade_out: 2 350 fade_out: 1.5
327 'c': 351 'c':
328 - play: 352 - play:
329 include: baston_ascension 353 include: baston_ascension
354# - volume:
355# include: baston_ascension
356# value: 100
330 'v': 357 'v':
331 - stop: 358 - stop:
332 include: baston_ascension 359 include: baston_ascension
333 fade_out: 2 360 fade_out: 2
361# 'n':
362# - play:
363# include: baston_ascension
334 'ESC': 364 'ESC':
335 - stop: ~ 365 - stop: ~
336 - stop_all_actions: ~ 366 - stop_all_actions: ~
diff --git a/helpers/__init__.py b/helpers/__init__.py
index 0e29f5d..7fe9c35 100644
--- a/helpers/__init__.py
+++ b/helpers/__init__.py
@@ -42,10 +42,17 @@ def parse_config(mapping):
42 if argument == 'file': 42 if argument == 'file':
43 filename = action[action_name]['file'] 43 filename = action[action_name]['file']
44 if filename not in seen_files: 44 if filename not in seen_files:
45 if 'name' in action[action_name]: 45 if filename in config['music_properties']:
46 seen_files[filename] = MusicFile(filename, file_lock, channel_id, name = action[action_name]['name']) 46 seen_files[filename] = MusicFile(
47 filename,
48 file_lock,
49 channel_id,
50 **config['music_properties'][filename])
47 else: 51 else:
48 seen_files[filename] = MusicFile(filename, file_lock, channel_id) 52 seen_files[filename] = MusicFile(
53 filename,
54 file_lock,
55 channel_id)
49 channel_id = channel_id + 1 56 channel_id = channel_id + 1
50 57
51 action_args['music'] = seen_files[filename] 58 action_args['music'] = seen_files[filename]
diff --git a/helpers/music_file.py b/helpers/music_file.py
index 667c169..892519d 100644
--- a/helpers/music_file.py
+++ b/helpers/music_file.py
@@ -1,13 +1,15 @@
1import threading 1import threading
2import pydub 2import pydub
3import pygame 3import pygame
4import math
4 5
5class MusicFile: 6class MusicFile:
6 def __init__(self, filename, lock, channel_id, name = None): 7 def __init__(self, filename, lock, channel_id, name = None, gain = 1):
7 self.filename = filename 8 self.filename = filename
8 self.channel_id = channel_id 9 self.channel_id = channel_id
9 self.name = name or filename 10 self.name = name or filename
10 self.raw_data = None 11 self.raw_data = None
12 self.gain = gain
11 13
12 self.loaded = False 14 self.loaded = False
13 self.flag_paused = False 15 self.flag_paused = False
@@ -16,7 +18,8 @@ class MusicFile:
16 def load_sound(self, lock): 18 def load_sound(self, lock):
17 lock.acquire() 19 lock.acquire()
18 print("Loading « {} »".format(self.name)) 20 print("Loading « {} »".format(self.name))
19 audio_segment = pydub.AudioSegment.from_file(self.filename).set_frame_rate(44100) 21 volume_factor = 20 * math.log10(self.gain)
22 audio_segment = pydub.AudioSegment.from_file(self.filename).set_frame_rate(44100).apply_gain(volume_factor)
20 self.sound_duration = audio_segment.duration_seconds 23 self.sound_duration = audio_segment.duration_seconds
21 self.raw_data = audio_segment.raw_data 24 self.raw_data = audio_segment.raw_data
22 print("Loaded « {} »".format(self.name)) 25 print("Loaded « {} »".format(self.name))