Example #1
0
 def add_ui(self, shell):
     print("starting add_ui")
     action_group = ActionGroup(shell, 'ParametricEqualizerActionGroup')
     action_group.add_action(func=self.show_ui,
         action_name='Equalize', label=_('_Equalizer'),
         action_type='app')
     self._appshell = ApplicationShell(shell)
     self._appshell.insert_action_group(action_group)
     self._appshell.add_app_menuitems(ui_string, 'ParametricEqualizerActionGroup')
     print("add_ui done")
Example #2
0
class ParametricEQPlugin (GObject.Object, Peas.Activatable):
    object = GObject.property(type=GObject.Object)

    def __init__(self):
        super(ParametricEQPlugin, self).__init__()
        print("init done")

    def set_filter(self):
        try:
            if self.filterSet:
                return
            print('adding filter')
            self.player.add_filter(self.eq)
            self.filterSet = True
            print('done setting filter')
        except Exception as inst:
            print('unexpected exception',  sys.exc_info()[0], type(inst), inst)  
            pass

    def do_deactivate(self):
        print('entering do_deactivate')
        try:        
            self.player.remove_filter(self.eq)
            print('filter disabled')
            shell = self.object
            self._appshell.cleanup()    
        except:
            pass        
        del self.shell_player
        del self.shell
        del self.eq

    def apply_settings(self,params):
        numEQBands = len( params )
        result = False
        print("num-bands : ", numEQBands)
        if numEQBands > 0:
            print("got eq bands")
            self.eq.set_property('num-bands', numEQBands)
            for i in range(0,numEQBands):
                band = self.eq.get_child_by_index(i)
                band.props.freq = params[i].frequency
                print('band.props.freq', band.props.freq)
                band.props.bandwidth = params[i].bandwidth
                print('band.props.bandwidth', band.props.bandwidth)
                band.props.gain = params[i].gain
                print('band.props.gain', band.props.gain)
                band.props.type = params[i].bandType
                print( inspect.getdoc( band.props.type ) )
                print( "band.props.type", params[i].bandType )
            result = True
        if True == result:
            self.set_filter()

    def show_ui(self, *args):
        self.eqDlg.show_ui(args)

    def add_ui(self, shell):
        print("starting add_ui")
        action_group = ActionGroup(shell, 'ParametricEqualizerActionGroup')
        action_group.add_action(func=self.show_ui,
            action_name='Equalize', label=_('_Equalizer'),
            action_type='app')
        self._appshell = ApplicationShell(shell)
        self._appshell.insert_action_group(action_group)
        self._appshell.add_app_menuitems(ui_string, 'ParametricEqualizerActionGroup')
        print("add_ui done")

    def do_activate(self):
        self.shell = self.object
        print("is RB3 :" + str( ParametricEQ_rb3compat.is_rb3() ) + ", " + str(ParametricEQ_rb3compat.PYVER))      
        self.shell_player = self.shell.props.shell_player
        self.player = self.shell_player.props.player
        self.eq = Gst.ElementFactory.make('equalizer-nbands', 'MyEQ')
        conf = Config()
        params = conf.load(None)
        if len(params) == 0:
            #no default config for active preset - create a 10 Band default EQ to get started
            params =  [EQBandParams(29, 20, 0),
            EQBandParams(59, 30, 0),
            EQBandParams(119, 60, 0),
            EQBandParams(237, 118, 0),
            EQBandParams(474, 237, 0),
            EQBandParams(947, 473, 0),
            EQBandParams(1889, 942, 0),
            EQBandParams(3770, 1881, 0),
            EQBandParams(7523, 3753, 0),
            EQBandParams(15011, 7488, 0)]
            conf.save(params,"default_10_band")
        self.eqDlg = EQControl(self)
        self.add_ui( self.shell )
        self.filterSet = False
        self.apply_settings(params)
        print("do_activate done")
Example #3
0
class ParametricEQPlugin (GObject.Object, Peas.Activatable):
    object = GObject.property(type=GObject.Object)

    def __init__(self):
        super(ParametricEQPlugin, self).__init__()
        print("init done")

    def set_filter(self):
        try:
            print('adding filter')
            self.player.add_filter(self.eq)
            print('done setting filter')
        except Exception as inst:
            print('unexpected exception',  sys.exc_info()[0], type(inst), inst)
            pass

    def do_deactivate(self):
        print('entering do_deactivate')
        try:
            self.player.remove_filter(self.eq)
            print('filter disabled')
            shell = self.object
            self._appshell.cleanup()
            self.stopFlag.set()
        except:
            pass
        del self.shell_player
        del self.shell
        del self.eq

    def apply_settings(self,params):
        numEQBands = len( params )
        #print("num-bands : ", numEQBands)
        if numEQBands > 0:
            #print("got eq bands")
            self.eq.set_property('num-bands', numEQBands)
            for i in range(0,numEQBands):
                band = self.eq.get_child_by_index(i)
                band.props.freq = params[i].frequency
                #print('band.props.freq', band.props.freq)
                band.props.bandwidth = params[i].bandwidth
                #print('band.props.bandwidth', band.props.bandwidth)
                band.props.gain = params[i].appliedGain
                #print('band.props.gain', band.props.gain)
                band.props.type = params[i].bandType
                #print( inspect.getdoc( band.props.type ) )
                #print( "band.props.type", params[i].bandType )

    def show_ui(self, *args):
        self.eqDlg.show_ui(args)

    def add_ui(self, shell):
        print("starting add_ui")
        action_group = ActionGroup(shell, 'ParametricEqualizerActionGroup')
        action_group.add_action(func=self.show_ui,
            action_name='Equalize', label=_('_Equalizer'),
            action_type='app')
        self._appshell = ApplicationShell(shell)
        self._appshell.insert_action_group(action_group)
        self._appshell.add_app_menuitems(ui_string, 'ParametricEqualizerActionGroup')
        print("add_ui done")

    def volume_changed(self, sp, entry):
        print("volume changed")
        rbVolume = self.player.get_volume()
        mainVolume = float(self.mainVolumePercentage) / 100.0
        overallVolume = mainVolume * rbVolume
        self.eqDlg.onVolumeChanged( overallVolume )
        print( "volume:", overallVolume)

    mainVolumePercentage = 0

    def do_activate(self):
        self.shell = self.object
        print("is RB3 :" + str( ParametricEQ_rb3compat.is_rb3() ) + ", " + str(ParametricEQ_rb3compat.PYVER))
        self.shell_player = self.shell.props.shell_player
        self.player = self.shell_player.props.player
        self.eq = Gst.ElementFactory.make('equalizer-nbands', 'MyEQ')
        self.set_filter()
        currPresets = Config.load()
        if len(currPresets.presets) == 0:
            print("creating default preset")
            #no default config for active preset - create a 10 Band default EQ to get started
            defaultPreset = Preset( "default_10_band",
            [EQBandParams(29, 20, 0),
            EQBandParams(59, 30, 0),
            EQBandParams(119, 60, 0),
            EQBandParams(237, 118, 0),
            EQBandParams(474, 237, 0),
            EQBandParams(947, 473, 0),
            EQBandParams(1889, 942, 0),
            EQBandParams(3770, 1881, 0),
            EQBandParams(7523, 3753, 0),
            EQBandParams(15011, 7488, 0)]
            )
            currPresets.appendPreset(defaultPreset, True)
            Config.save( currPresets )
        self.eqDlg = EQControl(self)
        self.add_ui( self.shell )
        self.filterSet = False
        #add volume changed callback
        self.psc_id = self.player.connect('volume-changed', self.volume_changed)
        self.stopFlag = threading.Event()
        thread = PullVolumeThread(self.stopFlag, self)
        thread.start()
        print("do_activate done")