Example #1
0
    def sel_profile(self):
        func_available, eqid, _, is_playing, _, is_dyn = self.check_func_available(
        )
        if not func_available: return

        self.eqid = eqid

        include_switch_off = is_dyn and is_playing

        profiles = SocketCom("server").call_func("get", "eq_profiles")
        profile = SocketCom("server").call_func("get", "eq_base_profile")

        if include_switch_off: profiles = [tr(32011)] + profiles

        funcs = [(tr(32014), self.sel_new_profile),
                 (tr(32015), self.sel_delete_profile),
                 (tr(32016), self.sel_load_defaults)]

        sel = contextMenu(items=profiles, default=profile, funcs=funcs)

        if sel is None: return
        if include_switch_off and sel == 0:
            SocketCom("server").call_func("switch", "eq_off")
        else:
            SocketCom("server").call_func("load", "eq_profile",
                                          [eqid, profiles[sel]])
Example #2
0
	def __init__( self ):
		#strat process
		xbmc.Monitor.__init__( self )
		xbmc.log("eq: start PulesEqualizer service",xbmc.LOGDEBUG)

		self.server_sock = SocketCom("kodi")
		if not self.server_sock.is_server_running():
			self.server_sock.start_func_server(self)
		else: self.server_sock = None

		launcher = Launcher("menu")
		launcher.start()

		self.sock = SocketCom("server")

		ps = PulseService()
		ps.start()

		self.sock.call_func("set","device",[self.get_device()])

		while not self.abortRequested():
			if self.waitForAbort( 10 ):
				break

		launcher.stop()

		ps.stop()
		if self.server_sock:
			self.server_sock.stop_server()
Example #3
0
    def check_func_available(self):
        self.current = SocketCom("server").call_func("get", "eq_current")
        eqid, desc, is_playing, eq_profile, is_dyn = (self.current)

        if eqid == -1:
            # Dialog equalizer not installed
            xbmcgui.Dialog().ok(tr(32004), tr(32035))
            return False, eqid, desc, is_playing, eq_profile, is_dyn

        if is_playing and eq_profile == 'off' and is_dyn:
            # Dialog switch on?
            if not xbmcgui.Dialog().yesno(tr(32000), tr(32003)):
                return False, eqid, desc, is_playing, eq_profile, is_dyn
            else:
                SocketCom("server").call_func("switch", "eq_on")

                count = 10
                while count > 0:
                    count = count - 1
                    self.current = SocketCom("server").call_func(
                        "get", "eq_current")
                    eqid, desc, is_playing, eq_profile, is_dyn = (self.current)
                    if eqid is not None:
                        return True, eqid, desc, is_playing, eq_profile, is_dyn
                    sleep(0.1)
            # Dialog problem switch on
            xbmcgui.Dialog().ok(tr(32004), tr(32005))
            return False, eqid, desc, is_playing, eq_profile, is_dyn
        # all ok
        return True, eqid, desc, is_playing, eq_profile, is_dyn
Example #4
0
    def on_pulse_connect(self):
        log("pact: start pulse control")
        self.pc.start()
        self.padb.on_pa_connect()
        self.pamm.on_pa_connect()

        SocketCom("kodi").call_func("up", "service", [])
        SocketCom("kodi").call_func("get", "player", [])
Example #5
0
 def sel_new_profile(self):
     # Name for new Profile
     profile = xbmcgui.Dialog().input(tr(32017))
     if profile != '':
         SocketCom("server").call_func("save", "eq_profile", [profile])
         SocketCom("server").call_func("load", "eq_profile",
                                       [self.eqid, profile])
     self.sel_profile()
Example #6
0
    def __init__(self, *args, **kwargs):
        self.sock = SocketCom("server")
        self.cwd = args[1]
        self.sock = SocketCom("server")
        self.eqid = kwargs["eqid"]
        self.desc = kwargs["desc"]

        self.tmp_fn = self.sock.path + "graph_%s.png"
        self.cnt = 0
Example #7
0
    def __init__(self, *_args, **kwargs):
        self.sock = SocketCom("server")
        self.rec = SocketCom("sweep")

        self.channel = kwargs["channel"]
        self.count = kwargs["count"]

        result = self.sock.call_func("get", "eq_channel")
        if result is None: return

        self.eqid, self.name, _ = (result)

        self.rec.start_func_server(self)
Example #8
0
    def sel_delete_correction(self):
        corrections = SocketCom("server").call_func("get", "room_corrections")

        if not corrections: return

        nr = contextMenu(items=corrections)
        if nr is None: return

        del_correction = corrections[nr]
        # sure to delete
        if xbmcgui.Dialog().yesno(
                tr(32030) % del_correction,
                tr(32031) % del_correction) is True:
            SocketCom("server").call_func("remove", "room_correction",
                                          [del_correction])
        self.sel_correction()
Example #9
0
	def __init__( self, *args, **_kwargs ):
		self.cwd = args[1]
		self.skin = args[2]

		self.sock = SocketCom("server")

		result = self.sock.call_func("get","eq_channel")
		if result is None: return

		self.eqid, self.name, channel = (result)

		self.channel_id = channel

		ch_index = []
		for ch_name in channel:
			try:
				index = chan_num.index(ch_name)
				ch_index.append(index)
			except Exception as e: opthandle(e)

		self.channel = ch_index

		self.profiles = [tr(32413)] + self.sock.call_func("get","eq_profiles")
		self.save_profile = self.sock.call_func("get","eq_base_profile")
		self.sock.call_func("unload","eq_profile",[self.eqid])

		self.corrections =[tr(32411)] + self.sock.call_func("get","room_corrections")
		self.save_correction = self.sock.call_func("get","room_correction")
		self.sock.call_func("unset","room_correction" , [self.eqid])
Example #10
0
    def sel_delete_profile(self):
        profiles = SocketCom("server").call_func("get", "eq_profiles")

        if not profiles: return

        nr = contextMenu(items=profiles)
        if nr is None: return

        # sure to delete
        del_profile = profiles[nr]
        if xbmcgui.Dialog().yesno(
                tr(32018) % del_profile,
                tr(32019) % del_profile) is True:
            SocketCom("server").call_func("remove", "eq_profile",
                                          [del_profile])
        self.sel_profile()
Example #11
0
    def __init__(self, *args, **kwargs):
        self.sock = SocketCom("server")

        self.path = os.path.join(args[1],
                                 "resources/skins/" + args[2] + "/media")

        self.progress1 = None
        self.updown = kwargs["updown"]

        try:
            step = (float(get_user_setting("sysvolstep", 0)) + 1) / 100
        except Exception:
            step = float(0.01)
        if step <= 0: step = float(0.01)

        self.dyn_step = DynStep(step, 0.05, 0.01, 3)

        self.key_up = None
        self.key_down = None
        self.updating = False

        self.vol = self.sock.call_func("get", "volume")
        if self.updown == "up":
            self.vol_up()
        elif self.updown == "down":
            self.vol_down()

        self.last = time.time()

        if self.updown != "none":
            threading.Thread(target=self.check_close).start()
Example #12
0
    def sel_correction(self):
        func_available, eqid, _, _, _, _ = self.check_func_available()
        if not func_available: return

        corrections = SocketCom("server").call_func("get", "room_corrections")
        correction = SocketCom("server").call_func("get", "room_correction")
        if correction is None: correction = tr(32411)

        corrections = [tr(32411)] + corrections

        funcs = [(tr(32033), self.sel_import_correction),
                 (tr(32028), self.sel_delete_correction),
                 (tr(32032), self.sel_playsweep)]

        sel = contextMenu(items=corrections, default=correction, funcs=funcs)

        if sel is None: return
        if sel == 0:
            SocketCom("server").call_func("unset", "room_correction", [eqid])
            return

        SocketCom("server").call_func("set", "room_correction",
                                      [eqid, corrections[sel]])
Example #13
0
    def __init__(self, gid=0):
        self.service_owner = False
        self.running = False
        self.pulseloop = False

        self.gid = gid
        self.sock = SocketCom("server")

        self.q = Queue()
        self.mc = MessageCentral()

        #allow only one instance of the server
        if not self.sock.is_server_running():
            self.start_event_loop()
            self.service_owner = True
        else:
            log("pase: server alreay running, don't start")
Example #14
0
    def on_pa_connect(self):
        log("pamm: start paModuleManager")
        try:
            self.load_dyn_equalizer()
            self.eq_fatal = False
        except Exception as e:
            self.eq_fatal = True
            handle(e)
            logerror("cannot load pulseaudio-equalizer, maybe not installed?")
            logerror("run: sudo apt install pulseaudio-equalizer")
            return None

        self.config.load_config()

        self.load_required_module("module-dbus-protocol")

        self.eq.on_pa_connect()

        sock = SocketCom("kodi")
        player = sock.call_func("get", "player")
        if player and len(player) > 0: self.on_player_play()
        else: self.on_player_stop()
Example #15
0
    def sel_device():
        response = xbmc.executeJSONRPC(
            '{"jsonrpc":"2.0", "method":"Settings.GetSettings", "params":{ "filter": {"section":"system", "category":"audio"}}, "id":1}'
        )
        r_dict = json.loads(response)

        settings = r_dict["result"]["settings"]
        for s in settings:
            if s["id"] == "audiooutput.audiodevice":
                value = s["value"]
                options = s["options"]

                sel_lables = []
                sel_values = []
                preselect = 0
                index = 0
                for o in options:
                    if "eq-auto-load" in o["value"]: continue

                    if o["value"] == value:
                        preselect = index

                    sel_values.append(o["value"])
                    sel_lables.append(o["label"].replace("(PULSEAUDIO)", ''))
                    index = index + 1

        # device selection Dialog

        sel = contextMenu(items=sel_lables,
                          default=sel_lables[preselect],
                          width=1000)

        if sel is None: return

        response = xbmc.executeJSONRPC(
            '{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"audiooutput.audiodevice", "value":"%s"}, "id":1}'
            % (sel_values[sel]))
        SocketCom("server").call_func("set", "device", [sel_values[sel]])
Example #16
0
    def __init__(self, *args, **kwargs):
        self.build_dialog(**kwargs)

        self.index = None
        self.updating = False
        self.controlId = 2000

        self.cwd = args[1]
        self.sock = SocketCom("server")
        self.eqid = kwargs["eqid"]
        self.desc = kwargs["desc"]
        try:
            step = int(get_user_setting("equalstep", 0)) + 1
        except Exception:
            step = int(1)

        self.dyn_step = DynStep(step, 5, 1, 3)

        self.sock.call_func("set", "eq_frequencies", [self.freqs])
        self.profile = self.sock.call_func("get", "eq_base_profile")

        self.preamp, self.coef = self.sock.call_func("get", "eq_filter")
        self.is_changed = False
Example #17
0
 def proc_device(self):
     self.output_sink = None
     sock = SocketCom("kodi")
     device = sock.call_func("get", "device")
     if device: self.proc_device_set(device)
Example #18
0
 def __init__(self, *_args, **_kwargs):
     self.sock = SocketCom("server")
     self.latency_info = self.sock.call_func("get", "latency")
     self.save = self.latency_info.copy()
Example #19
0
 def sel_load_defaults(self):
     # load predefined
     SocketCom("server").call_func("set", "eq_defaults")
     self.sel_profile()
Example #20
0
#	Copyright (C) 2021 wastis    https://github.com/wastis/PulseEqualizerGui
#
#	PulseEqualizerGui is free software; you can redistribute it and/or modify
#	it under the terms of the GNU Lesser General Public License as published
#	by the Free Software Foundation; either version 3 of the License,
#	or (at your option) any later version.

import sys

sys.path.append('./resources/lib/')
sys.path.append('./fakekodi')

from helper import SocketCom

#sc = SocketCom("sound")
sc = SocketCom("server")
if not sc.is_server_running():
    print("server is not running")
    sys.exit(0)

try:
    func = sys.argv[1]

    if func == "exit":
        sc.stop_server()
        sys.exit(0)

    target = sys.argv[2]
    try:
        args = []
        for arg in sys.argv[3:]:
Example #21
0
    def sweep_play_loop(self, count, channel, vol):
        if not self.player_proc:
            if not self.on_pulseplayer_start(channel): return False

        self.playing = True
        self.stop = False

        log("soge: sweep start")

        socket = SocketCom("sweep")
        sock_up = socket.is_server_running()
        if sock_up: log("soge: sweep server is up")

        sampleRate = float(self.cur_eq.sample_spec["rate"])
        chunk = int(sampleRate / 4)
        chunk_duration = float(0.25)

        #
        # prepare Sound
        #

        total_chunk = 20 * count
        cur_chunk = 0

        chunk_list = []
        pos = 0
        for c in range(20):
            base = c * chunk
            samples = array('f', [])
            for f in range(chunk):
                step = float((base + f)) / (sampleRate * 10)
                samples.append(float(sin(2 * pos * pi) * vol))
                pos = pos + step
            chunk_list.append(samples)
        cur_chunk = 0

        #
        # play Sound
        #

        for cnt in range(count):
            if sock_up: socket.send("play", "sound", [count - cnt])
            c = 0

            for samples in chunk_list:
                if sock_up:
                    socket.send("play", "chunk",
                                [c, 20, cur_chunk, total_chunk])
                self.player_proc.stdin.write(samples)

                if self.stop: break
                cur_chunk = cur_chunk + 1
                c = c + 1
                if cur_chunk > 2: sleep(chunk_duration)
            if self.stop: break

        sleep(4 * chunk_duration)

        log("soge: sweep has finished")
        self.stop = False
        self.playing = False
        if sock_up: socket.send("stop", "sound")
        self.on_pulseplayer_stop()