def toggle_preset_preload_noteon(self): if zynthian_gui_config.preset_preload_noteon: logging.info("Preset Preload OFF") zynthian_gui_config.preset_preload_noteon=False else: logging.info("Preset Preload ON") zynthian_gui_config.preset_preload_noteon=True # Save config zynconf.update_midi_profile({ "ZYNTHIAN_MIDI_PRESET_PRELOAD_NOTEON": str(int(zynthian_gui_config.preset_preload_noteon)) }) self.fill_list()
def toggle_midi_sys(self): if zynthian_gui_config.midi_sys_enabled: logging.info("MIDI System Messages OFF") zynthian_gui_config.midi_sys_enabled=False else: logging.info("MIDI System Messages ON") zynthian_gui_config.midi_sys_enabled=True # Update MIDI profile zynconf.update_midi_profile({ "ZYNTHIAN_MIDI_SYS_ENABLED": str(int(zynthian_gui_config.midi_sys_enabled)) }) self.fill_list()
def toggle_prog_change_zs3(self): if zynthian_gui_config.midi_prog_change_zs3: logging.info("ZS3 Program Change OFF") zynthian_gui_config.midi_prog_change_zs3=False else: logging.info("ZS3 Program Change ON") zynthian_gui_config.midi_prog_change_zs3=True # Save config zynconf.update_midi_profile({ "ZYNTHIAN_MIDI_PROG_CHANGE_ZS3": str(int(zynthian_gui_config.midi_prog_change_zs3)) }) self.fill_list()
def stop_aubionotes(self, save_config=True): logging.info("STOPPING aubionotes") try: check_output("systemctl stop aubionotes", shell=True) zynthian_gui_config.midi_aubionotes_enabled = 0 # Update MIDI profile if save_config: zynconf.update_midi_profile({ "ZYNTHIAN_MIDI_AUBIONOTES_ENABLED": str(zynthian_gui_config.midi_aubionotes_enabled) }) except Exception as e: logging.error(e) self.fill_list()
def stop_touchosc2midi(self, save_config=True): logging.info("STOPPING touchosc2midi") try: check_output("systemctl stop touchosc2midi", shell=True) zynthian_gui_config.midi_touchosc_enabled = 0 # Update MIDI profile if save_config: zynconf.update_midi_profile({ "ZYNTHIAN_MIDI_TOUCHOSC_ENABLED": str(zynthian_gui_config.midi_touchosc_enabled) }) except Exception as e: logging.error(e) self.fill_list()
def toggle_midi_filter_output(self): if zynthian_gui_config.midi_filter_output: logging.info("MIDI Filter Output OFF") zynthian_gui_config.midi_filter_output=False else: logging.info("MIDI Filter Output ON") zynthian_gui_config.midi_filter_output=True # Update MIDI profile zynconf.update_midi_profile({ "ZYNTHIAN_MIDI_FILTER_OUTPUT": str(int(zynthian_gui_config.midi_filter_output)) }) self.zyngui.zynautoconnect_midi() self.fill_list()
def toggle_single_channel(self): if zynthian_gui_config.midi_single_active_channel: logging.info("Single Channel Mode OFF") zynthian_gui_config.midi_single_active_channel=False else: logging.info("Single Channel Mode ON") zynthian_gui_config.midi_single_active_channel=True # Update MIDI profile zynconf.update_midi_profile({ "ZYNTHIAN_MIDI_SINGLE_ACTIVE_CHANNEL": str(int(zynthian_gui_config.midi_single_active_channel)) }) self.zyngui.set_active_channel() sleep(0.5) self.fill_list()
def stop_rtpmidi(self, save_config=True): logging.info("STOPPING RTP-MIDI") try: check_output("systemctl stop jackrtpmidid", shell=True) zynthian_gui_config.midi_rtpmidi_enabled = 0 # Update MIDI profile if save_config: zynconf.update_midi_profile({ "ZYNTHIAN_MIDI_RTPMIDI_ENABLED": str(zynthian_gui_config.midi_rtpmidi_enabled) }) except Exception as e: logging.error(e) self.fill_list()
def stop_qmidinet(self, save_config=True): logging.info("STOPPING QMIDINET") try: check_output("systemctl stop qmidinet", shell=True) zynthian_gui_config.midi_network_enabled = 0 # Update MIDI profile if save_config: zynconf.update_midi_profile({ "ZYNTHIAN_MIDI_NETWORK_ENABLED": str(zynthian_gui_config.midi_network_enabled) }) except Exception as e: logging.error(e) self.fill_list()
def toggle_single_channel(self): if zynthian_gui_config.midi_single_active_channel: logging.info("Single Channel Mode OFF") zynthian_gui_config.midi_single_active_channel=False else: logging.info("Single Channel Mode ON") zynthian_gui_config.midi_single_active_channel=True # Update MIDI profile zynconf.update_midi_profile({ "ZYNTHIAN_MIDI_SINGLE_ACTIVE_CHANNEL": str(int(zynthian_gui_config.midi_single_active_channel)) }) self.zyngui.set_active_channel() sleep(0.5) self.fill_list()
def start_aubionotes(self, save_config=True): logging.info("STARTING aubionotes") try: check_output("systemctl start aubionotes", shell=True) zynthian_gui_config.midi_aubionotes_enabled = 1 # Update MIDI profile if save_config: zynconf.update_midi_profile({ "ZYNTHIAN_MIDI_AUBIONOTES_ENABLED": str(zynthian_gui_config.midi_aubionotes_enabled) }) # Call autoconnect after a little time sleep(0.5) self.zyngui.zynautoconnect() except Exception as e: logging.error(e) self.fill_list()
def start_touchosc2midi(self, save_config=True): logging.info("STARTING touchosc2midi") try: check_output("systemctl start touchosc2midi", shell=True) zynthian_gui_config.midi_touchosc_enabled = 1 # Update MIDI profile if save_config: zynconf.update_midi_profile({ "ZYNTHIAN_MIDI_TOUCHOSC_ENABLED": str(zynthian_gui_config.midi_touchosc_enabled) }) # Call autoconnect after a little time sleep(0.5) self.zyngui.zynautoconnect_midi() except Exception as e: logging.error(e) self.fill_list()
def start_qmidinet(self, save_config=True): logging.info("STARTING QMIDINET") try: check_output("systemctl start qmidinet", shell=True) zynthian_gui_config.midi_network_enabled = 1 # Update MIDI profile if save_config: zynconf.update_midi_profile({ "ZYNTHIAN_MIDI_NETWORK_ENABLED": str(zynthian_gui_config.midi_network_enabled) }) # Call autoconnect after a little time sleep(0.5) self.zyngui.zynautoconnect_midi(True) except Exception as e: logging.error(e) self.fill_list()
def post(self): self.request.arguments[ 'ZYNTHIAN_MIDI_FILTER_OUTPUT'] = self.request.arguments.get( 'ZYNTHIAN_MIDI_FILTER_OUTPUT', '0') self.request.arguments[ 'ZYNTHIAN_MIDI_SYS_ENABLED'] = self.request.arguments.get( 'ZYNTHIAN_MIDI_SYS_ENABLED', '0') self.request.arguments[ 'ZYNTHIAN_MIDI_PRESET_PRELOAD_NOTEON'] = self.request.arguments.get( 'ZYNTHIAN_MIDI_PRESET_PRELOAD_NOTEON', '0') self.request.arguments[ 'ZYNTHIAN_MIDI_SINGLE_ACTIVE_CHANNEL'] = self.request.arguments.get( 'ZYNTHIAN_MIDI_SINGLE_ACTIVE_CHANNEL', '0') self.request.arguments[ 'ZYNTHIAN_MIDI_PROG_CHANGE_ZS3'] = self.request.arguments.get( 'ZYNTHIAN_MIDI_PROG_CHANGE_ZS3', '0') self.request.arguments[ 'ZYNTHIAN_MIDI_RTPMIDI_ENABLED'] = self.request.arguments.get( 'ZYNTHIAN_MIDI_RTPMIDI_ENABLED', '0') self.request.arguments[ 'ZYNTHIAN_MIDI_NETWORK_ENABLED'] = self.request.arguments.get( 'ZYNTHIAN_MIDI_NETWORK_ENABLED', '0') self.request.arguments[ 'ZYNTHIAN_MIDI_TOUCHOSC_ENABLED'] = self.request.arguments.get( 'ZYNTHIAN_MIDI_TOUCHOSC_ENABLED', '0') self.request.arguments[ 'ZYNTHIAN_MIDI_AUBIONOTES_ENABLED'] = self.request.arguments.get( 'ZYNTHIAN_MIDI_AUBIONOTES_ENABLED', '0') escaped_request_arguments = tornado.escape.recursive_unicode( self.request.arguments) errors = {} try: freq = float( self.request.arguments.get('ZYNTHIAN_MIDI_FINE_TUNING', '440.0')[0]) if freq < 392.0 or freq > 493.88: errors[ 'ZYNTHIAN_MIDI_FINE_TUNING'] = "Frequency must be in the range 392.00 - 493.88 Hz!" except: self.request.arguments['ZYNTHIAN_MIDI_FINE_TUNING'] = 440.0 errors['ZYNTHIAN_MIDI_FINE_TUNING'] = "Frequency must be a number!" filter_error = self.validate_filter_rules(escaped_request_arguments) if filter_error: errors['ZYNTHIAN_MIDI_FILTER_RULES'] = filter_error if not errors: # remove fields that start with FILTER_ADD from request_args, so that they won't be passed to update_config for filter_add_argument in list(escaped_request_arguments.keys()): if filter_add_argument.startswith('FILTER_ADD'): del escaped_request_arguments[filter_add_argument] new_profile_script_name = self.get_argument( 'zynthian_midi_profile_new_script_name') if new_profile_script_name: #New MIDI profile self.current_midi_profile_script = self.PROFILES_DIRECTORY + '/' + new_profile_script_name + '.sh' try: #create file as copy of default: zynconf.get_midi_config_fpath( self.current_midi_profile_script) zynconf.update_midi_profile( escaped_request_arguments, self.current_midi_profile_script) mode = os.stat(self.current_midi_profile_script).st_mode mode |= (mode & 0o444) >> 2 # copy R bits to X os.chmod(self.current_midi_profile_script, mode) errors = zynconf.save_config({ 'ZYNTHIAN_SCRIPT_MIDI_PROFILE': self.current_midi_profile_script }) self.load_midi_profile_directories() except: errors[ 'zynthian_midi_profile_new_script_name'] = "Can't create new profile!" elif 'zynthian_midi_profile_delete_script' in self.request.arguments and self.get_argument( 'zynthian_midi_profile_delete_script') == "1": #DELETE if self.current_midi_profile_script.startswith( self.PROFILES_DIRECTORY): os.remove(self.current_midi_profile_script) self.current_midi_profile_script = "{}/default.sh".format( self.PROFILES_DIRECTORY) errors = zynconf.save_config({ 'ZYNTHIAN_SCRIPT_MIDI_PROFILE': self.current_midi_profile_script }) self.load_midi_profile_directories() else: errors[ 'zynthian_midi_profile_delete_script'] = 'You can only delete user profiles!' else: #SAVE if self.current_midi_profile_script: updateParameters = [] for parameter in escaped_request_arguments: if not parameter.startswith('ZYNTHIAN_'): updateParameters.append(parameter) for k in updateParameters: del escaped_request_arguments[k] zynconf.update_midi_profile( escaped_request_arguments, self.current_midi_profile_script) errors = self.update_config(escaped_request_arguments) else: errors[ 'zynthian_midi_profile_new_script_name'] = 'No profile name!' self.reload_midi_config_flag = True self.get(errors)
def post(self): self.request.arguments[ 'ZYNTHIAN_MIDI_PRESET_PRELOAD_NOTEON'] = self.request.arguments.get( 'ZYNTHIAN_MIDI_PRESET_PRELOAD_NOTEON', '0') self.request.arguments[ 'ZYNTHIAN_MIDI_SINGLE_ACTIVE_CHANNEL'] = self.request.arguments.get( 'ZYNTHIAN_MIDI_SINGLE_ACTIVE_CHANNEL', '0') self.request.arguments[ 'ZYNTHIAN_MIDI_PROG_CHANGE_ZS3'] = self.request.arguments.get( 'ZYNTHIAN_MIDI_PROG_CHANGE_ZS3', '0') self.request.arguments[ 'ZYNTHIAN_MIDI_NETWORK_ENABLED'] = self.request.arguments.get( 'ZYNTHIAN_MIDI_NETWORK_ENABLED', '0') escaped_request_arguments = tornado.escape.recursive_unicode( self.request.arguments) filter_error = self.validate_filter_rules(escaped_request_arguments) errors = {} if not filter_error: # remove fields that start with FILTER_ADD from request_args, so that they won't be passed to update_config for filter_add_argument in list(escaped_request_arguments.keys()): if filter_add_argument.startswith('FILTER_ADD'): del escaped_request_arguments[filter_add_argument] new_profile_script_name = self.get_argument( 'zynthian_midi_profile_new_script_name') if new_profile_script_name: #New MIDI profile new_profile_script_path = self.PROFILES_DIRECTORY + '/' + new_profile_script_name + '.sh' #create file as copy of default: zynconf.get_midi_config_fpath(new_profile_script_path) zynconf.update_midi_profile(escaped_request_arguments, new_profile_script_path) mode = os.stat(new_profile_script_path).st_mode mode |= (mode & 0o444) >> 2 # copy R bits to X os.chmod(new_profile_script_path, mode) self.load_midi_profile_directories() elif 'zynthian_midi_profile_delete_script' in self.request.arguments and self.get_argument( 'zynthian_midi_profile_delete_script') == "1": #DELETE if self.current_midi_profile_script.startswith( self.PROFILES_DIRECTORY): os.remove(self.current_midi_profile_script) self.current_midi_profile_script = None else: errors[ 'zynthian_midi_profile_delete_script'] = 'You can only delete user profiles!' else: #SAVE if self.current_midi_profile_script: updateParameters = [] for parameter in escaped_request_arguments: if not parameter.startswith('ZYNTHIAN_'): updateParameters.append(parameter) for k in updateParameters: del escaped_request_arguments[k] zynconf.update_midi_profile( escaped_request_arguments, self.current_midi_profile_script) errors = self.update_config(escaped_request_arguments) else: errors[ 'zynthian_midi_profile_new_script_name'] = 'Profile name missing' #self.restart_ui() self.reload_midi_config() else: errors = { 'ZYNTHIAN_MIDI_FILTER_RULES': filter_error } self.get(errors)