# $Id: .asoundrc,v 1.3 2012/03/08 19:19:31 raman Exp raman $
# Under pipewire, install pipewire-alsa to use this as before.
# {{{crossfeed (bs2b):
## Adding these stanzas to your .asoundrc or /etc/asound.conf will
## create an ALSA output device called 'crossfeed' which outputs
## the bs2b crossfeed stream to a device of your choosing.

## LADSPA uses a 32-bit floating-point sample format, while most
## software uses 16-, 24-, or 32-bit integer formats. We input through
## a plug device to handle the conversion.

pcm.crossfeed {
  type plug
  slave.pcm "bs2b"
}

## If you use dmix or other processing filters, you should slave the
## plug:bs2b device to them directly, then have bs2b play to the hardware.
## This will minimize the impact of sample format conversion.

## This device passes its input through the bs2b LADSPA plugin, then
## passes it off to another PCM device. In this example, we use
## plughw:0,0 to pass directly to hardware (with a plug adapter for
## sample conversion).
pcm.bs2b {
  type ladspa
  slave.pcm "default" # Set this line to match your configuration
  path "/usr/lib/ladspa/"
  plugins [{
    label bs2b
    input {
#      controls [ 725 4.5 ] # The defaults are 725Hz crossover frequency and 4.5dB rolloff
    }
  }]
}

# }}}
# {{{An amp device:
pcm.amp {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default" # Set this line to match your configuration
        path "/usr/lib/ladspa/"
        plugins [
            {
                label amp_stereo
                input {
                    #double volume 
                    controls [ 2  ]
                }
            }]
    }
}


# }}}
# {{{tap_reverb:

pcm.tap_reverb {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default" # Set this line to match your configuration
        path "/usr/lib/ladspa/"
        plugins [{
                    label tap_reverb
                    input {
                        controls [1800 0 -17 1 1 1 1 4] # Ambiance
                    }
                }]
    }
}

# }}}
# {{{autopan:

pcm.autopan {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default" # Set this line to match your configuration
        path "/usr/lib/ladspa/"
        plugins [{
                    label tap_autopan
                    input {controls [0.016 75 2 ]}
                }
                 {
                     label tap_autopan
                     input {controls [0.06 33 2]}
                 }]
    }
}

# }}}
# {{{reverb_crossfeed

#tap_reverb -> bs2b
pcm.reverb_crossfeed {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default"
        path "/usr/lib/ladspa/"
        plugins [
            {label tap_reverb #ambiance thick (hd)
             input {controls [2400 0 -14 1 1 1 1 4]}
            }
            {label bs2b
             input {controls [ 725 4.5 ]}
            }]
    }
}

# }}}
# {{{autopan_crossfeed

#autopan -> crossfeed
pcm.autopan_crossfeed {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default"
        path "/usr/lib/ladspa/"
        plugins [
            {label bs2b
             input {controls [ 725 4.5 ]}
            }
            {
                label tap_autopan
                input {
                    controls [0.066 66 2.5 ]
                }
            }
            {
                label tap_autopan
                input {
                    controls [0.0166 100 2.5 ]
                }
            }
        ]
    }
}

# }}}
# {{{tts_crossfeed:

pcm.tts_crossfeed{
    type upmix
    slave. pcm "crossfeed"
}

# }}}
# {{{tts_reverb:

pcm.tts_reverb {
    type upmix
    slave. pcm "tap_reverb"
}

# }}}
# {{{tts_reverb_crossfeed:

pcm.tts_reverb_crossfeed {
    type upmix
    slave. pcm "reverb_crossfeed"
}

# }}}
# {{{tts_autopan_crossfeed:

pcm.tts_autopan_crossfeed {
    type upmix
    slave. pcm "autopan_crossfeed"
}

# }}}
# {{{tts_autopan:

pcm.tts_autopan {
    type upmix
    slave.pcm "autopan"
}

# }}}
# {{{A Soft left device:

pcm.soft_left {
    type plug
    slave.pcm {
        type route
        slave.pcm "default"
        ttable {
            0.0 =  0.35
            0.1 = 0.03
            1.0 =  0.35
            1.1 = 0.03
        }
    }
} 

# }}}
# {{{TTS Mono:

#  The Route plugin routes audio among channles using a TTable .
#TTable is a transfer table.
# Matrix of Source->Destination values
# Unspecified entries default to 0.
# Format: Source.Destination = Value

pcm.tts_mono_right {
    type upmix
    slave.pcm {
        type route
        slave.pcm "default"
        ttable.0.1 = 1
        ttable.1.1 = 1 
    }
}

pcm.tts_mono_left {
    type upmix
    slave.pcm {
        type route
        slave.pcm "default"
        ttable.0.0=1
        ttable.1.0 = 1
    }
}

pcm.tts_mid_left {
    type upmix
    slave.pcm {
        type route
        slave.pcm "default"
        ttable {
            0.0 =  0.66
            0.1 = 0.33
            1.0 =  0.66
            1.1 = 0.33
        }
    }
}


pcm.tts_mid_right {
    type upmix
    slave.pcm {
        type route
        slave.pcm "default"
        ttable {
            0.1 =  0.66
            0.0 = 0.33
            1.1 =  0.66
            1.0 = 0.33
        }
    }
}
#quarters
pcm.tts_quarter_left {
    type upmix
    slave.pcm {
        type route
        slave.pcm "default"
        ttable {
            0.0 =  0.75
            0.1 = 0.25
            1.0 =  0.75
            1.1 = 0.25
        }
    }
}

pcm.tts_quarter_right {
    type upmix
    slave.pcm {
        type route
        slave.pcm "default"
        ttable {
            0.0 =  0.25
            0.1 = 0.75
            1.0 =  0.25
            1.1 = 0.75
        }
    }
}

# }}}
# {{{ HRTF Devices Using Zam Plugin:

# Notes:
#  Zam Plugins from https://github.com/zamaudio/zam-plugins.git
# Azimuth:   Clockwise: -90..270 --- 0 is North.
# Elevation: -45 .. 90

pcm.tts_a45_e45 {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default" # Set this line to match your configuration
        path "/usr/lib/ladspa/"
        plugins [{
                    label ZamHeadX2
                    input {controls [45 45 2.5 ]}
                }
                ]
    }
}

pcm.tts_a135_e45 {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default" # Set this line to match your configuration
        path "/usr/lib/ladspa/"
        plugins [{
                    label ZamHeadX2
                    input {controls [135 45 2.5 ]}
                }
                ]
    }
}

pcm.tts_a225_e45 {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default" # Set this line to match your configuration
        path "/usr/lib/ladspa/"
        plugins [{
                    label ZamHeadX2
                    input {controls [225 45 2.5 ]}
                }
                ]
    }
}

pcm.tts_am45_e45 {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default" # Set this line to match your configuration
        path "/usr/lib/ladspa/"
        plugins [{
                    label ZamHeadX2
                    input {controls [-45 45 2.5 ]}
                }
                ]
    }
}

# negative Elevation:

pcm.tts_a45_em45 {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default" # Set this line to match your configuration
        path "/usr/lib/ladspa/"
        plugins [{
                    label ZamHeadX2
                    input {controls [45 -45 2.5 ]}
                }
                ]
    }
}

pcm.tts_a135_em45 {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default" # Set this line to match your configuration
        path "/usr/lib/ladspa/"
        plugins [{
                    label ZamHeadX2
                    input {controls [135 -45 2.5 ]}
                }
                ]
    }
}

pcm.tts_a225_em45 {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default" # Set this line to match your configuration
        path "/usr/lib/ladspa/"
        plugins [{
                    label ZamHeadX2
                    input {controls [225 -45 2.5 ]}
                }
                ]
    }
}

pcm.tts_am45_em45 {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default" # Set this line to match your configuration
        path "/usr/lib/ladspa/"
        plugins [{
                    label ZamHeadX2
                    input {controls [-45 -45 2.5 ]}
                }
                ]
    }
}

#0 azimuth, various elevations:

pcm.tts_a0_em45 {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default" # Set this line to match your configuration
        path "/usr/lib/ladspa/"
        plugins [{
                    label ZamHeadX2
                    input {controls [0 -45 2.5 ]}
                }
                ]
    }
}

pcm.tts_a0_e45 {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default" # Set this line to match your configuration
        path "/usr/lib/ladspa/"
        plugins [{
                    label ZamHeadX2
                    input {controls [0 45 2.5 ]}
                }
                ]
    }
}


pcm.tts_a0_e90 {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default" # Set this line to match your configuration
        path "/usr/lib/ladspa/"
        plugins [{
                    label ZamHeadX2
                    input {controls [0 90 2.5 ]}
                }
                ]
    }
}

pcm.tts_a0_em30 {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default" # Set this line to match your configuration
        path "/usr/lib/ladspa/"
        plugins [{
                    label ZamHeadX2
                    input {controls [0 -30 2.5 ]}
                }
                ]
    }
}

pcm.tts_a0_em15 {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default" # Set this line to match your configuration
        path "/usr/lib/ladspa/"
        plugins [{
                    label ZamHeadX2
                    input {controls [0 -15 2.5 ]}
                }
                ]
    }
}

pcm.tts_a0_e15 {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default" # Set this line to match your configuration
        path "/usr/lib/ladspa/"
        plugins [{
                    label ZamHeadX2
                    input {controls [0 15 2.5 ]}
                }
                ]
    }
}

pcm.tts_a0_e30 {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default" # Set this line to match your configuration
        path "/usr/lib/ladspa/"
        plugins [{
                    label ZamHeadX2
                    input {controls [0 30 2.5 ]}
                }
                ]
    }
}

pcm.tts_a0_e60 {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default" # Set this line to match your configuration
        path "/usr/lib/ladspa/"
        plugins [{
                    label ZamHeadX2
                    input {controls [0 60 2.5 ]}
                }
                ]
    }
}

# }}}
# {{{Equal:

ctl.equal {type equal}

pcm.equal{
    type plug;
    slave.pcm{
        type equal
        slave.pcm "default"
    }
}

# }}}
# {{{Save2File:
# outloud produces save.wav channels 1, rate 11025 format S16_LE
# aplay -r 11025 -f s16_le save.wav
pcm.save2file {
    type file
    slave.pcm "default"
    file "save.wav"
}

# }}}
# {{{ matrixSpatializer

pcm.spatial {
    type plug
    slave.pcm {
        type ladspa
        slave.pcm "default" # Set this line to match your configuration
        path "/usr/lib/ladspa/"
        plugins [{
                    label matrixSpatialiser
                    input {controls [256 ]}
                }
                ]
    }
}

# }}}
# {{{end of file

# local variables:
# mode: sh
# folded-file: t
# end:

# }}}
