# Convolver sink
#
# Copy this file into a conf.d/ directory such as
# ~/.config/pipewire/filter-chain.conf.d/
#
# Adjust the paths to the convolver files to match your system
#
context.modules = [
    { name = libpipewire-module-filter-chain
        flags = [ nofail ]
        args = {
            node.description = "Virtual Surround Sink"
            media.name       = "Virtual Surround Sink"
            filter.graph = {
                nodes = [
                    {
                        type  = builtin
                        label = convolver
                        name  = convFL_L
                        config = {
                            filename = "hrir_kemar/hrir-kemar.wav"
                            channel  = 0
                        }
                    }
                    {
                        type  = builtin
                        label = convolver
                        name  = convFL_R
                        config = {
                            filename = "hrir_kemar/hrir-kemar.wav"
                            channel  = 1
                        }
                    }
                    {
                        type  = builtin
                        label = convolver
                        name  = convFR_L
                        config = {
                            filename = "hrir_kemar/hrir-kemar.wav"
                            channel  = 1
                        }
                    }
                    {
                        type  = builtin
                        label = convolver
                        name  = convFR_R
                        config = {
                            filename = "hrir_kemar/hrir-kemar.wav"
                            channel  = 0
                        }
                    }
                    {
                        type  = builtin
                        label = convolver
                        name  = convFC
                        config = {
                            filename = "hrir_kemar/hrir-kemar.wav"
                            channel  = 2
                        }
                    }
                    {
                        type  = builtin
                        label = convolver
                        name  = convLFE
                        config = {
                            filename = "hrir_kemar/hrir-kemar.wav"
                            channel  = 3
                        }
                    }
                    {
                        type  = builtin
                        label = convolver
                        name  = convSL_L
                        config = {
                            filename = "hrir_kemar/hrir-kemar.wav"
                            channel  = 4
                        }
                    }
                    {
                        type  = builtin
                        label = convolver
                        name  = convSL_R
                        config = {
                            filename = "hrir_kemar/hrir-kemar.wav"
                            channel  = 5
                        }
                    }
                    {
                        type  = builtin
                        label = convolver
                        name  = convSR_L
                        config = {
                            filename = "hrir_kemar/hrir-kemar.wav"
                            channel  = 5
                        }
                    }
                    {
                        type  = builtin
                        label = convolver
                        name  = convSR_R
                        config = {
                            filename = "hrir_kemar/hrir-kemar.wav"
                            channel  = 4
                        }
                    }
                    {
                        type  = builtin
                        label = mixer
                        name  = mixL
                    }
                    {
                        type  = builtin
                        label = mixer
                        name  = mixR
                    }
                    {
                        type  = builtin
                        label = copy
                        name  = copyFL
                    }
                    {
                        type  = builtin
                        label = copy
                        name  = copyFR
                    }
                    {
                        type  = builtin
                        label = copy
                        name  = copySL
                    }
                    {
                        type  = builtin
                        label = copy
                        name  = copySR
                    }
                ]
                links = [
                    { output = "copyFL:Out"   input = "convFL_L:In" }
                    { output = "copyFL:Out"   input = "convFL_R:In" }
                    { output = "copyFR:Out"   input = "convFR_R:In" }
                    { output = "copyFR:Out"   input = "convFR_L:In" }

                    { output = "copySL:Out"   input = "convSL_L:In" }
                    { output = "copySL:Out"   input = "convSL_R:In" }
                    { output = "copySR:Out"   input = "convSR_R:In" }
                    { output = "copySR:Out"   input = "convSR_L:In" }

                    { output = "convFL_L:Out" input = "mixL:In 1" }
                    { output = "convFR_L:Out" input = "mixL:In 2" }
                    { output = "convFC:Out"   input = "mixL:In 3" }
                    { output = "convLFE:Out"  input = "mixL:In 4" }
                    { output = "convSL_L:Out" input = "mixL:In 5" }
                    { output = "convSR_L:Out" input = "mixL:In 6" }

                    { output = "convFL_R:Out" input = "mixR:In 1" }
                    { output = "convFR_R:Out" input = "mixR:In 2" }
                    { output = "convFC:Out"   input = "mixR:In 3" }
                    { output = "convLFE:Out"  input = "mixR:In 4" }
                    { output = "convSL_R:Out" input = "mixR:In 5" }
                    { output = "convSR_R:Out" input = "mixR:In 6" }
                ]
                inputs  = [ "copyFL:In" "copyFR:In" "convFC:In" "convLFE:In" "copySL:In" "copySR:In" ]
                outputs = [ "mixL:Out" "mixR:Out" ]

            }
            capture.props = {
                node.name      = "effect_input.virtual-surround-5.1-kemar"
                media.class    = Audio/Sink
                audio.channels = 6
                audio.position = [ FL FR FC LFE SL SR]
            }
            playback.props = {
                node.name      = "effect_output.virtual-surround-5.1-kemar"
                node.passive   = true
                audio.channels = 2
                audio.position = [ FL FR ]
            }
        }
    }
]
