5 python ladspa-dbus.py <sinkname> [values]
7 The "sinkname" parameter is the name of the ladspa sink. The "values"
8 parameter is a comma-separated list of ladspa sink parameter values. A
9 value in the list can be either string "default" or a float.
13 python ladspa-dbus.py ladspa_1 10.0,default,4.0,0.6,default
15 This command will configure sink "ladspa_1" by setting the first value
16 to 10.0, the second to the default value (specified in the ladspa
17 filter), the third to 4.0 and so on.
24 def get_ladspa_property_interface(sinkname
):
26 # do some D-Bus stuff to get to the real ladspa property object
27 session
= dbus
.SessionBus()
29 # get the private D-Bus socket address from PulseAudio properties
30 session_property_iface
= dbus
.Interface(session
.get_object("org.PulseAudio1", "/org/pulseaudio/server_lookup1"), "org.freedesktop.DBus.Properties")
31 socket
= session_property_iface
.Get("org.PulseAudio.ServerLookup1", "Address")
33 # connect to the private PulseAudio D-Bus socket
34 connection
= dbus
.connection
.Connection(socket
)
36 # core object for listing the sinks
37 core
= connection
.get_object(object_path
="/org/pulseaudio/core1")
39 # object path to the ladspa sink
40 ladspa_sink_path
= core
.GetSinkByName(sinkname
)
42 # property interface proxy for the sink
43 ladspa_sink_property_iface
= dbus
.Interface(connection
.get_object(object_path
=ladspa_sink_path
), "org.freedesktop.DBus.Properties")
45 return ladspa_sink_property_iface
47 def parse_arguments(args
):
57 tokens
= args
[2].split(",")
60 if token
== "default":
64 arguments
.append(float(token
))
65 defaults
.append(False)
68 print("Input arguments:")
69 print(" sink: " + sink)
70 print(" arguments: " + str(arguments))
71 print(" defaults: " + str(defaults))
74 return sinkname
, arguments
, defaults
76 def print_arguments(arguments
, defaults
):
77 for i
in range(len(arguments
)):
81 print(str(i
) + " : " + str(arguments
[i
]) + " \t" + default
)
84 sinkname
, arguments
, defaults
= parse_arguments(sys
.argv
)
90 # get the D-Bus property interface of the sink
91 ladspa
= get_ladspa_property_interface(sinkname
)
93 # read the current sink arguments from PulseAudio
94 oldarguments
, olddefaults
= ladspa
.Get("org.PulseAudio.Ext.Ladspa1", "AlgorithmParameters")
96 print("Current LADSPA parameters for sink " + sinkname
+ ":")
97 print_arguments(oldarguments
, olddefaults
)
99 if len(arguments
) != 0:
100 # set new arguments if they were provided on the command line
102 # Set the arguments ...
103 ladspa
.Set("org.PulseAudio.Ext.Ladspa1", "AlgorithmParameters", (dbus
.Array(arguments
), dbus
.Array(defaults
)))
105 # ... and read them back.
106 newarguments
, newdefaults
= ladspa
.Get("org.PulseAudio.Ext.Ladspa1", "AlgorithmParameters")
108 print("New LADSPA parameters for sink " + sinkname
+ ":")
109 print_arguments(newarguments
, newdefaults
)
111 # test the GetAll functionality
112 # print(str(ladspa.GetAll("org.PulseAudio.Ext.Ladspa1")))