Equalizer in VB

Started by Naz (Guest),

Naz (Guest)

Hi,
I made an audio player using MP3player.ocx,but now I found BASS and decided to do this with it.Can someone please help me with EQ code for Visual Basic.

Thanks.

(: JOBnik! :)

Hi ;D

There are some examples in BASS package to get you started.
An example called: "FXtest.vbp"
will show you how to make a DX8/9 Parametric EQ with 3 Bands, you can add some more if you like.

* Another option is to use the BASS_FX library, if you want to use a DSP EQ (NOTE: none DX8+ drivers needed).
Examples are included as well in BASS_FX package.

Have fun!

8) JOBnik! 8)


cab0San

Here's what I am using for the BassFX Lib + DX8. I am working on a radio station, and it seems to be working...
Hope it helps

Dim stream As nBASS.Stream
 Dim bass As New nBASS.BASS(-1, freq, DeviceSetupFlags.Latency Or _
            DeviceSetupFlags.LeaveVolume Or DeviceSetupFlags.ThreeDee, IntPtr.Zero)
            Dim buffer(442000) As Byte
 stream = bass.LoadStream(False, sFile, _
                0, 0, StreamFlags.DecodeOnly)
 Dim eq(9) As FX
....

Sub SetEq()
        'reads eq Setting from  the registry, removes the existing eq settings from the
        'stream, and then applies the new EQ
        Try
            Dim p As New nBASS.FXPARAMEQ()
            Dim f As ChannelAttributes = stream.Attributes

            ' I'm not even going to pretend I know exactly how this works
            ' - I copied it from the forums on un4seen.com
            'Basically, it divides the eq into ten bands, based on the freqeuncy. Then you adjust the gain for each.

            Dim freq = Math.Min(f.freq / 3, 16000)
            p.fBandwidth = 12 * Math.Log(freq / 80.0) / Math.Log(2) / 9
            Dim x As Integer


            Dim gain(9) As Integer
            'read the eqSettings from the registry
            For x = 0 To 9
                Try
                    gain(x) = fGetRegValue(Registry.LocalMachine, hiveBase, "eq" + CStr(x + 1))
                Catch
                    gain(x) = 0
                End Try
            Next
            'remove the existing eq settings, if any
            For x = 0 To 9
                If Not eq(x) Is Nothing Then
                    stream.RemoveFX(eq(x))
                End If
            Next
            'apply the new settings
            For x = 0 To 9
                eq(x) = stream.SetFX(ChannelFX.ParametricEQ)
                p = eq(x).Parameters
                p.fCenter = 80 * Math.Pow(freq / 80.0, x / 9.0)
                p.fGain = gain(x)
                'save the settings for removal the next time
                eq(x).Parameters = p
            Next x
        Catch ex As Exception
            writeLog(ex.ToString, 2)
        End Try
    End Sub