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