setting up an equalizer

Started by kgs1951,

kgs1951

The following is my code to create an equalizer in vb.net. I am using 3 slider controls to update the Bass, Mid and Treble. However, it doesn't seem to be working as I get no change in my sound. Can  someone review and advise of any changes I could make. Thanks so Much!

 Private Sub SetBFX_EQ(channel As Integer)
     ' set peaking equalizer effect with no bands
     _fxEQ = Bass.BASS_ChannelSetFX(channel, BASSFXType.BASS_FX_BFX_PEAKEQ, 0)

     ' setup the EQ bands
     Dim eq As New BASS_BFX_PEAKEQ()
     eq.fQ = 0F
     eq.fBandwidth = 2.5F
     eq.lChannel = BASSFXChan.BASS_BFX_CHANALL

     ' create 1st band for bass
     eq.lBand = 0
     eq.fCenter = 125.0F
     Bass.BASS_FXSetParameters(_fxEQ, eq)
     UpdateFX(0, 0F)

     ' create 2nd band for mid
     eq.lBand = 1
     eq.fCenter = 1000.0F
     Bass.BASS_FXSetParameters(_fxEQ, eq)
     UpdateFX(1, 0F)

     ' create 3rd band for treble
     eq.lBand = 2
     eq.fCenter = 8000.0F
     Bass.BASS_FXSetParameters(_fxEQ, eq)
     UpdateFX(2, 0F)
 End Sub

 Private Sub UpdateFX(band As Integer, gain As Double)
     Dim eq As New BASS_BFX_PEAKEQ()
     ' get values of the selected band
     eq.lBand = band
     Bass.BASS_FXGetParameters(_fxEQ, eq)
     eq.fGain = gain
     Bass.BASS_FXSetParameters(_fxEQ, eq)
 End Sub

 Private Sub sliderBass_ValueChanged(sender As Object, e As RoutedPropertyChangedEventArgs(Of Double)) Handles sliderBass.ValueChanged
     Dim gain As Double = sliderBass.Value
     UpdateFX(0, gain)
 End Sub

 Private Sub sliderMid_ValueChanged(sender As Object, e As RoutedPropertyChangedEventArgs(Of Double)) Handles sliderMid.ValueChanged
     Dim gain As Double = sliderMid.Value

     UpdateFX(1, gain)
 End Sub

 Private Sub sliderTreble_ValueChanged(sender As Object, e As RoutedPropertyChangedEventArgs(Of Double)) Handles sliderTreble.ValueChanged
     Dim gain As Double = sliderTreble.Value

     UpdateFX(2, gain)
 End Sub


When I create by stream file, then I substitute as follows to create the 3 band equalizer:

 SetBFX_EQ(stream)


Ian @ un4seen

Is the BASS_ChannelSetFX call returning a non-0 value? If it's returning 0 then that means it's failing, and you can use BASS_ErrorGetCode to find out why. The usual cause is that the BASS_FX add-on (which provides the BASS_FX_BFX_PEAKEQ effect) isn't loaded. You can call a BASS_FX function to force it to be loaded, eg. BASS_FX_GetVersion during initialization.

kgs1951

I am fairly new at this. How do I load the Bass_FX addon

kgs1951

During the initialization I used this code:

 Dim fxpluginfo As Integer = Bass.BASS_PluginLoad("bassfx.dll")



This returned a 0 though.

Ian @ un4seen

Yes, BASS_PluginLoad is for loading add-ons that add support for more file formats (eg. BASSFLAC), so it won't work with BASS_FX. To load BASS_FX, you can just call a function from it, eg. BASS_FX_GetVersion.

kgs1951


kgs1951

I have gotten it to work by just calling the Bass_FX_GetVersion Function. Thanks