-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathParametricEqGen.py
113 lines (101 loc) · 4.14 KB
/
ParametricEqGen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/python3
import os
import sys
import tkinter.filedialog
# txt file picker
txt_file = tkinter.filedialog.askopenfilename(title="Choose txt file", filetypes=[("text files", ".txt")])
# askopenfilename returns tuple. If exits, it returns empty tuple
if (txt_file is None or txt_file == () or txt_file == ''):
sys.exit()
output_file = open("sink-eq6.conf", "w+")
# Commentary
output_file.write("\
# sink-eq6.conf \n\
# \n\
# 10 band (or any band, originally, it's 6 band) sink equalizer \n\
# \n\
# Copy this file into a conf.d/ directory such as \n\
# ~/.config/pipewire/pipewire.conf.d/ \n\
# \n\
# Edit it for your needs and then restart pipewire service \n\
# systemctl --user restart pipewire.service \n\
# \n\n")
output_file = open("sink-eq6.conf", "a+")
# Beginning of conf
output_file.write('\
context.modules = [ \n\
{ name = libpipewire-module-filter-chain \n\
args = { \n\
node.description = "Pipewire Equalizer" \n\
media.name = "Pipewire Equalizer" \n\
filter.graph = { \n\
nodes = [ \n')
with open(txt_file, "r") as input_file:
# read first string, useless for now
string = input_file.readline().strip()
# LOWSHELF
output_file.write('\
{ \n\
type = builtin \n\
name = eq_band_1 \n\
label = bq_lowshelf \n')
# read second string for 'lowshelf'
string = input_file.readline().strip() # strip is to prevent \n at the end of the line
output_file.write('\
control = { "Freq" = ' + string.split(" ")[5] + ' "Q" = ' + string.split(" ")[11] + ' "Gain" = ' + string.split(" ")[8] + ' }\n\
}')
# PEAKS
peaks = 8
# read and write parameters for 'peaks'
for i in range(peaks):
string = input_file.readline().strip()
output_file.write('\n\
{ \n\
type = builtin \n\
name = eq_band_' + str(i+2) + '\n\
label = bq_peaking \n\
control = { "Freq" = ' + string.split(" ")[5] + ' "Q" = ' + string.split(" ")[11] + ' "Gain" = ' + string.split(" ")[8] + ' }\n\
}')
# HIGHSHELF
output_file.write('\n\
{ \n\
type = builtin \n\
name = eq_band_10 \n\
label = bq_highshelf \n')
# read 10th string for 'highshelf'
string = input_file.readline().strip() # strip is to prevent \n at the end of the line
output_file.write('\
control = { "Freq" = ' + string.split(" ")[5] + ' "Q" = ' + string.split(" ")[11] + ' "Gain" = ' + string.split(" ")[8] + ' }\n\
}')
output_file.write('\n\
] \n\
links = [ \n\
{ output = "eq_band_1:Out" input = "eq_band_2:In" } \n\
{ output = "eq_band_2:Out" input = "eq_band_3:In" } \n\
{ output = "eq_band_3:Out" input = "eq_band_4:In" } \n\
{ output = "eq_band_4:Out" input = "eq_band_5:In" } \n\
{ output = "eq_band_5:Out" input = "eq_band_6:In" } \n\
{ output = "eq_band_6:Out" input = "eq_band_7:In" } \n\
{ output = "eq_band_7:Out" input = "eq_band_8:In" } \n\
{ output = "eq_band_8:Out" input = "eq_band_9:In" } \n\
{ output = "eq_band_9:Out" input = "eq_band_10:In" } \n\
] \n\
} \n\
audio.channels = 2 \n\
audio.position = [ FL FR ] \n\
capture.props = { \n\
node.name = "effect_input.eq6" \n\
media.class = Audio/Sink \n\
} \n\
playback.props = { \n\
node.name = "effect_output.eq6" \n\
node.passive = true \n\
} \n\
} \n\
} \n\
]')
output_file.close()
input_file.close()
os.system("mkdir -p ~/.config/pipewire/pipewire.conf.d")
os.system("cp -u sink-eq6.conf ~/.config/pipewire/pipewire.conf.d/")
os.system("systemctl --user restart pipewire.service")