]>
git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blob - music_sampler.py
6 pygame
.mixer
.pre_init(frequency
= 44100)
9 size
= width
, height
= 913, 563
10 screen
= pygame
.display
.set_mode(size
)
11 screen
.fill((229, 228, 226))
13 draw_lock
= helpers
.Lock("draw")
15 mapping
= helpers
.Mapping(screen
, draw_lock
)
16 channel_number
, open_files
= helpers
.parse_config(mapping
)
17 pygame
.mixer
.set_num_channels(channel_number
)
31 #### Normal workflow ####
33 event
= pygame
.event
.wait()
35 if event
.type == pygame
.QUIT
or (
36 event
.type == pygame
.KEYDOWN
and
38 event
.key
== pygame
.K_c
):
39 for thread
in threading
.enumerate():
40 if thread
.getName()[0:2] != "MS":
47 if context
== 'normal':
48 if event
.type == pygame
.KEYDOWN
:
49 key
= mapping
.find_by_key_num(event
.key
)
51 threading
.Thread(name
= "MSKeyAction", target
=key
.do_actions
).start()
52 threading
.Thread(name
= "MSClic", target
=key
.list_actions
, args
= [screen
]).start()
53 elif event
.type == pygame
.MOUSEBUTTONUP
:
54 key
= mapping
.find_by_collidepoint(pygame
.mouse
.get_pos())
56 threading
.Thread(name
= "MSClic", target
=key
.list_actions
, args
= [screen
]).start()
59 police
= helpers
.font(14)
60 icon_police
= helpers
.font(14, font
= "Symbola")
62 surface
= pygame
.Surface((208, 250)).convert()
63 surface
.fill((250, 250, 250))
65 for music_file
in open_files
.values():
66 police
.set_bold(False)
67 if music_file
.is_playing():
68 icon
= icon_police
.render("⏵", True, (0,0,0))
69 if music_file
.is_paused():
70 icon
= icon_police
.render("⏸", True, (0,0,0))
73 text
= police
.render(music_file
.name
, True, (0,0,0))
74 surface
.blit(icon
, (0, offset
))
75 surface
.blit(text
, (20, offset
))
76 offset
+= police
.get_linesize()
77 screen
.blit(surface
, (700, 308))
83 # for thread in threading.enumerate():
84 # if thread.getName()[0:2] != "MS":