# Virtual stereo sink
#
# the main purpose is to provide a junction where audio can be selectively routed *to* this device,
# and then consumers can tunnel it to some other place.
# for example, `blast` can be used to cast this sink (source) to a TV.
#
# based on: <repo:pipewire/pipewire:src/daemon/filter-chain/source-duplicate-FL.conf>
# but modified:
# - duplicate both FL *and* FR
# - don't pipe inputs into outputs
#   this effectively creates a filter who's output is always silence.
#   blast still works because it grabs from the monitor, not the output.
#   better would be to make a sink (a "virtual sink", a "null sink", or a "loopback"), which has no output at *all*,
#   but i couldn't get that to actually work (e.g. it doesn't show up in PavuControl, or it does but still forwards audio)

context.modules = [
  { name = libpipewire-module-filter-chain
    flags = [ nofail ]
    args = {
      node.description = "Virtual Sink"
      media.name       = "Virtual Sink"
      filter.graph = {
        nodes = [
          {
            name   = copyIL
            type   = builtin
            label  = copy
          }
          {
            name   = copyIR
            type   = builtin
            label  = copy
          }
          {
            name   = copyOL
            type   = builtin
            label  = copy
          }
          {
            name   = copyOR
            type   = builtin
            label  = copy
          }
        ]
        links = [
          # we can only tee from nodes, not inputs so we need
          # to copy the inputs and then tee.
          # { output = "copyIL:Out" input = "copyOL:In" }
          # { output = "copyIR:Out" input = "copyOR:In" }
        ]
        inputs  = [ "copyIL:In" "copyIR:In" ]
        outputs = [ "copyOL:Out" "copyOR:Out" ]
      }
      capture.props = {
        node.name         = "effect_input.virtual"
        media.class       = Audio/Sink
        audio.channels    = 2
        audio.position    = [ FL FR ]
      }
      playback.props = {
        node.name         = "effect_output.virtual"
        node.passive      = true
        audio.channels    = 2
        audio.position    = [ FL FR ]
      }
    }
  }
]

