Attribute VB_Name = "Module3"

Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" _
    (ByVal lpApplicationName As String, _
    ByVal lpKeyName As Any, _
    ByVal lpDefault As String, _
    ByVal lpReturnedString As String, _
    ByVal nSize As Long, _
    ByVal lpFileName As String) As Long

Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" _
    (ByVal lpApplicationName As String, _
    ByVal lpKeyName As Any, _
    ByVal lpString As Any, _
    ByVal lpFileName As String) As Long
    
Public SourceDuration           As String
    
Public SplitCounter             As Integer

Public DOS_SourceFileName       As String
Public EQSaveFileName           As String
Public DOS_EQSaveFileName       As String

Public LowCutFilter             As Integer

Public IniLocation              As String

Public UserPreset               As Integer
Public EQRange                  As Integer

Public EQAudioGain              As Variant

Public Sub SetDefaultBandwidth(NewBandwidth As Integer)
On Error Resume Next

    GQ_BandWidthOctave = NewBandwidth
    
With Form1

    .Label8(3).Caption = "Current Bandwidth Settings:" & Space(1) & Format((NewBandwidth), "000") & Space(1) & "Hz"
    .Label7(6).Caption = "Current Bandwidth:" & Space(1) & Format((NewBandwidth), "000") & Space(1) & "Hz"
    
If .Command1(8).Caption = "Data On Clipboard" Then
    
    .Command1(8).Caption = "EQ String > Clipboard"

End If

End With
End Sub

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

With Form1

   EQRange = .Option2(Index).Index
   
If EQRange = 0 Then

    .Label2(0).Caption = "+12db"
    .Label2(1).Caption = "-12db"
    
For i = 0 To .Slider1.Count - 1

    .Slider1(i).Max = 12
    .Slider1(i).Min = -12
    .Slider1(i).Value = 0
    .Slider1(i).TickFrequency = 2

Next i
   
Else

    .Label2(0).Caption = "+6db"
    .Label2(1).Caption = "-6db"

For i = 0 To .Slider1.Count - 1

    .Slider1(i).Max = 6
    .Slider1(i).Min = -6
    .Slider1(i).Value = 0
    .Slider1(i).TickFrequency = 1

Next i
    
End If

End With

End Sub

Public Sub LabelFrequencyHeaders()
On Error Resume Next

With Form1

    .Label1(0).Caption = "19hz":    .Label1(1).Caption = "20hz"
    .Label1(2).Caption = "25hz":    .Label1(3).Caption = "31.5hz"
    .Label1(4).Caption = "33hz":    .Label1(5).Caption = "40hz"
    .Label1(6).Caption = "50hz":    .Label1(7).Caption = "63hz"
    .Label1(8).Caption = "75hz":    .Label1(9).Caption = "80hz"
    .Label1(10).Caption = "125hz":  .Label1(11).Caption = "160hz"
    .Label1(12).Caption = "250hz":  .Label1(13).Caption = "313hz"
    .Label1(14).Caption = "400hz":  .Label1(15).Caption = "450hz"
    .Label1(16).Caption = "500hz":  .Label1(17).Caption = "630hz"
    .Label1(18).Caption = "1K":     .Label1(19).Caption = "1.25K"
    .Label1(20).Caption = "1.6K":   .Label1(21).Caption = "2K"
    .Label1(22).Caption = "2.5K":   .Label1(23).Caption = "3.15K"
    .Label1(24).Caption = "4K":     .Label1(25).Caption = "5K"
    .Label1(26).Caption = "6.3K":   .Label1(27).Caption = "8K"
    .Label1(28).Caption = "10K":    .Label1(29).Caption = "12.5K"
    .Label1(30).Caption = "16K":    .Label1(31).Caption = "20K"

End With

End Sub

Public Sub SavePresetToIni()
On Error Resume Next

Dim SliderVals          As String
Dim SelectedPreset      As String

If UserPreset = 0 Then Exit Sub

    GQ_BandWidthOctave = Format((GQ_BandWidthOctave), "000")
    EQAudioGain = EQAudioGain * 100
        
With Form1
    
    SelectedPreset = "Preset#" & UserPreset
    
    WritePrivateProfileString SelectedPreset, _
    "Frequency", _
    0&, _
    IniLocation
    
For i = 0 To .Slider1.Count - 1

    SliderVals = SliderVals & .Slider1(i).Value & ":"

Next i

    SliderVals = SliderVals & _
              "LowCut=" & LowCutFilter & _
        ":" & "Range=" & EQRange & _
        ":" & "BandWidth=" & GQ_BandWidthOctave & _
        ":" & "AudioGain=" & EQAudioGain

    WritePrivateProfileString SelectedPreset, _
    "Frequency", _
    SliderVals, _
    IniLocation

End With

End Sub

Public Sub ReadPresetFromIni(SelectedOption As Integer)
On Error Resume Next

Dim buffer                      As String
Dim IniData                     As String

Dim PresetSetting               As Variant

Dim MyArray                     As String

Dim i                           As Integer
Dim LCutFilter                  As Integer
Dim RangeSett                   As Integer
Dim x                           As Integer

    SplitCounter = 0

    PresetOption = "Preset#" & SelectedOption

    buffer = String(1024, Chr(0))
    
    INIsetting = Left(buffer, _
    GetPrivateProfileString(PresetOption, _
    "Frequency", _
    "1", _
    buffer, _
    Len(buffer), _
    IniLocation))
    
    PresetSetting = Split((INIsetting), ":", -1, 1)
    
With Form1

For i = 0 To Len(INIsetting) - 1

    SplitCounter = SplitCounter + 1
    
    x = InStr(1, (INIsetting), "Range=", vbTextCompare)

    GraphRange = Mid((INIsetting), x + 6, 1)

If GraphRange = 1 Then
    
    .Option2(0).Value = False
    .Option2(1).Value = True
    
ElseIf GraphRange = 0 Then

    .Option2(1).Value = False
    .Option2(0).Value = True
    
End If

    x = InStr(1, (INIsetting), "LowCut=", vbTextCompare)

    LoCutFilter = Mid((INIsetting), x + 7, 1)

If LoCutFilter = 1 Then
    
    .Option3(0).Value = False
    .Option3(1).Value = True

ElseIf LoCutFilter = 0 Then

    .Option3(1).Value = False
    .Option3(0).Value = True
    
End If

    x = InStr(1, (INIsetting), "BandWidth=", vbTextCompare)

    SetBandWidth = Mid((INIsetting), x + 10, 3)

    .Slider3.Value = SetBandWidth
    
    x = InStr(1, (INIsetting), "AudioGain=", vbTextCompare)

    SetAudioGain = Mid((INIsetting), x + 10, 4)

    .Slider2.Value = Format((SetAudioGain / 20), "000")
    
Call .Slider2_Scroll

If SplitCounter < 33 Then
    
    .Slider1(i).Value = PresetSetting(i)

End If

Next i
    
    .Label7(7).Caption = "Selected Frequency Value:  0db"

End With

End Sub



