aboutsummaryrefslogtreecommitdiff
path: root/music_sampler.py
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2016-06-20 23:08:22 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2016-06-20 23:15:47 +0200
commit9de92b6dd2bd906f6a64fce7c90a6aff0dbb27a2 (patch)
treec654b7691e8bc92bd1726554e0d353604ebb4d71 /music_sampler.py
parentd479af33afa54fee7c22701c6012a1579ead395f (diff)
downloadMusicSampler-9de92b6dd2bd906f6a64fce7c90a6aff0dbb27a2.tar.gz
MusicSampler-9de92b6dd2bd906f6a64fce7c90a6aff0dbb27a2.tar.zst
MusicSampler-9de92b6dd2bd906f6a64fce7c90a6aff0dbb27a2.zip
Added music name, currently playing musics, pause/unpause
Diffstat (limited to 'music_sampler.py')
-rw-r--r--music_sampler.py31
1 files changed, 28 insertions, 3 deletions
diff --git a/music_sampler.py b/music_sampler.py
index 8dbbc28..ff04fd1 100644
--- a/music_sampler.py
+++ b/music_sampler.py
@@ -6,14 +6,14 @@ import threading
6pygame.mixer.pre_init(frequency = 44100) 6pygame.mixer.pre_init(frequency = 44100)
7pygame.init() 7pygame.init()
8 8
9size = width, height = 1024, 600 9size = width, height = 913, 563
10screen = pygame.display.set_mode(size) 10screen = pygame.display.set_mode(size)
11screen.fill((250, 250, 250)) 11screen.fill((229, 228, 226))
12 12
13draw_lock = helpers.Lock("draw") 13draw_lock = helpers.Lock("draw")
14 14
15mapping = helpers.Mapping(screen, draw_lock) 15mapping = helpers.Mapping(screen, draw_lock)
16channel_number = helpers.parse_config(mapping) 16channel_number, open_files = helpers.parse_config(mapping)
17pygame.mixer.set_num_channels(channel_number) 17pygame.mixer.set_num_channels(channel_number)
18 18
19mapping.draw() 19mapping.draw()
@@ -49,12 +49,37 @@ while 1:
49 key = mapping.find_by_key_num(event.key) 49 key = mapping.find_by_key_num(event.key)
50 if key is not None: 50 if key is not None:
51 threading.Thread(name = "MSKeyAction", target=key.do_actions).start() 51 threading.Thread(name = "MSKeyAction", target=key.do_actions).start()
52 threading.Thread(name = "MSClic", target=key.list_actions, args = [screen]).start()
52 elif event.type == pygame.MOUSEBUTTONUP: 53 elif event.type == pygame.MOUSEBUTTONUP:
53 key = mapping.find_by_collidepoint(pygame.mouse.get_pos()) 54 key = mapping.find_by_collidepoint(pygame.mouse.get_pos())
54 if key is not None: 55 if key is not None:
55 threading.Thread(name = "MSClic", target=key.list_actions, args = [screen]).start() 56 threading.Thread(name = "MSClic", target=key.list_actions, args = [screen]).start()
56 57
57 draw_lock.acquire() 58 draw_lock.acquire()
59 if getattr(sys, 'frozen', False):
60 icon_police = pygame.font.Font(sys._MEIPASS + "/Symbola.ttf", 19)
61 police = pygame.font.Font(sys._MEIPASS + "/Ubuntu-Regular.ttf", 14)
62 else:
63 icon_police = pygame.font.Font("Symbola.ttf", 19)
64 police = pygame.font.Font("Ubuntu-Regular.ttf", 14)
65
66 surface = pygame.Surface((208, 250)).convert()
67 surface.fill((250, 250, 250))
68 offset = 0
69 for music_file in open_files.values():
70 police.set_bold(False)
71 if music_file.is_playing():
72 icon = icon_police.render("⏵", True, (0,0,0))
73 if music_file.is_paused():
74 icon = icon_police.render("⏸", True, (0,0,0))
75 else:
76 police.set_bold(True)
77 text = police.render(music_file.name, True, (0,0,0))
78 surface.blit(icon, (0, offset))
79 surface.blit(text, (20, offset))
80 offset += police.get_linesize()
81 screen.blit(surface, (700, 308))
82
58 pygame.display.flip() 83 pygame.display.flip()
59 draw_lock.release() 84 draw_lock.release()
60 85