aliases:
intro_jonglacro:
file: "PIRATE_01-1-intro_jonglacro.mp3"
+ name: Intro Jonglacro
jonglacro_suite:
file: "PIRATE_01-2-jonglacro_suite.mp3"
+ name: Jonglacro suite
lancer_prisonniere:
file: "PIRATE_02-lancers_de_prisonniere.mp3"
+ name: Lancer prisonnière
quete:
file: "PIRATE_03-quete.mp3"
+ name: Quête
entree_ondine:
file: "PIRATE_04-entree_ondine.mp3"
+ name: Entrée Ondine
cour_ondine:
file: "PIRATE_05-cour_a_londine.mp3"
+ name: Cour à l'Ondine
fouille_jonglage:
file: "PIRATE_07-fouille_jonglage.mp3"
+ name: Fouille jonglage
liberation_prisonniere:
file: "PIRATE_08-liberation_prisonniere.mp3"
+ name: Libération prisonnière
duo_pirate_ondine:
file: "PIRATE_09-duo_pirate_ondine.mp3"
+ name: Duo pirate Ondine
trio_jalousie:
file: "PIRATE_10-trios_jalousie.mp3"
+ name: Trio Jalousie
piquage_2_4:
file: "PIRATE_11-piquage_2_4.mp3"
+ name: Piquage 2-4
baston:
file: "PIRATE_12-1-baston.mp3"
+ name: Baston
baston_ascension:
file: "PIRATE_12-3-baston_ascension.mp3"
+ name: Baston ascension
bruit:
file: "PIRATE_bruit.wav"
+ name: Bruit
paf:
file: "PIRATE_paf.mp3"
+ name: Paf
ralenti:
file: "PIRATE_12-2-ralenti.mp3"
+ name: Ralenti
key_properties:
'a':
description:
- #Chloé
- Jonglacro
- - 2
+ - "2"
color: [73, 221, 226]
'e':
description:
description:
- #Jérôme
- Jeu à
- - 2 4
+ - "2 4"
color: [240, 158, 0]
'm':
description:
'c':
description:
- #Christophe
- - Baston 2
+ - Baston "2"
color: [255, 255, 0]
'v':
description:
- #Auréliane
- - Fin baston 2
+ - Fin baston "2"
color: [0, 190, 27]
if argument == 'file':
filename = action[action_name]['file']
if filename not in seen_files:
- seen_files[filename] = MusicFile(filename, file_lock, channel_id)
+ if 'name' in action[action_name]:
+ seen_files[filename] = MusicFile(filename, file_lock, channel_id, name = action[action_name]['name'])
+ else:
+ seen_files[filename] = MusicFile(filename, file_lock, channel_id)
channel_id = channel_id + 1
action_args['music'] = seen_files[filename]
key.set_color(config['key_properties'][key_property]['color'])
# Return the number of channels reserved
- return channel_id + 1
+ return (channel_id + 1, seen_files)
'play',
'stop',
'stop_all_actions',
+ 'unpause',
'volume',
'wait',
]
def run(self):
print(self.description())
- return getattr(self, self.action)(**self.arguments)
+ getattr(self, self.action)(**self.arguments)
+ pygame.event.post(pygame.event.Event(pygame.USEREVENT))
def description(self):
return getattr(self, self.action + "_print")(**self.arguments)
else:
pygame.mixer.pause()
+ def unpause(self, music = None, **kwargs):
+ if music is not None:
+ music.unpause()
+ else:
+ pygame.mixer.unpause()
+
def play(self, music = None, fade_in = 0, start_at = 0,
restart_if_running = False, volume = 100, **kwargs):
if music is not None:
def pause_print(self, music = None, **kwargs):
if music is not None:
- return "pausing {}".format(music.filename)
+ return "pausing « {} »".format(music.name)
else:
return "pausing all musics"
+ def unpause_print(self, music = None, **kwargs):
+ if music is not None:
+ return "unpausing « {} »".format(music.name)
+ else:
+ return "unpausing all musics"
+
def play_print(self, music = None, fade_in = 0, start_at = 0,
restart_if_running = False, volume = 100, **kwargs):
message = "starting "
if music is not None:
- message += music.filename
+ message += "« {} »".format(music.name)
else:
message += "music"
def stop_print(self, music = None, fade_out = 0, **kwargs):
if music is not None:
if fade_out == 0:
- return "stopping music {}".format(music.filename)
+ return "stopping music « {} »".format(music.name)
else:
- return "stopping music {} with {}s fadeout".format(music.filename, fade_out)
+ return "stopping music « {} » with {}s fadeout".format(music.name, fade_out)
else:
if fade_out == 0:
return "stopping all musics"
def volume_print(self, music = None, value = 100, **kwargs):
if music is not None:
- return "setting volume of {} to {}%".format(music.filename, value)
+ return "setting volume of « {} » to {}%".format(music.name, value)
else:
return "setting volume to {}%".format(value)
#print("actions linked to key {}:".format(self.key_sym))
#print("\t" + "\n\t".join(action_descriptions))
self.draw_lock.acquire()
- surface = pygame.Surface((800, 250)).convert()
+ surface = pygame.Surface((690, 250)).convert()
surface.fill((250, 250, 250))
if getattr(sys, 'frozen', False):
police = pygame.font.Font(sys._MEIPASS + "/Ubuntu-Regular.ttf", 14)
surface.blit(text, (0, offset))
offset += police.get_linesize()
- screen.blit(surface, (10, 330))
+ screen.blit(surface, (5, 308))
pygame.display.flip()
self.draw_lock.release()
import pygame
class MusicFile:
- def __init__(self, filename, lock, channel_id):
+ def __init__(self, filename, lock, channel_id, name = None):
self.filename = filename
self.channel_id = channel_id
+ self.name = name or filename
self.raw_data = None
self.sound = None
self.loaded = False
+ self.flag_paused = False
threading.Thread(name = "MSMusicLoad", target = self.load_sound, args = [lock]).start()
def load_sound(self, lock):
lock.acquire()
- print("Loading {}".format(self.filename))
+ print("Loading « {} »".format(self.name))
self.raw_data = pydub.AudioSegment.from_file(self.filename).raw_data
self.sound = pygame.mixer.Sound(self.raw_data)
- print("Loaded {}".format(self.filename))
+ print("Loaded « {} »".format(self.name))
self.loaded = True
lock.release()
def is_playing(self):
return self.channel().get_busy()
+ def is_paused(self):
+ return self.flag_paused
+
def play(self, fade_in = 0, volume = 100, start_at = 0):
+ self.channel().set_endevent()
+ self.channel().set_endevent(pygame.USEREVENT)
self.set_volume(volume)
if start_at > 0:
self.sound = pygame.mixer.Sound(self.raw_data)
self.channel().play(self.sound, fade_ms = fade_in * 1000)
+ self.flag_paused = False
def pause(self):
self.channel().pause()
+ self.flag_paused = True
+
+ def unpause(self):
+ self.channel().unpause()
+ self.flag_paused = False
def stop(self, fade_out = 0):
if fade_out > 0:
pygame.mixer.pre_init(frequency = 44100)
pygame.init()
-size = width, height = 1024, 600
+size = width, height = 913, 563
screen = pygame.display.set_mode(size)
-screen.fill((250, 250, 250))
+screen.fill((229, 228, 226))
draw_lock = helpers.Lock("draw")
mapping = helpers.Mapping(screen, draw_lock)
-channel_number = helpers.parse_config(mapping)
+channel_number, open_files = helpers.parse_config(mapping)
pygame.mixer.set_num_channels(channel_number)
mapping.draw()
key = mapping.find_by_key_num(event.key)
if key is not None:
threading.Thread(name = "MSKeyAction", target=key.do_actions).start()
+ threading.Thread(name = "MSClic", target=key.list_actions, args = [screen]).start()
elif event.type == pygame.MOUSEBUTTONUP:
key = mapping.find_by_collidepoint(pygame.mouse.get_pos())
if key is not None:
threading.Thread(name = "MSClic", target=key.list_actions, args = [screen]).start()
draw_lock.acquire()
+ if getattr(sys, 'frozen', False):
+ icon_police = pygame.font.Font(sys._MEIPASS + "/Symbola.ttf", 19)
+ police = pygame.font.Font(sys._MEIPASS + "/Ubuntu-Regular.ttf", 14)
+ else:
+ icon_police = pygame.font.Font("Symbola.ttf", 19)
+ police = pygame.font.Font("Ubuntu-Regular.ttf", 14)
+
+ surface = pygame.Surface((208, 250)).convert()
+ surface.fill((250, 250, 250))
+ offset = 0
+ for music_file in open_files.values():
+ police.set_bold(False)
+ if music_file.is_playing():
+ icon = icon_police.render("⏵", True, (0,0,0))
+ if music_file.is_paused():
+ icon = icon_police.render("⏸", True, (0,0,0))
+ else:
+ police.set_bold(True)
+ text = police.render(music_file.name, True, (0,0,0))
+ surface.blit(icon, (0, offset))
+ surface.blit(text, (20, offset))
+ offset += police.get_linesize()
+ screen.blit(surface, (700, 308))
+
pygame.display.flip()
draw_lock.release()
a = Analysis(['music_sampler.py'],
binaries=None,
- datas=[('config.yml', '.'), ('Ubuntu-Regular.ttf', '.')],
+ datas=[
+ ('config.yml', '.'),
+ ('Ubuntu-Regular.ttf', '.'),
+ ('Symbola.ttf', '.')
+ ],
hiddenimports=[
'six',
'packaging',