-- luacheck: ignore 111 113
local args = {
  ["node.description"] = "Noise Canceling Source",
  ["media.name"]       = "Noise Canceling Source",
}

args["filter.graph"] = Json.Object {
  nodes = Json.Array {
    Json.Object {
      type    = "ladspa",
      name    = "rnnoise",
      plugin  = "/usr/lib/ladspa/librnnoise_ladspa.so",
      label   = "noise_suppressor_mono",
      control = Json.Object {
        ["VAD Threshold (%)"]          = 50.0,
        ["VAD Grace Period (ms)"]      = 200.0,
        ["Retroactive VAD Grace (ms)"] = 0.0
      },
    },
  },
}

args["capture.props"] = Json.Object {
  ["node.name"]    = "capture.rnnoise_source",
  ["node.passive"] = "true",
  ["audio.rate"]   = 48000,
}

args["playback.props"] = Json.Object {
  ["node.name"]   = "rnnoise_source",
  ["media.class"] = "Audio/Source",
  ["audio.rate"]  = 48000,
}

local args_json   = Json.Object(args)
local args_string = args_json:get_data()
local properties  = {}

print("Loading Noise Canceling Source with arguments = ")
print(args_string)

filter_chain = LocalModule("libpipewire-module-filter-chain", args_string, properties)
