class Action:
action_types = [
+ 'command',
'pause',
'play',
- 'run',
'stop',
'volume',
'wait',
def run(self, callback):
getattr(self, self.action)(callback, **self.arguments)
- def stop(self, callback, musique = None, fade_out = 0):
+ def command(self, callback, command = "", **kwargs):
+ pass
+
+ def pause(self, callback, music = None, **kwargs):
+ pass
+
+ def play(self, callback,
+ music = None,
+ fade_in = 0,
+ restart_if_running = False,
+ volume = 100,
+ **kwargs):
+ pass
+
+ def stop(self, callback, music = None, fade_out = 0, **kwargs):
print('stopping')
return callback()
+ def volume(self, callback, music = None, value = 100, **kwargs):
+ pass
+
+ def wait(self, callback, time = 0, **kwargs):
+ pass
+
class Key:
row_positions = {
'first': 5,
if len(self.actions) > 0:
self.actions[0].run(self.next_action)
- def find_from_unicode(key_sym):
+ def list_actions(self, surface):
+ print("bouh", self.key_sym)
+ surface.fill((255, 0, 0))
+
+ def find_by_key_num(key_num):
+ if key_num in Mapping.KEYS:
+ return Mapping.KEYS[key_num]
+ return None
+
+ def find_by_collidepoint(position):
+ for key in Mapping.KEYS:
+ if Mapping.KEYS[key].collidepoint(position):
+ return Mapping.KEYS[key]
+ return None
+
+ def find_by_unicode(key_sym):
for key in Mapping.KEYS:
if Mapping.KEYS[key].key_sym == key_sym:
return Mapping.KEYS[key]
seen_files = {}
for mapped_key in config['keys']:
- key = Key.find_from_unicode(mapped_key)
+ key = Key.find_by_unicode(mapped_key)
if key is None:
continue
if filename not in seen_files:
seen_files[filename] = MusicFile.new(filename)
- action_args['file'] = seen_files[filename]
+ action_args['music'] = seen_files[filename]
else:
action_args[argument] = action[action_name][argument]
+import sys
+
+if getattr(sys, 'frozen', False):
+ os.chdir(sys._MEIPASS)
+
import pygame
import pydub
-import sys
import helpers
pygame.mixer.pre_init(frequency = 44100)
background = background.convert()
background.fill((250, 250, 250))
+action_surface = pygame.Surface((600, 250)).convert()
+action_surface.fill((0,0,0))
helpers.parse_config()
for key_name in helpers.Mapping.KEYS:
key.draw(background)
screen.blit(background, (0, 0))
+screen.blit(action_surface, (10, 330))
+
pygame.display.flip()
contexts = [
sys.exit()
if context == 'normal':
- if event.type == pygame.KEYDOWN and event.key in helpers.Mapping.KEYS:
- helpers.Mapping.KEYS[event.key].do_actions()
- if event.type == pygame.MOUSEBUTTONUP:
- for key in helpers.Mapping.KEYS:
- if helpers.Mapping.KEYS[key].collidepoint(pygame.mouse.get_pos()):
- helpers.Mapping.KEYS[key].do_actions()
+ if event.type == pygame.KEYDOWN:
+ key = helpers.Key.find_by_key_num(event.key)
+ if key is not None:
+ key.do_actions()
+ elif event.type == pygame.MOUSEBUTTONUP:
+ key = helpers.Key.find_by_collidepoint(pygame.mouse.get_pos())
+ if key is not None:
+ key.list_actions(action_surface)
pygame.display.flip()
--- /dev/null
+# -*- mode: python -*-
+
+block_cipher = None
+
+a = Analysis(['run.py'],
+ pathex=['/home/immae/temp/soundplant_alternative'],
+ binaries=None,
+ datas=[('config.yml', '.')],
+ hiddenimports=[
+ 'six',
+ 'packaging',
+ 'packaging.version',
+ 'packaging.specifiers',
+ 'packaging.requirements'
+ ],
+ hookspath=[],
+ runtime_hooks=[],
+ excludes=[],
+ win_no_prefer_redirects=False,
+ win_private_assemblies=False,
+ cipher=block_cipher)
+pyz = PYZ(a.pure, a.zipped_data,
+ cipher=block_cipher)
+exe = EXE(pyz,
+ a.scripts,
+ a.binaries,
+ a.zipfiles,
+ a.datas,
+ name='run',
+ debug=False,
+ strip=False,
+ upx=True,
+ console=True )