Skip to content

Instantly share code, notes, and snippets.

@v1kko
Created October 26, 2022 12:20
Show Gist options
  • Save v1kko/77ad90f278e138acac0219376d7be09a to your computer and use it in GitHub Desktop.
Save v1kko/77ad90f278e138acac0219376d7be09a to your computer and use it in GitHub Desktop.
Convert your REW filters (text format) to ACDf format to use with alsa
# Use as python3 REW_to_ACDf.py filter.txt
# where filter.txt is the text exported REW filters
# License GPLv3.0
# Copyright Victor Azizi 2022
import sys
import re
#Header
print("""pcm.!default {
type plug
slave {
pcm "klipsch";
}
}
pcm.klipsch {
type ladspa
path "/usr/lib/ladspa"
channels 2
slave {
pcm "plughw:1,0"
}
plugins {""")
pattern = re.compile(r'Filter +[1-9]+: +ON +PK +Fc +([0-9\.]+) Hz +Gain +([\-0-9.]+) +dB +Q +([0-9\.]+)')
with open(sys.argv[1]) as f:
count = 0
for line in f.readlines():
m = pattern.match(line)
if not m:
continue
freq = float(m.group(1))
gain = float(m.group(2))
qual = float(m.group(3))
for chan in (0,1):
print(f""" {count} {{
label ACDf
policy none
input.bindings.{chan} "Input"
output.bindings.{chan} "Output"
input {{ controls [26 1 {gain} {freq} {qual} 1 1]}}
}}""")
count = count + 1
print(""" }
}""")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment