Skip to content

Instantly share code, notes, and snippets.

@Znuff

Znuff/EQ APO GUI Secret

Created Apr 28, 2014
Embed
What would you like to do?
#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=noun_project_2807.ico
#AutoIt3Wrapper_Outfile=eq-config.exe
#AutoIt3Wrapper_Outfile_x64=eq-config_x64.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_Comment=EQ
#AutoIt3Wrapper_Res_Fileversion=0.1.0.1
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p
#AutoIt3Wrapper_Res_Language=1033
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiSlider.au3>
#include <GuiToolTip.au3>
#include <File.au3>
#include <Array.au3>
#include <Constants.au3>
$title = "Egalizatoru' lu' troo"
$Form1 = GUICreate("Egalizatoru' lu' troo", 490, 345, 494, 390, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU))
Opt("TrayMenuMode", 11)
Opt("TrayAutoPause", 0)
Opt("TrayOnEventMode", 1)
TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "_TrayClick")
TraySetClick(16)
TraySetToolTip($title)
Local $showitem = TrayCreateItem("Show EQ");
TrayItemSetOnEvent(-1, "_TrayClick")
Local $exititem = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "_TrayExit")
Global $WinState
$state = WinGetState($Form1, "")
If BitAND($state, 16) Then
$WinState = True
Else
$WinState = False
EndIf
Func _TrayClick()
$WinState = Not $WinState
If $WinState Then
WinSetState($Form1, "", @SW_MINIMIZE)
WinSetState($Form1, "", @SW_HIDE)
Else
WinSetState($Form1, "", @SW_SHOW)
WinSetState($Form1, "", @SW_RESTORE)
EndIf
Sleep(100)
EndFunc ;==>_TrayClick
Func _TrayExit()
Exit 0
EndFunc ;==>_TrayExit
Global $cFile = "eq.txt"
Global $aArray = StringSplit("0|32|64|125|250|500|1000|2000|4000|8000|16000|", "|", 3)
Global $iCount = UBound($aArray) - 1
Global $dbLimit = "120"
Global $aConfig
Global $aSlider[$iCount]
Global $aLabel[$iCount]
Global $aLegend[$iCount]
Global $aLine[$iCount]
Global $aSlider_hold[$iCount]
Global $aSlider_value[$iCount]
_ReadFile($cFile)
Func CreateSliders()
For $i = 0 To $iCount - 1
$Position = ($i * 40) + 32;
$aSlider[$i] = GUICtrlCreateSlider($Position, 32, 32, 240, BitOR($TBS_VERT, $TBS_AUTOTICKS, $TBS_BOTH))
GUICtrlSetLimit($aSlider[$i], $dbLimit, -$dbLimit)
GUICtrlSetData($aSlider[$i], $aSlider_value[$i])
If $aArray[$i] = 0 Then
$aLabeltext = "PRE"
ElseIf $aArray[$i] >= 1000 Then
$nValue = $aArray[$i] / 1000
$aLabeltext = $nValue & " KHz"
Else
$aLabeltext = $aArray[$i] & " Hz"
EndIf
$aLabel[$i] = GUICtrlCreateLabel($aLabeltext, $Position, 16, 36, 16, $SS_CENTER)
$aLegend[$i] = GUICtrlCreateLabel(0, $Position, 280, 28, 16, $SS_CENTER)
Next
EndFunc ;==>CreateSliders
CreateSliders()
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Reset = GUICtrlCreateButton("Reset", 5, 312, 75, 25)
GUISetState(@SW_SHOW)
; Get a time stamp
$nBegin = TimerInit()
_UpdateAllSliders()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Reset
_ResetSliders()
Case $GUI_EVENT_MINIMIZE
_TrayClick()
Case $GUI_EVENT_RESTORE
_TrayClick()
EndSwitch
; Checkif a slider has been moved
For $i = 0 To $iCount - 1
If - 1 * (GUICtrlRead($aSlider[$i]) / 10) <> GUICtrlRead($aLegend[$i]) Then
_Slider_Update($i)
; Only one can move at a time so no point in looking further
ExitLoop
EndIf
Next
; Hide the ToolTip every second
If TimerDiff($nBegin) > 1000 Then
_HideToolTip()
$nBegin = TimerInit()
EndIf
WEnd
Func _UpdateAllSliders()
For $i = 0 To $iCount - 1
_Slider_Update($i)
Next
EndFunc ;==>_UpdateAllSliders
Func _Slider_Update($Index)
$nValue = -1 * (GUICtrlRead($aSlider[$Index]) / 10)
GUICtrlSetData($aLegend[$Index], $nValue) ; No ned to check as we know it must be different or we would not be here
$aSlider_value[$Index] = $nValue;
; Show the tootip
ToolTip($nValue & " dB")
If $Index = 0 Then
$aLine[$Index] = "Preamp: " & $nValue & " dB"
Else
$aLine[$Index] = "Filter " & $Index & ": ON PK Fc " & $aArray[$Index] & " Hz Gain " & $nValue & " dB Q 1,00"
EndIf
_WriteFile($cFile)
EndFunc ;==>_Slider_Update
Func _WriteFile($cFile)
$hFile = FileOpen($cFile, 2)
FileWriteLine($hFile, "Equaliser: Generic")
If $hFile = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf
_FileWriteFromArray($hFile, $aLine)
FileFlush($hFile)
FileClose($hFile)
EndFunc ;==>_WriteFile
Func _ReadFile($cFile)
If _FileReadToArray($cFile, $aConfig) Then
Global $cLine[$aConfig[0] + 1]
For $i = 0 To $aConfig[0]
$cLine = StringSplit($aConfig[$i], " ", 3)
If StringInStr(StringStripWS($cLine[0], 8), "Preamp", 2) Then
$aSlider_value[0] = -1 * $cLine[1] * 10
ElseIf StringInStr(StringStripWS($cLine[0], 8), "Filter", 2) Then
Local $sliderNumber = StringTrimRight($cLine[1], 1)
$aSlider_value[$sliderNumber] = -1 * $cLine[8] * 10
EndIf
Next
EndIf
EndFunc ;==>_ReadFile
Func _ResetSliders()
For $i = 0 To $iCount - 1
$aSlider_value[$i] = 0
GUICtrlSetData($aSlider[$i], $aSlider_value[$i])
Next
_UpdateAllSliders()
EndFunc ;==>_ResetSliders
Func _HideToolTip()
; Hide ToolTip
ToolTip("")
EndFunc ;==>_HideToolTip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment