def preset_clicked(self, button): global sox_multiplier self.terminate_sox() # Use a filter to find the currently selected preset current_preset = list(filter(lambda p: p.name == button.props.label, state.loaded_presets))[0] state.current_preset = current_preset if current_preset.override_pitch: # Set the pitch of the slider self.pitch_scale.set_value(float(current_preset.pitch_value)) self.pitch_scale.set_sensitive(False) command = utils.build_sox_command( state.current_preset, config_object=state.config ) else: self.pitch_scale.set_sensitive(True) command = utils.build_sox_command( state.current_preset, config_object=state.config, scale_object=self.pitch_scale ) self.sox_process = subprocess.Popen(command.split(' '))
def toggle_activated(self, switch, gparam): if switch.get_active(): # Load module-null-sink null_sink = subprocess.check_call( 'pacmd load-module module-null-sink sink_name=Lyrebird-Output'.split(' ') ) remap_sink = subprocess.check_call( 'pacmd load-module module-remap-source source_name=Lyrebird-Input master=Lyrebird-Output.monitor'\ .split(' ') ) print(f'Loaded null output sink ({null_sink}), and remap sink ({remap_sink})') subprocess.check_call( 'pacmd update-sink-proplist Lyrebird-Output device.description="Lyrebird Output"'\ .split(' ') ) subprocess.check_call( 'pacmd update-source-proplist Lyrebird-Input device.description="Lyrebird Virtual Input"'\ .split(' ') ) state.sink = null_sink # Kill the sox process self.terminate_sox() # Use the default preset, which is "Man" if the loaded preset is not found. default_preset = state.loaded_presets[0] current_preset = state.current_preset or default_preset if current_preset.override_pitch: # Set the pitch of the slider self.pitch_scale.set_value(float(current_preset.pitch_value)) self.pitch_scale.set_sensitive(False) command = utils.build_sox_command( current_preset, config_object=state.config ) else: self.pitch_scale.set_sensitive(True) command = utils.build_sox_command( current_preset, config_object=state.config, scale_object=self.pitch_scale ) self.sox_process = subprocess.Popen(command.split(' ')) else: utils.unload_pa_modules(check_state=True) self.terminate_sox()
def pitch_scale_moved(self, event): global sox_multiplier # Very hacky code, we repeatedly kill sox, grab the new value to pitch shift # by, and then restart the process. # Only allow adjusting the pitch if the preset doesn't override the pitch if state.current_preset is not None: # Kill the sox process self.terminate_sox() if not state.current_preset.override_pitch: # Multiply the pitch shift scale value by the multiplier and feed it to sox command = utils.build_sox_command( state.current_preset, config_object=state.config, scale_object=self.pitch_scale) self.sox_process = subprocess.Popen(command.split(' '))