Debian Codegraph @

tests/examples/filter-chain.lua

raw
1 #!/usr/bin/wpexec
2 --
3 -- WirePlumber
4 --
5 -- Copyright © 2022 Collabora Ltd.
6 -- @author George Kiagiadakis <[email protected]>
7 --
8 -- SPDX-License-Identifier: MIT
9 --
10 -- This is an example of how to load a pipewire module that takes a JSON
11 -- string as arguments.
12 --
13 -- For illustration purposes, this loads module-filter-chain with a 6-band
14 -- equalizer. This is the same configuration found in the sink-eq6.conf
15 -- file that can be found in pipewire's source tree.
16 -----------------------------------------------------------------------------
17
18 -- For illustration purposes, we declare 'args' here as a native lua table,
19 -- we populate it in multiple steps and we transform it later to a json object
20 local args = {
21 ["node.description"] = "Equalizer Sink",
22 ["media.name"] = "Equalizer Sink",
23 ["audio.channels"] = 2,
24 ["audio.position"] = Json.Array { "FL", "FR" },
25 }
26
27 args["filter.graph"] = Json.Object {
28 nodes = Json.Array {
29 Json.Object {
30 type = "builtin",
31 name = "eq_band_1",
32 label = "bq_lowshelf",
33 control = Json.Object { Freq = 100.0, Q = 1.0, Gain = 0.0 },
34 },
35 Json.Object {
36 type = "builtin",
37 name = "eq_band_2",
38 label = "bq_peaking",
39 control = Json.Object { Freq = 100.0, Q = 1.0, Gain = 0.0 },
40 },
41 Json.Object {
42 type = "builtin",
43 name = "eq_band_3",
44 label = "bq_peaking",
45 control = Json.Object { Freq = 500.0, Q = 1.0, Gain = 0.0 },
46 },
47 Json.Object {
48 type = "builtin",
49 name = "eq_band_4",
50 label = "bq_peaking",
51 control = Json.Object { Freq = 2000.0, Q = 1.0, Gain = 0.0 },
52 },
53 Json.Object {
54 type = "builtin",
55 name = "eq_band_5",
56 label = "bq_peaking",
57 control = Json.Object { Freq = 5000.0, Q = 1.0, Gain = 0.0 },
58 },
59 Json.Object {
60 type = "builtin",
61 name = "eq_band_6",
62 label = "bq_highshelf",
63 control = Json.Object { Freq = 5000.0, Q = 1.0, Gain = 0.0 },
64 },
65 },
66 links = Json.Array {
67 Json.Object { output = "eq_band_1:Out", input = "eq_band_2:In" },
68 Json.Object { output = "eq_band_2:Out", input = "eq_band_3:In" },
69 Json.Object { output = "eq_band_3:Out", input = "eq_band_4:In" },
70 Json.Object { output = "eq_band_4:Out", input = "eq_band_5:In" },
71 Json.Object { output = "eq_band_5:Out", input = "eq_band_6:In" },
72 },
73 }
74
75 args["capture.props"] = Json.Object {
76 ["node.name"] = "effect_input.eq6",
77 ["media.class"] = "Audio/Sink",
78 }
79
80 args["playback.props"] = Json.Object {
81 ["node.name"] = "effect_output.eq6",
82 ["node.passive"] = true,
83 }
84
85 -- Transform 'args' to a json object here
86 local args_json = Json.Object(args)
87
88 -- and get the final JSON as a string from the json object
89 local args_string = args_json:get_data()
90
91 local properties = {}
92
93 print("Loading module-filter-chain with arguments = ")
94 print(args_string)
95
96 filter_chain = LocalModule("libpipewire-module-filter-chain", args_string, properties)