Skip to content

Commit 780c031

Browse files
author
Croupier42
authored
Add files via upload
1 parent 1ac66bc commit 780c031

File tree

1 file changed

+320
-0
lines changed

1 file changed

+320
-0
lines changed

src/EqualizerAPO 1.6.ahk

Lines changed: 320 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,320 @@
1+
#SingleInstance Force
2+
3+
;Переменные
4+
global CFG := SubStr(A_ScriptName, 1, -3)"txt"
5+
global TMP := SubStr(A_ScriptName, 1, -3)"tmp"
6+
global LNK := SubStr(A_ScriptName, 1, -3)"lnk"
7+
global DeviceLabel := "DeviceLabel: Out 1-2"
8+
global DeviceLabel1 :=
9+
global DeviceLabel2 :=
10+
global DeviceLabelA := "DeviceLabelA: Out 1-2"
11+
global DeviceLabelA1 :=
12+
global DeviceLabelA2 :=
13+
global DeviceLabelB := "DeviceLabelB: Динамики"
14+
global DeviceLabelB1 :=
15+
global DeviceLabelB2 :=
16+
global IncludeLabel := "IncludeLabel: NOEMA"
17+
global IncludeLabel1 :=
18+
global IncludeLabel2 :=
19+
global Include := "Include: D:\Programs\EqualizerAPO\NOEMA\NOEMA Filters.txt"
20+
global Include1 :=
21+
global Include2 :=
22+
global IncludeLabelA := "IncludeLabelA: NOEMA"
23+
global IncludeLabelA1 :=
24+
global IncludeLabelA2 :=
25+
global IncludeA := "IncludeA: D:\Programs\EqualizerAPO\NOEMA\NOEMA Filters.txt"
26+
global IncludeA1 :=
27+
global IncludeA2 :=
28+
global IncludeLabelB := "IncludeLabelB: Chu 2"
29+
global IncludeLabelB1 :=
30+
global IncludeLabelB2 :=
31+
global IncludeB := "IncludeB: D:\Programs\EqualizerAPO\Headphones\Chu 2\Moondrop Chu 2 Filters.txt"
32+
global IncludeB1 :=
33+
global IncludeB2 :=
34+
global Preamp := "Preamp: -30 dB"
35+
global Preamp1 :=
36+
global Preamp2 :=
37+
global Preamp3 :=
38+
global PreampStep := "PreampStep: 5 dB"
39+
global PreampStep1 :=
40+
global PreampStep2 :=
41+
global PreampStep3 :=
42+
global VSTPlugin := "VSTPlugin: Library D:\Programs\VSTPlugins\LoudMax64.dll Thresh 1 Output 1 ""Fader Link"" 0 ""ISP Detection"" 1 ""Large GUI"" 1"
43+
global MonitorScale := "MonitorScale: 2"
44+
global MonitorScale1 :=
45+
global MonitorScale2 :=
46+
global Startup := "Startup: 1"
47+
global Startup1 :=
48+
global Startup2 :=
49+
50+
;Проверка на наличие Equalizer APO
51+
if !FileExist("C:\Program Files\EqualizerAPO\Editor.exe")
52+
{
53+
MsgBox,,, Для начала нужно установить Equalizer APO!, 3
54+
Run, https://sourceforge.net/projects/equalizerapo/
55+
exitapp
56+
}
57+
58+
;Первоначальная настройка
59+
if !FileExist(CFG)
60+
{
61+
MsgBox, 4,, Добавить конфигурационный файл в Equalizer APO?, 3
62+
IfMsgBox Yes
63+
{
64+
EAPO := "C:\Program Files\EqualizerAPO\config\config.txt"
65+
if FileExist(EAPO)
66+
{
67+
ADDCFG := SubStr(A_ScriptFullPath, 1, -3)"txt"
68+
FileAppend, `nInclude: %ADDCFG%, %EAPO%
69+
}
70+
else
71+
{
72+
MsgBox,,, %EAPO% не найден!, 1
73+
}
74+
}
75+
MsgBox, 4,, Перейти на страницу проекта?, 3
76+
IfMsgBox Yes
77+
{
78+
Run, https://github.com/Croupier42/EqualizerAPO.ahk
79+
}
80+
WriteCFG()
81+
}
82+
83+
;Считывание конфиг файла
84+
FileRead, File, %CFG% ;Считывание конфиг файла
85+
RegExMatch(File, "(DeviceLabel:) (.*)", DeviceLabel)
86+
RegExMatch(File, "(DeviceLabelA:) (.*)", DeviceLabelA)
87+
RegExMatch(File, "(DeviceLabelB:) (.*)", DeviceLabelB)
88+
RegExMatch(File, "(IncludeLabel:) (.*)", IncludeLabel)
89+
RegExMatch(File, "(Include:) (.*)", Include)
90+
RegExMatch(File, "(IncludeLabelA:) (.*)", IncludeLabelA)
91+
RegExMatch(File, "(IncludeA:) (.*)", IncludeA)
92+
RegExMatch(File, "(IncludeLabelB:) (.*)", IncludeLabelB)
93+
RegExMatch(File, "(IncludeB:) (.*)", IncludeB)
94+
RegExMatch(File, "(Preamp:) (.*) (.*)", Preamp) ;Поиск и разделение переменной на Preamp1 "Preamp:", Preamp2 "-30", Preamp3 "dB"
95+
RegExMatch(File, "(PreampStep:) (.*) (.*)", PreampStep) ;Поиск и разделение переменной на PreampStep1 "PreampStep:", PreampStep2 "5", PreampStep3 "dB"
96+
RegExMatch(File, "(.*VSTPlugin:.*)", VSTPlugin) ;Поиск переменной VSTPlugin
97+
RegExMatch(File, "(MonitorScale:) (.*)", MonitorScale) ;Поиск и разделение переменной на MonitorScale1 "MonitorScale:", MonitorScale2 "1"
98+
RegExMatch(File, "(Startup:) (.*)", Startup) ;Поиск и разделение переменной на Startup1 "Startup:", Startup2 "0"
99+
100+
;Автозагрузка
101+
if (Startup2 = 1)
102+
{
103+
if !FileExist(A_Startup "\" LNK)
104+
{
105+
FileCreateShortcut, %A_ScriptFullPath%, %A_Startup%\%LNK%, %A_WorkingDir%
106+
msgbox,,, Скрипт добавлен в автозагрузку, 1
107+
}
108+
}
109+
else
110+
{
111+
if FileExist(A_Startup "\" LNK)
112+
{
113+
FileDelete, %A_Startup%\%LNK%
114+
msgbox,,, Скрипт удален из автозагрузки, 1
115+
}
116+
}
117+
118+
;Win11 like OSD
119+
SysGet, MonitorWorkArea, MonitorWorkArea, 1
120+
MonitorWidth := MonitorWorkAreaRight - MonitorWorkAreaLeft
121+
MonitorHeight := MonitorWorkAreaBottom - MonitorWorkAreaTop
122+
ControlW := (MonitorWidth // 9.89) ;384px+4px on white bg for 4k
123+
ControlH := (MonitorHeight // 22.04) ;94px+4px on white bg for 4k
124+
ControlWS := ControlW // MonitorScale2 ;194px
125+
ControlHS := ControlH // MonitorScale2 ;49px
126+
global ControlY := MonitorHeight - ControlH - (MonitorHeight // 17.7) ;122px for 4k
127+
Gui +LastFound +AlwaysOnTop -Caption +ToolWindow
128+
Gui, Color, 2C2C2C
129+
Gui, Font, s14, Tahoma
130+
Gui, Margin, 0, 0
131+
Gui, Add, Text, vOSDText c4CC2FF w%ControlWS% h%ControlHS% Center
132+
WinSet, Transparent, 191
133+
134+
;Смена устройства вывода звука, взято отсюда https://www.autohotkey.com/boards/viewtopic.php?f=76&t=49980#p221777
135+
Devices := {}
136+
IMMDeviceEnumerator := ComObjCreate("{BCDE0395-E52F-467C-8E3D-C4579291692E}", "{A95664D2-9614-4F35-A746-DE8DB63617E6}")
137+
DllCall(NumGet(NumGet(IMMDeviceEnumerator+0)+3*A_PtrSize), "UPtr", IMMDeviceEnumerator, "UInt", 0, "UInt", 0x1, "UPtrP", IMMDeviceCollection, "UInt")
138+
ObjRelease(IMMDeviceEnumerator)
139+
DllCall(NumGet(NumGet(IMMDeviceCollection+0)+3*A_PtrSize), "UPtr", IMMDeviceCollection, "UIntP", Count, "UInt")
140+
Loop % (Count)
141+
{
142+
DllCall(NumGet(NumGet(IMMDeviceCollection+0)+4*A_PtrSize), "UPtr", IMMDeviceCollection, "UInt", A_Index-1, "UPtrP", IMMDevice, "UInt")
143+
DllCall(NumGet(NumGet(IMMDevice+0)+5*A_PtrSize), "UPtr", IMMDevice, "UPtrP", pBuffer, "UInt")
144+
DeviceID := StrGet(pBuffer, "UTF-16"), DllCall("Ole32.dll\CoTaskMemFree", "UPtr", pBuffer)
145+
DllCall(NumGet(NumGet(IMMDevice+0)+4*A_PtrSize), "UPtr", IMMDevice, "UInt", 0x0, "UPtrP", IPropertyStore, "UInt")
146+
ObjRelease(IMMDevice)
147+
VarSetCapacity(PROPVARIANT, A_PtrSize == 4 ? 16 : 24)
148+
VarSetCapacity(PROPERTYKEY, 20)
149+
DllCall("Ole32.dll\CLSIDFromString", "Str", "{A45C254E-DF1C-4EFD-8020-67D146A850E0}", "UPtr", &PROPERTYKEY)
150+
NumPut(14, &PROPERTYKEY + 16, "UInt")
151+
DllCall(NumGet(NumGet(IPropertyStore+0)+5*A_PtrSize), "UPtr", IPropertyStore, "UPtr", &PROPERTYKEY, "UPtr", &PROPVARIANT, "UInt")
152+
DeviceName := StrGet(NumGet(&PROPVARIANT + 8), "UTF-16")
153+
DllCall("Ole32.dll\CoTaskMemFree", "UPtr", NumGet(&PROPVARIANT + 8))
154+
ObjRelease(IPropertyStore)
155+
ObjRawSet(Devices, DeviceName, DeviceID)
156+
}
157+
ObjRelease(IMMDeviceCollection)
158+
Return
159+
160+
;Fn+F9
161+
$Media_Stop::
162+
if (DeviceLabel2 == DeviceLabelA2)
163+
{
164+
DeviceLabel2 = %DeviceLabelB2%
165+
DeviceLabel = %DeviceLabel1% %DeviceLabel2%
166+
SetDefaultEndpoint( GetDeviceID(Devices, DeviceLabel2) )
167+
}
168+
else
169+
{
170+
DeviceLabel2 = %DeviceLabelA2%
171+
DeviceLabel = %DeviceLabel1% %DeviceLabel2%
172+
SetDefaultEndpoint( GetDeviceID(Devices, DeviceLabel2) )
173+
}
174+
WriteCFG()
175+
OSD()
176+
return
177+
178+
;Fn+F10
179+
$Volume_Mute::
180+
if (Include2 == IncludeA2)
181+
{
182+
Include2 = %IncludeB2%
183+
IncludeLabel2 = %IncludeLabelB2%
184+
Include = %Include1% %Include2%
185+
IncludeLabel = %IncludeLabel1% %IncludeLabel2%
186+
}
187+
else
188+
{
189+
Include2 = %IncludeA2%
190+
IncludeLabel2 = %IncludeLabelA2%
191+
Include = %Include1% %Include2%
192+
IncludeLabel = %IncludeLabel1% %IncludeLabel2%
193+
}
194+
WriteCFG()
195+
OSD()
196+
return
197+
198+
;Fn+F11
199+
$Volume_Down::
200+
SysVol()
201+
Preamp2 -= PreampStep2
202+
Preamp = %Preamp1% %Preamp2% %Preamp3%
203+
VSTPlugin()
204+
WriteCFG()
205+
OSD()
206+
return
207+
208+
;Fn+F12
209+
$Volume_Up::
210+
SysVol()
211+
Preamp2 += PreampStep2
212+
Preamp = %Preamp1% %Preamp2% %Preamp3%
213+
VSTPlugin()
214+
WriteCFG()
215+
OSD()
216+
return
217+
218+
;Fn+AltGr+F12
219+
$<^>!Volume_Up::
220+
Setup()
221+
return
222+
223+
;Настройка конфига
224+
Setup()
225+
{
226+
MsgBox,4 ,, Открыть mmsys.cpl?, 2
227+
IfMsgBox Yes
228+
{
229+
Run, mmsys.cpl
230+
}
231+
InputBox, Answer,, Название устройства вывода звука A`n(Его можно найти в mmsys.cpl),,,,,,,, %DeviceLabelA2%
232+
DeviceLabelA = %DeviceLabelA1% %Answer%
233+
DeviceLabel = %DeviceLabel1% %Answer%
234+
InputBox, Answer,, Название устройства вывода звука B`n(Его можно найти в mmsys.cpl),,,,,,,, %DeviceLabelB2%
235+
DeviceLabelB = %DeviceLabelB1% %Answer%
236+
InputBox, Answer,, Имя профиля A`n(Будет отображаться в OSD),,,,,,,, %IncludeLabelA2%
237+
IncludeLabelA = %IncludeLabelA1% %Answer%
238+
IncludeLabel = %IncludeLabel1% %Answer%
239+
InputBox, Answer,, Путь к файлу профиля A`n(Без кавычек),,,,,,,, %IncludeA2%
240+
IncludeA = %IncludeA1% %Answer%
241+
Include = %Include1% %Answer%
242+
InputBox, Answer,, Имя профиля B`n(Будет отображаться в OSD),,,,,,,, %IncludeLabelB2%
243+
IncludeLabelB = %IncludeLabelB1% %Answer%
244+
InputBox, Answer,, Путь к файлу профиля B`n(Без кавычек),,,,,,,, %IncludeB2%
245+
IncludeB = %IncludeB1% %Answer%
246+
InputBox, Answer,, Шаг регулировки громкости в дБ,,,,,,,, %PreampStep2%
247+
PreampStep = %PreampStep1% %Answer% %PreampStep3%
248+
InputBox, Answer,, VST плагин лимитера или авторегулировки громкости`n(Можно скопировать уже настроенный из Equalizer APO),,,,,,,, %VSTPlugin%
249+
VSTPlugin = %Answer%
250+
InputBox, Answer,, Масштабирование экрана:`n1 - 100`% `;` 1.25 - 125`% `;` 1.5 - 150`% и т.д,,,,,,,, %MonitorScale2%
251+
MonitorScale = %MonitorScale1% %Answer%
252+
InputBox, Answer,, Автозагрузка:`n0 - Выключить`n1 - Включить,,,,,,,, %Startup2%
253+
Startup = %Startup1% %Answer%
254+
WriteCFG()
255+
reload
256+
}
257+
258+
;Смена устройства вывода звука
259+
SetDefaultEndpoint(DeviceID)
260+
{
261+
IPolicyConfig := ComObjCreate("{870af99c-171d-4f9e-af0d-e63df40c2bc9}", "{F8679F50-850A-41CF-9C72-430F290290C8}")
262+
DllCall(NumGet(NumGet(IPolicyConfig+0)+13*A_PtrSize), "UPtr", IPolicyConfig, "UPtr", &DeviceID, "UInt", 0, "UInt")
263+
ObjRelease(IPolicyConfig)
264+
}
265+
GetDeviceID(Devices, Name)
266+
{
267+
For DeviceName, DeviceID in Devices
268+
If (InStr(DeviceName, Name))
269+
Return DeviceID
270+
}
271+
272+
;Фиксирование системной громкости на 100%
273+
SysVol()
274+
{
275+
SoundGet, SystemVolume
276+
if (SystemVolume != 100)
277+
{
278+
SoundSet, 100
279+
}
280+
}
281+
282+
;Переключение VST плагина
283+
VSTPlugin()
284+
{
285+
if (Preamp2 <= 0)
286+
{
287+
if (SubStr(VSTPlugin, 1, 1) != "#")
288+
{
289+
VSTPlugin = #%VSTPlugin%
290+
}
291+
}
292+
else
293+
{
294+
if (SubStr(VSTPlugin, 1, 1) == "#")
295+
{
296+
VSTPlugin := SubStr(VSTPlugin, 2)
297+
}
298+
}
299+
}
300+
301+
;Обновление OSD
302+
OSD()
303+
{
304+
PreampVisual = Громкость: %Preamp2% дБ
305+
GuiControl, Text, OSDText, %DeviceLabel2% | %IncludeLabel2%`n%PreampVisual%
306+
Gui, Show, xCenter y%ControlY% NoActivate
307+
SetTimer, HideOSD, 1500
308+
return
309+
HideOSD:
310+
Gui, Hide
311+
return
312+
}
313+
314+
;Запись конфига
315+
WriteCFG()
316+
{
317+
FileDelete, %TMP%
318+
FileAppend, %DeviceLabel%`n%DeviceLabelA%`n%DeviceLabelB%`n%IncludeLabel%`n%Include%`n%IncludeLabelA%`n%IncludeA%`n%IncludeLabelB%`n%IncludeB%`n%Preamp%`n%PreampStep%`n%VSTPlugin%`n%MonitorScale%`n%Startup%, %TMP%
319+
FileCopy, %TMP%, %CFG%, 1
320+
}

0 commit comments

Comments
 (0)