Attribute VB_Name = "Module1"

Public MainWindowState          As Boolean

Public Sub Main()
On Error Resume Next

    Load Form1
    
    IniLocation = App.Path & "\AppPresets.ini"
    
    SplitCounter = 0
    EQAudioGain = 0
    EQRange = 0
    
    LowCutFreqFilt = False
    
    
Call Module1.CreateControls
Call Module6.SetDefaultGain

With Form1
    
    .Label6.Visible = False
    
    .Timer3.Enabled = False
    
    .Slider2.Value = 5
    
    .Caption = "ProGraph32 Graphic Equalizer"
    
    .Command1(2).Enabled = False
    .Command1(3).Enabled = False
   ' .Command1(6).Enabled = False
    .Command1(7).Enabled = False
    .Command1(8).Enabled = False

    .Height = 5310
    .Show

End With

End Sub

Public Sub ResetGainSldrColours()
On Error Resume Next

Dim i As Integer

With Form1

For i = 0 To .Label4.Count - 1

    .Label4(i).ForeColor = vbBlack

Next i

End With

End Sub

Public Sub AudioGainSettings(GainValue As Integer)
On Error Resume Next

    EQAudioGain = GainValue / 5
    
With Form1

    .Label7(5).Caption = "Gain Settings " & GainValue / 5 * 100 & "% Of Source"
    .Label4(3).Caption = "Gain:" & GainValue / 5 * 100 & "%"

End With

End Sub

Public Sub LCutIndication(Index As Integer)
On Error Resume Next

    LowCutFilter = Index

With Form1

If Index = 0 Then

    .Label7(2).Caption = "Low Cut Filter: On"

Else

    .Label7(2).Caption = "Low Cut Filter: Off"

End If

End With

End Sub

Public Sub VisibleIndicators()
On Error Resume Next

With Form1

If .Check1.Value = 1 Then

    .Label7(3).Caption = "Indicators: On"

Else

    .Label7(3).Caption = "Indicators: Off"

End If

End With

End Sub

Public Sub EQRangeSettings(Index As Integer)
On Error Resume Next

With Form1

If Index = 0 Then

    .Label7(1).Caption = "EQ Range: +/- 12 db"

Else

    .Label7(1).Caption = "EQ Range: +/- 6 db"

End If

End With

End Sub

Public Sub PresetNotify(Index As Integer)
On Error Resume Next

    UserPreset = Index

If Index = 0 Then

    Form1.Timer3.Enabled = True

End If
  
With Form1

    .Label7(0).Caption = "Preset Settings: " & Index

End With

Call Module3.ReadPresetFromIni(UserPreset)

End Sub

Public Sub IndicBars()
On Error Resume Next

Dim i As Integer

With Form1

For i = 0 To .Line4.Count - 1

If .Check1.Value = 0 Then

    .Line4(i).Visible = False

Else

    .Line4(i).Visible = True

End If

Next i

End With

End Sub

Public Sub HighLightFrequency(SliderFocused As Integer)
On Error Resume Next

Dim i As Integer
For i = 0 To Form1.Slider1.Count - 1

With Form1.Label1(i)

    .ForeColor = vbBlack

End With

Next i

With Form1.Label1(SliderFocused)

    .ForeColor = vbRed

End With

End Sub

Public Sub GainSliderScroll()
On Error Resume Next

With Form1

If .Slider2.Value < 0 Then

    .Line10.BorderColor = Safe_GainControlColour

End If

If .Slider2.Value / 5 < -"1" Then

    .Line10.BorderColor = Peak_GainControlColour

End If

If .Slider2.Value / 5 < -"1.5" Then

    .Line10.BorderColor = Warn_GainControlColour
    
End If

If .Slider2.Value > 0 Then

    .Line10.BorderColor = Safe_GainControlColour

End If

If .Slider2.Value / 5 > "1" Then

    .Line10.BorderColor = Peak_GainControlColour

End If

If .Slider2.Value / 5 > "1.5" Then

    .Line10.BorderColor = Warn_GainControlColour
    
End If

End With

With Form1.Line10

    .X1 = Form1.Slider2.Left + Form1.Slider2.Width / 2
    .X2 = Form1.Slider2.Left + Form1.Slider2.Width - Form1.Slider2.Width / 2

    .X1 = Form1.Slider2.Left + Form1.Slider2.Width / 2 + Form1.Slider2.Value / 2 * 25
    
End With

If Form1.Command1(8).Caption = "Data On Clipboard" Then
    
    Form1.Command1(8).Caption = "EQ String > Clipboard"

End If

End Sub

Public Sub FrequencySliderScroll(SldIndex As Integer)
On Error Resume Next

Dim FreqEQ As Boolean

If Left((Form1.Slider1(SldIndex).Value), 1) = "-" Then
'Reverse +/-

    FreqEQ = True
    
Else

    FreqEQ = False

End If

    Form1.Label7(4).Caption = "Selected Frequency: " & Form1.Label1(SldIndex).Caption

    FixValue = Form1.Slider1(SldIndex).Value
    
If Left((FixValue), 1) = "-" Then

    FixValue = Mid((FixValue), 2, 2)
    
End If

With Form1.Label7(7)

If FreqEQ = False Then

    .Caption = "Selected Frequency Value: -" & FixValue & "db"

Else

    .Caption = "Selected Frequency Value: " & FixValue & "db"

End If

End With
    
If EQRange = 0 Then

With Form1.Line4(SldIndex)

    .Y1 = Form1.Slider1(SldIndex).Top + Form1.Slider1(SldIndex).Height / 2 + Form1.Slider1(SldIndex).Value * 5
    .Y2 = Form1.Slider1(SldIndex).Top + Form1.Slider1(SldIndex).Height / 2
    
If Form1.Slider1(SldIndex).Value > Form1.Slider1(SldIndex).Min / 2 Then

    Form1.Line4(SldIndex).BorderColor = Safe_GainControlColour

ElseIf Form1.Slider1(SldIndex).Value > Form1.Slider1(SldIndex).Min / 1.1 Then

    Form1.Line4(SldIndex).BorderColor = Peak_GainControlColour

ElseIf Form1.Slider1(SldIndex).Value > Form1.Slider1(SldIndex).Min * 1.1 Then

    Form1.Line4(SldIndex).BorderColor = Warn_GainControlColour

End If

End With

End If

If EQRange = 1 Then

With Form1.Line4(SldIndex)

    .Y1 = Form1.Slider1(SldIndex).Top + Form1.Slider1(SldIndex).Height / 2 + Form1.Slider1(SldIndex).Value * 10
    .Y2 = Form1.Slider1(SldIndex).Top + Form1.Slider1(SldIndex).Height / 2
    
If Form1.Slider1(SldIndex).Value > Form1.Slider1(SldIndex).Min / 2 Then

    Form1.Line4(SldIndex).BorderColor = Safe_GainControlColour

ElseIf Form1.Slider1(SldIndex).Value > Form1.Slider1(SldIndex).Min / 1.1 Then

    Form1.Line4(SldIndex).BorderColor = Peak_GainControlColour

ElseIf Form1.Slider1(SldIndex).Value > Form1.Slider1(SldIndex).Min * 1.1 Then

    Form1.Line4(SldIndex).BorderColor = Warn_GainControlColour

End If

End With

End If

End Sub

Public Sub CreateControls()
Dim i As Integer

With Form1

For i = 1 To 31

    Load .Slider1(i)
    Load .Label1(i)
    Load .Line4(i)
    Load .Label9(i)

Next i

With Form1.Slider1(0)

    .Top = 15
    .Left = 25
    .Width = 20
    .Height = Form1.Picture1(0).ScaleHeight - 15

End With

For i = 1 To .Slider1.Count - 1

With Form1.Slider1(i)

    .Left = Form1.Slider1(0).Left + Form1.Slider1(0).Width * i * 1.5
    .Top = Form1.Slider1(0).Top
    .Height = Form1.Slider1(0).Height
    .Width = Form1.Slider1(0).Width
    
    Form1.Line4(i).Y1 = 20
    Form1.Line4(i).Y2 = .Height
    Form1.Line4(i).X1 = .Left - 5
    Form1.Line4(i).X2 = .Left - 5
    
    Form1.Line4(i).BorderWidth = 3
    Form1.Line4(i).Visible = True
    
    .Visible = True
    
End With

Next i

With Form1.Label1(0)

    .Top = 0
    .Left = Form1.Slider1(0).Left
    .Width = 40
    .FontSize = 7
    .Alignment = 2
    .Caption = "19Hz"

End With

For i = 1 To .Label1.Count - 1

    .Label1(i).Top = 0
    .Label1(i).Left = Form1.Slider1(i).Left
    .Label1(i).Alignment = 2
    .Label1(i).BackStyle = 0
    .Label1(i).Width = 28
    .Label1(i).FontSize = 7
    .Label1(i).Visible = True

Next i
    
For i = 0 To .Label9.Count - 1

    .Label9(i).Top = Form1.Picture1(0).Top - .Label9(0).Height - 5
    .Label9(i).Left = Form1.Picture1(0).Left + Form1.Slider1(i).Left + .Label9(i).Width / 2
    .Label9(i).Alignment = 2
    .Label9(i).AutoSize = True
    .Label9(i).BackStyle = 0
    .Label9(i).ForeColor = &HE0E0E0
    .Label9(i).Caption = i + 1
    .Label9(i).Width = 28
    .Label9(i).Height = 6
    .Label9(i).FontSize = 7
    .Label9(i).ZOrder 0
    
    .Label9(i).Visible = True

Next i

    Form1.Label9(0).Top = Form1.Label9(1).Top

With .Label2(0)

    .Alignment = 0
    .Width = 25
    .FontSize = 7
    .Top = Form1.Slider1(0).Top + 10
    .Left = 0
    .Caption = "+12db"
    
End With

With .Label2(1)

    .Alignment = 0
    .Width = 25
    .FontSize = 7
    .Top = Form1.Slider1(0).Top + Form1.Slider1(0).Height - 25
    .Left = 0
    .Caption = "-12db"
    
End With

With .Line1

    .Y1 = Form1.Slider1(0).Height / 2 + Form1.Slider1(0).Top
    .Y2 = Form1.Slider1(0).Height / 2 + Form1.Slider1(0).Top
    
    .X1 = 5
    .X2 = Form1.Picture1(0).ScaleWidth - 10
    
    .BorderWidth = 2

End With

With .Line10

    .X1 = Form1.Slider2.Left + 10
    .X2 = Form1.Slider2.Left + Form1.Slider2.Width - 10

End With

For i = 0 To .Slider1.Count - 1

Call Module5.PreventSliderToolTips(.Slider1(i).hwnd, False)

Next i

End With

Call Module3.LabelFrequencyHeaders

End Sub
