from .music_file import *
from .mixer import Mixer
from . import Config, gain, error_print
+from .action import Action
class Mapping(RelativeLayout):
expected_keys = NumericProperty(0)
self.mixer = Mixer()
else:
self.mixer = None
- self.key_config, self.open_files = self.parse_config()
+
+ try:
+ self.key_config, self.open_files = self.parse_config()
+ except Exception as e:
+ error_print("Error while loading configuration: {}".format(e))
+ sys.exit()
+
super(Mapping, self).__init__(**kwargs)
self._keyboard = Window.request_keyboard(self._keyboard_closed, self)
self._keyboard.bind(on_key_down=self._on_keyboard_down)
self.running = []
+ self.wait_ids = {}
Clock.schedule_interval(self.not_all_keys_ready, 1)
@property
def master_gain(self):
return gain(self.master_volume)
- def set_master_volume(self, value, delta=False):
+ def set_master_volume(self, value, delta=False, fade=0):
[db_gain, self.master_volume] = gain(
value + int(delta) * self.master_volume,
self.master_volume)
for music in self.open_files.values():
- music.set_gain(db_gain)
+ music.set_gain_with_effect(db_gain, fade=fade)
+
+ def add_wait_id(self, wait_id, action_or_wait):
+ self.wait_ids[wait_id] = action_or_wait
+
+ def interrupt_wait(self, wait_id):
+ if wait_id in self.wait_ids:
+ action_or_wait = self.wait_ids[wait_id]
+ del(self.wait_ids[wait_id])
+ if isinstance(action_or_wait, Action):
+ action_or_wait.interrupt()
+ else:
+ action_or_wait.set()
def _keyboard_closed(self):
self._keyboard.unbind(on_key_down=self._on_keyboard_down)
**config['music_properties'][filename])
else:
seen_files[filename] = MusicFile(
- self,
- filename)
+ filename,
+ self)
if filename not in key_properties[mapped_key]['files']:
key_properties[mapped_key]['files'] \