]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blame - music_sampler.py
Allow to find files in pyinstaller
[perso/Immae/Projets/Python/MusicSampler.git] / music_sampler.py
CommitLineData
d8ab67c7 1import sys
189bf90c 2import pygame
8f88a3e4 3import pydub
189bf90c
IB
4import helpers
5
8f88a3e4 6pygame.mixer.pre_init(frequency = 44100)
189bf90c
IB
7pygame.init()
8
9size = width, height = 1024, 600
10
11screen = pygame.display.set_mode(size)
12background = pygame.Surface(screen.get_size())
13background = background.convert()
14background.fill((250, 250, 250))
15
d8ab67c7
IB
16action_surface = pygame.Surface((600, 250)).convert()
17action_surface.fill((0,0,0))
8f88a3e4
IB
18helpers.parse_config()
19
20for key_name in helpers.Mapping.KEYS:
21 key = helpers.Mapping.KEYS[key_name]
189bf90c
IB
22 key.draw(background)
23
24screen.blit(background, (0, 0))
d8ab67c7
IB
25screen.blit(action_surface, (10, 330))
26
189bf90c
IB
27pygame.display.flip()
28
29contexts = [
30 'normal'
31]
32
33context = 'normal'
34
35while 1:
36 event = pygame.event.wait()
37 if event.type == pygame.QUIT or (
38 event.type == pygame.KEYDOWN and
39 event.mod == 4160 and
40 event.key == pygame.K_c):
41 pygame.quit()
42 sys.exit()
43
44 if context == 'normal':
d8ab67c7
IB
45 if event.type == pygame.KEYDOWN:
46 key = helpers.Key.find_by_key_num(event.key)
47 if key is not None:
48 key.do_actions()
49 elif event.type == pygame.MOUSEBUTTONUP:
50 key = helpers.Key.find_by_collidepoint(pygame.mouse.get_pos())
51 if key is not None:
52 key.list_actions(action_surface)
189bf90c
IB
53
54 pygame.display.flip()
55