Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Next small EQ step
#4
So here's something as the equalizer style. I was lazy to do with the graphics and adjust the sliders here.... so I did it using the keyboard, or repeatedly press V to start or end the quick adjustment of the equalization.

Code: (Select All)

$NoPrefix

Screen _NewImage(600, 600, 32)
Title "Equalizer"
S = SndOpen("10.mp3")
Dim m As MEM
Dim Shared As Single L(5), R(5), L2(5), R2(5), Le(10), Ri(10), LVol(10), RVol(10), X(10)
Dim As Long f
Dim As Long Raw(10)
m = MemSound(S, 0)
If m.ELEMENTSIZE <> 8 Then
    Print "Try another music file, program required SINGLE array. Try MP3."
    Sleep
    SndClose S
    MemFree m
    System
End If


eff = 0

X(1) = SetFreq(80)
X(2) = SetFreq(125)
X(3) = SetFreq(180)
X(4) = SetFreq(250)
X(5) = SetFreq(500)
X(6) = SetFreq(1000)
X(7) = SetFreq(2000)
X(8) = SetFreq(4000)
X(8) = SetFreq(8000)
X(9) = SetFreq(12000)
X(10) = SetFreq(16000)

For SetVol = 1 To 10
    LVol(SetVol) = 0.1
    RVol(SetVol) = 0.1
Next

For R = 1 To 10
    Raw(R) = SndOpenRaw
Next


'The program (if written correctly) should read two harmonic frequencies above and two below the selected frequency
'to make the sound denser


FreqChange = -1

Do Until n& >= m.SIZE - SndRate

   eq = 1
    Do Until eq = 10
        a = 1
        Le(eq) = 0
        Ri(eq) = 0

        Do Until a = 5

            'get freqency in samples
            So& = n& + 8 * X(eq)

            MemGet m, m.OFFSET + n&, L(a)
            MemGet m, m.OFFSET + n& + 4, R(a)
            MemGet m, m.OFFSET + So&, L2(a)
            MemGet m, m.OFFSET + So& + 4, R2(a)


            Le(eq) = Le(eq) - (L(a) - L2(a))
            Ri(eq) = Ri(eq) - (R(a) - R2(a))

            a = a + 1
        Loop
        Le(eq) = Le(eq) * LVol(eq)
        Ri(eq) = Ri(eq) * RVol(eq)
        eq = eq + 1

    Loop

    For eq = 1 To 10
        SndRaw Le(eq), Ri(eq), Raw(eq) ', Raw(eq)
    Next

    If eff Then

        If n& Mod SndRate / 20 = 0 Then
            omega = omega + .1
            For eq = 1 To 10
                LVol(eq) = Abs(Sin(omega + eq * Pi / 20))
                RVol(eq) = Abs(Sin(omega + eq * Pi / 20))
            Next
        End If
    End If


    Do Until SndRawLen(Raw(10)) <= .1
        i$ = InKey$
        Select Case LCase$(i$)
            Case "q": SetEqVolP 1
            Case "a": SetEqVolM 1
            Case "w": SetEqVolP 2
            Case "s": SetEqVolM 2
            Case "e": SetEqVolP 3
            Case "d": SetEqVolM 3
            Case "r": SetEqVolP 4
            Case "f": SetEqVolM 4
            Case "t": SetEqVolP 5
            Case "g": SetEqVolM 5
            Case "y": SetEqVolP 6
            Case "h": SetEqVolM 6
            Case "u": SetEqVolP 7
            Case "j": SetEqVolM 7
            Case "i": SetEqVolP 8
            Case "k": SetEqVolM 8
            Case "o": SetEqVolP 9
            Case "l": SetEqVolM 9
            Case "p": SetEqVolP 10
            Case "ů": SetEqVolM 10

            Case "v": eff = Not eff
        End Select


        Locate 2
        Print "First equalizer."
        Print "Press: q,w,e,r,t,y,u,i,o,p for eq volume up"
        Print "      a,s,d,f,g,h,j,k,l,ů for eq volume down"

        For eqva = 1 To 10
            Print "Freq: "; SndRate \ X(eqva); " vol:"; LVol(eqva); "                    "
        Next

    Loop

    n& = n& + 8
Loop
SndClose S
MemFree m
System

Sub SetEqVolM (i)
    LVol(i) = LVol(i) - .1
    If LVol(i) < 0 Then LVol(i) = 0
    RVol(i) = LVol(i)
End Sub

Sub SetEqVolP (i)
    LVol(i) = LVol(i) + .1
    If LVol(i) > 1.4 Then LVol(i) = 1.4
    RVol(i) = LVol(i)
End Sub


Function SetFreq (f)
    SetFreq = SndRate \ 2 \ f
End Function

Finally is used SndOpenRaw too.


Reply


Messages In This Thread
Next small EQ step - by Petr - 03-30-2024, 08:50 PM
RE: Next small EQ step - by Petr - 03-31-2024, 10:39 AM
RE: Next small EQ step - by Petr - 04-07-2024, 09:07 AM
RE: Next small EQ step - by Petr - 04-07-2024, 06:35 PM



Users browsing this thread: 2 Guest(s)