|
kgs51
Posts: 26
|
 |
« on: 13 Mar '07 - 12:32 » |
Quote
|
I have read through all the threads in the forum regarding the programming of a 10 band equalizer and I am still confused. Can some one steer me in the right direction. I am a visual basic.net programmer. I appreciate any help you can provide.
Ken
|
|
|
|
|
Logged
|
|
|
|
|
VorTechS
Posts: 241
|
 |
« Reply #1 on: 14 Mar '07 - 11:38 » |
Quote
|
Hi, I have a 10-band EQ in my application as this screenshot shows: First I configured the form so that on it there are standard trackbars for the sliders, named EQ1-EQ10. Each trackbar has its Tag property set to Mhz the EQ band represents. So EQ1.Tag=31, EQ2.Tag=63 and so on. When it gets to 1khz, then the value becomes 1000 etc I also have Infragistic Ultra labels named lblLevel1-lblLevel10 above each trackbar to show the user the current setting of each EQ band. The tags on the trackbars are important as they are used by this code, which initially configures the EQ bands, which should be called as you create your next stream to play.
Private Sub SetupEQ(ByVal Stream As Int32)
Dim tBar As TrackBar = Nothing Dim Band As Int32 = -1 Dim ChanEQ As New Un4seen.Bass.AddOn.Fx.BASS_FX_DSPPEAKEQ
' Get current sample rate of a Handle Dim f As Int32 If Not (Un4seen.Bass.Bass.BASS_ChannelGetAttributes(Stream, f, 0, 0)) Then Dim BassError As Un4seen.Bass.BASSErrorCode = Un4seen.Bass.Bass.BASS_ErrorGetCode Else ChanEQ.lFreq = f ChanEQ.fBandwidth = 2.5 ChanEQ.fQ = 0.0# ChanEQ.fGain = 0.0# End If
'Loop through all the track bars on the form For Band = 0 To 9 'Configure the EQ priority If Not (Un4seen.Bass.AddOn.Fx.BassFx.BASS_FX_DSP_Set(Stream, Un4seen.Bass.AddOn.Fx.BASSFXDsp.BASS_FX_DSPFX_PEAKEQ, 0)) Then Dim BassError As Un4seen.Bass.BASSErrorCode = Un4seen.Bass.Bass.BASS_ErrorGetCode
End If Next Band
For Band = 0 To 9 'Create a new FX EQ instance ChanEQ.lBand = Band
'Get the on-screen track bar tBar = exbMixerPanel.Controls("EQ" & Band + 1)
'Is it one of the EQ value bars? [Safety check] If IsNumeric(tBar.Tag) Then 'Now configure the EQ center ChanEQ.fCenter = Val(tBar.Tag)
'Apply to the current stream If Not (Un4seen.Bass.AddOn.Fx.BassFx.BASS_FX_DSP_SetParameters(Stream, ChanEQ)) Then Dim BassError As Un4seen.Bass.BASSErrorCode = Un4seen.Bass.Bass.BASS_ErrorGetCode End If End If Next Band
End SubOn each trackbar_scroll event there is the following code: 'Get the object reference Dim tBar As TrackBar = sender Dim EQValue As Int32 = tBar.Value
'Pass the EQ settings Call EQSlideChanged(tBar.Name.Substring(tBar.Name.Length - 1, 1), EQValue)
Here's the function that applies the EQ changes: Private Sub EQSlideChanged(ByVal EQBand As Int32, ByVal Value As Int32)
'Get the Bass FX EQ Dim p As New Un4seen.Bass.AddOn.Fx.BASS_FX_DSPPEAKEQ
'Set which band we want to manipulate p.lBand = EQBand - 1
'Get the slider text object Dim lblValue As Infragistics.Win.Misc.UltraLabel = exbMixerPanel.Controls("lblLevel" & EQBand)
'Now get the current EQ settings for the specified band Call Un4seen.Bass.AddOn.Fx.BassFx.BASS_FX_DSP_GetParameters(strmPlay, p)
'Set the new value p.fGain = Value - 15
'Update the slider label If Not (lblValue Is Nothing) Then lblValue.Text = p.fGain lblValue.Invalidate() End If
'Reset the new EQ level on the stream If Not (Un4seen.Bass.AddOn.Fx.BassFx.BASS_FX_DSP_SetParameters(strmPlay, p)) Then Dim BassError As Un4seen.Bass.BASSErrorCode = Un4seen.Bass.Bass.BASS_ErrorGetCode
Call MsgBox(BassError.ToString) End If
End SubHTH!
|
|
|
|
« Last Edit: 14 Mar '07 - 11:40 by VorTechS »
|
Logged
|
|
|
|
|
kgs51
Posts: 26
|
 |
« Reply #2 on: 14 Mar '07 - 20:48 » |
Quote
|
Thank you very much. This should be a great help .
Ken
|
|
|
|
|
Logged
|
|
|
|
|
kgs51
Posts: 26
|
 |
« Reply #3 on: 15 Mar '07 - 18:49 » |
Quote
|
What min and max values do you use for the trackbars.
|
|
|
|
|
Logged
|
|
|
|
|
VorTechS
Posts: 241
|
 |
« Reply #4 on: 15 Mar '07 - 22:20 » |
Quote
|
Off-hand I forgot, and will confirm in the morning [GMT]. I think Min=0, Max=30, giving a +/- range of 15.
I'll be reviewing some of the code though to make the low-mid ranges more granular so that they don't distort when the trackbar values are above 17/18.
|
|
|
|
|
Logged
|
|
|
|
|
kgs51
Posts: 26
|
 |
« Reply #5 on: 16 Mar '07 - 12:32 » |
Quote
|
How do you incorporate the min and max as well as the +/- values in your code for the trackbars. As for the initial values, I assume they are the tag values that you have listed. Thanks
Ken
|
|
|
|
|
Logged
|
|
|
|
|
VorTechS
Posts: 241
|
 |
« Reply #6 on: 16 Mar '07 - 12:54 » |
Quote
|
Each trackbar has a min of 0 and a max of 30. By default the value is set to 15.
This code ins EQSlideChanged then works out if the new value is a +/-.
p.fGain = Value - 15
...as we already know 15 is the center [or 0] we use that value to determine how much the deviation +/- is.
So, if
trackbar value = 0, then gain is 0-15 = -15 trackbar value = 15, then gain is 15-15 = 0 trackbar value = 30, then gain is 30-15 = +15
The tag values in the code represent the Mhz of each band on your equalizer. Take a look at the screenshot.
Trackbar1.tag = 31 = 31mhz Trackbar2.tag = 63 = 63 mhz Trackbar6.tag = 1000 = 1khz
....and so on. These values are used to setup the 10 bands on the stream [in the SetupEQ] function.
|
|
|
|
|
Logged
|
|
|
|
|
kgs51
Posts: 26
|
 |
« Reply #7 on: 16 Mar '07 - 13:10 » |
Quote
|
Thanks
Ken
|
|
|
|
|
Logged
|
|
|
|
|
radio42
Posts: 4030
|
 |
« Reply #8 on: 16 Mar '07 - 14:44 » |
Quote
|
Trackbar1.tag = 31 = 31mhz Trackbar2.tag = 63 = 63 mhz Trackbar6.tag = 1000 = 1khz
I don't want to influence, but it should be "Hz" and not "mHz" ;-)
|
|
|
|
|
Logged
|
|
|
|
|
VorTechS
Posts: 241
|
 |
« Reply #9 on: 16 Mar '07 - 15:19 » |
Quote
|
Haha, I'm not an audio n00b....honest! 
|
|
|
|
|
Logged
|
|
|
|
|
Jinja
Posts: 34
|
 |
« Reply #10 on: 22 Mar '07 - 17:08 » |
Quote
|
Hi Vortechs,
I recreated a test EQ with the code you wrote, but am getting distortion from -12dB.. do you get the same? Could you include the code you use to intialise Bass and the stream? maybe there's something I'm not doing right (before I call setupEQ).
Many thx!
|
|
|
|
|
Logged
|
|
|
|
|
VorTechS
Posts: 241
|
 |
« Reply #11 on: 22 Mar '07 - 21:13 » |
Quote
|
Yes, on the lower frequencies distortion is more noticable the more EQ is applied. I haven't actually addressed the issue myself yet, but have thought about doing so.
With the ranges giving you the problem, I would modify what the +/- values mean and the max values of the sliders, and instead of modifying by +1 on the scroll change, perhaps modify by 0.2 or 0.5 to 'smoothen' the EQ.
So in EQSlideChanged something a little like:
If EQBand=3 or EQBand=4 then 'Smoother EQ change to minimise distortion p.fGain = (Value/5) - <slider value max / 2> Else 'Set the new value p.fGain = Value - 15 EndIf
Obviously this is not real code, but should point you in the right direction. If you are still stuck, give me another shout and I'll address my own issue and re-post the code.
|
|
|
|
|
Logged
|
|
|
|
|
cheechai
Guest
|
 |
« Reply #12 on: 10 Oct '11 - 09:46 » |
Quote
|
Hi guys, i'm trying to mod below sample to my own project, but it shows that my DSP is not yet defined, can help to advise where is the part that i had missed?
i hav installed BASS.NET i hav added the BASS.NET API to my project i hav placed the native "BASS_FX.dll" in my executable directory (e.g. ./bin/Debug) i hav placed the native "BASS_FX.dll" in system32 as well i hav imported 'Un4seen.Bass.AddOn.Fx'
Best rgds Chai
|
|
|
|
|
Logged
|
|
|
|
|
Ian @ un4seen
Administrator
Posts: 15363
|
 |
« Reply #13 on: 10 Oct '11 - 13:39 » |
Quote
|
This thread is regarding an old version of BASS and the BASS_FX add-on. For example, instead of BASS_FX_DSP_Set and BASS_FX_DSPFX_PEAKEQ, you would now use BASS_ChannelSetFX and BASS_FX_BFX_PEAKEQ. Please see the documentation for details.
|
|
|
|
|
Logged
|
|
|
|
|
radio42
Posts: 4030
|
 |
« Reply #14 on: 11 Oct '11 - 04:24 » |
Quote
|
a) DO NOT copy the .dll to your system32 folder - just place it to your executable directory b) make sure to call BassFx.BASS_FX_GetVersion before other methods from it (this to ensure, that the BASS_FX assembly is actually loaded)
|
|
|
|
|
Logged
|
|
|
|
|
chai
Guest
|
 |
« Reply #15 on: 11 Oct '11 - 13:32 » |
Quote
|
Hi Ian, thks for the update, i didn't notice before u told me.  I had divert to BASS_FX_BFX_PEAKEQ intead, but when i use it, my handle value is 0, so i change it to BASS_FX_DX8_PARAMEQ, my handle got a value = 53687090X. and now, after i use Bass.BASS_FXSetParameters to update the gain value, the sound become terible "woouang..." sound. anything i miss out? or i should not use BASS_FX_DX8_PARAMEQ. Hi radio, i thought i saw in others forum that, to make it easy, place the dll into system folder? best rgds Chai
|
|
|
|
|
Logged
|
|
|
|
|
Ian @ un4seen
Administrator
Posts: 15363
|
 |
« Reply #16 on: 11 Oct '11 - 18:06 » |
Quote
|
I had divert to BASS_FX_BFX_PEAKEQ intead, but when i use it, my handle value is 0, so i change it to BASS_FX_DX8_PARAMEQ, my handle got a value = 53687090X. and now, after i use Bass.BASS_FXSetParameters to update the gain value, the sound become terible "woouang..." sound. anything i miss out? or i should not use BASS_FX_DX8_PARAMEQ.
What parameter structure are you using in the BASS_FXSetParameters call? Note that the BASS_FX_DX8_PARAMEQ and BASS_FX_BFX_PEAKEQ effects use different parameter structures. BASS_FX_DX8_PARAMEQ will require a separate effect (ie. BASS_ChannelSetFX call) for each band, so if you want multiple bands, it is generally preferable to use BASS_FX_BFX_PEAKEQ instead. If BASS_ChannelSetFX is failing to apply a BASS_FX effect, and the error code (see BASS_ErrorGetCode) is BASS_ERROR_ILLTYPE, that indicates that BASS_FX isn't loaded. Have you already added a BASS_FX_GetVersion call (eg. during initialization) to force the loading of BASS_FX? If not, please try that. i thought i saw in others forum that, to make it easy, place the dll into system folder?
That is not a good idea because different software may require a different version of the DLL. For example, if 2 apps do it, then 1 of them may be left using an incorrect DLL version.
|
|
|
|
|
Logged
|
|
|
|
|
Chai
Guest
|
 |
« Reply #17 on: 17 Oct '11 - 14:55 » |
Quote
|
Hi Ian, i was getting blur after searching, comparing, testing in all others forum that i had read thru this few day.... Dim bv As Integer = Bass.BASS_GetVersion(), i get 33818625 Dim bvfx As Integer = BassFx.BASS_FX_GetVersion(), i get 33818369 Bass.BASSVERSION, i get 516 Bassfx.BASSFXVERSION, i get 516 Dim fxEQ As Integer = Bass.BASS_ChannelSetFX(strm, BASSFXType.BASS_FX_BFX_PEAKEQ, 0), i get 0 Dim eq As New Un4seen.Bass.AddOn.Fx.BASS_BFX_PEAKEQ, i get 0 if this all mean the bassfx.dll was not loaded in correctly, pls guide me into correct step...  Best Rgds Chai
|
|
|
|
|
Logged
|
|
|
|
|