]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blob - music_sampler.py
Remove frozen path
[perso/Immae/Projets/Python/MusicSampler.git] / music_sampler.py
1 import sys
2 import pygame
3 import pydub
4 import helpers
5
6 pygame.mixer.pre_init(frequency = 44100)
7 pygame.init()
8
9 size = width, height = 1024, 600
10
11 screen = pygame.display.set_mode(size)
12 background = pygame.Surface(screen.get_size())
13 background = background.convert()
14 background.fill((250, 250, 250))
15
16 action_surface = pygame.Surface((600, 250)).convert()
17 action_surface.fill((0,0,0))
18 helpers.parse_config()
19
20 for key_name in helpers.Mapping.KEYS:
21 key = helpers.Mapping.KEYS[key_name]
22 key.draw(background)
23
24 screen.blit(background, (0, 0))
25 screen.blit(action_surface, (10, 330))
26
27 pygame.display.flip()
28
29 contexts = [
30 'normal'
31 ]
32
33 context = 'normal'
34
35 while 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':
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)
53
54 pygame.display.flip()
55