Beispiel #1
0
    def __init__(self):
        Gtk.Window.__init__(self, title='Lyrebird')
        self.set_border_width(10)

        self.set_size_request(600, 500)
        self.set_default_size(600, 500)

        headerbar = Gtk.HeaderBar()
        headerbar.set_show_close_button(True)
        headerbar.props.title = 'Lyrebird Voice Changer'

        about_btn = Gtk.Button()
        about_btn.props.image = Gtk.Button.new_from_icon_name('help-about-symbolic', Gtk.IconSize.BUTTON)
        about_btn.connect('clicked', self.about_clicked)
        headerbar.pack_start(about_btn)

        self.set_wmclass ('Lyrebird', 'Lyrebird')
        self.set_title('Lyrebird')
        self.set_titlebar(headerbar)

        self.sox_process = None

        # Unload the null sink module if there is one from last time.
        # The only reason there would be one already, is if the application was closed without
        # toggling the switch to off (aka a crash was experienced).
        utils.unload_pa_modules(check_state=False)

        # Load the configuration file
        state.config = config.load_config()

        # Set the icon
        self.set_icon_from_file('icon.png')

        # Build the UI
        self.build_ui()
Beispiel #2
0
    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()
Beispiel #3
0
 def close(self, *args):
     self.terminate_sox()
     utils.unload_pa_modules(check_state=False)
     Gtk.main_quit()