]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/commitdiff
Add the possibility to use the system mixer
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Sun, 17 Jul 2016 12:48:59 +0000 (14:48 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Sun, 17 Jul 2016 12:48:59 +0000 (14:48 +0200)
helpers/__init__.py
helpers/mapping.py
helpers/music_file.py

index 807aa4403880128ce0d219c4af77364f05f1f2b4..863a23b06cccb0eeb4159ddef6fcaf45ba1da908 100644 (file)
@@ -32,6 +32,9 @@ def parse_args():
             default="config.yml",
             required=False,
             help="Config file to load")
+    parser.add_argument("-m", "--no-mixing",
+            action="store_true",
+            help="Don't make the mixing of sounds manually and let the sound system do it")
     parser.add_argument("-l", "--latency",
             default="high",
             required=False,
@@ -80,6 +83,7 @@ def parse_args():
     Config.frame_rate = args.frame_rate
     Config.channels = args.channels
     Config.sample_width = args.sample_width
+    Config.no_mixing = args.no_mixing
 
 class SelectDeviceAction(argparse.Action):
     def __call__(self, parser, namespace, values, option_string=None):
index 8e0265c9415ced4a8ec6267d4ead9c82d1c919ea..cfc2c3f7546b4dba6afa1f083aacc8ca8c515e05 100644 (file)
@@ -17,7 +17,10 @@ class Mapping(RelativeLayout):
     ready_color = ListProperty([1, 165/255, 0, 1])
 
     def __init__(self, **kwargs):
-        self.mixer = Mixer()
+        if Config.no_mixing:
+            self.mixer = None
+        else:
+            self.mixer = Mixer()
         self.key_config, self.open_files = self.parse_config()
         super(Mapping, self).__init__(**kwargs)
         self._keyboard = Window.request_keyboard(self._keyboard_closed, self)
index f1aa341ee26f194d6af50a35d512f4fd44fe177f..f391ff4d2dadbf21877add9748b53adea609bb69 100644 (file)
@@ -7,6 +7,7 @@ import os.path
 
 from .lock import Lock
 from . import Config, gain
+from .mixer import Mixer
 
 file_lock = Lock("file")
 
@@ -31,6 +32,7 @@ class MusicFile(Machine):
 
         Machine.__init__(self, states=states, transitions=transitions, initial='initial')
 
+        self.mixer = mapping.mixer or Mixer()
         self.volume = 100
         self.mapping = mapping
         self.filename = filename
@@ -95,7 +97,7 @@ class MusicFile(Machine):
         self.start_playing()
 
     def on_enter_loaded_playing(self):
-        self.mapping.mixer.add_file(self)
+        self.mixer.add_file(self)
 
     def finished_callback(self):
         if self.is_loaded_playing():
@@ -104,7 +106,7 @@ class MusicFile(Machine):
             self.stopped()
 
     def trigger_stopped_events(self):
-        self.mapping.mixer.remove_file(self)
+        self.mixer.remove_file(self)
         self.wait_event.set()
 
     def play_callback(self, out_data_length, frame_count):