aboutsummaryrefslogtreecommitdiff
path: root/music_sampler.py
diff options
context:
space:
mode:
Diffstat (limited to 'music_sampler.py')
-rw-r--r--music_sampler.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/music_sampler.py b/music_sampler.py
new file mode 100644
index 0000000..9797c91
--- /dev/null
+++ b/music_sampler.py
@@ -0,0 +1,59 @@
1import sys
2
3if getattr(sys, 'frozen', False):
4 os.chdir(sys._MEIPASS)
5
6import pygame
7import pydub
8import helpers
9
10pygame.mixer.pre_init(frequency = 44100)
11pygame.init()
12
13size = width, height = 1024, 600
14
15screen = pygame.display.set_mode(size)
16background = pygame.Surface(screen.get_size())
17background = background.convert()
18background.fill((250, 250, 250))
19
20action_surface = pygame.Surface((600, 250)).convert()
21action_surface.fill((0,0,0))
22helpers.parse_config()
23
24for key_name in helpers.Mapping.KEYS:
25 key = helpers.Mapping.KEYS[key_name]
26 key.draw(background)
27
28screen.blit(background, (0, 0))
29screen.blit(action_surface, (10, 330))
30
31pygame.display.flip()
32
33contexts = [
34 'normal'
35]
36
37context = 'normal'
38
39while 1:
40 event = pygame.event.wait()
41 if event.type == pygame.QUIT or (
42 event.type == pygame.KEYDOWN and
43 event.mod == 4160 and
44 event.key == pygame.K_c):
45 pygame.quit()
46 sys.exit()
47
48 if context == 'normal':
49 if event.type == pygame.KEYDOWN:
50 key = helpers.Key.find_by_key_num(event.key)
51 if key is not None:
52 key.do_actions()
53 elif event.type == pygame.MOUSEBUTTONUP:
54 key = helpers.Key.find_by_collidepoint(pygame.mouse.get_pos())
55 if key is not None:
56 key.list_actions(action_surface)
57
58 pygame.display.flip()
59