Author Topic: Equalizer  (Read 183 times)

azrael11

  • Posts: 25
Equalizer
« on: 6 Feb '19 - 08:17 »
Hello

Try to make a simple 10 band equalizer with this code above but i get an number error from the Bass_ErrorGetCode = 5

Here is the code... In Delphi. Try to keep it clean as i can.
Code: [Select]
var
  vPar_Set: array [0 .. 9] of BASS_BFX_PEAKEQ;

procedure Set_EQ;
const
  cFreq: array [0 .. 9] of Single = (70, 180, 320, 600, 1000, 3000, 6000, 12000, 14000, 16000);
var
  vi: Integer;
begin
  for vi := 0 to 9 do
  begin
  //Set an effect to HSAMPLE 
  BASS_ChannelSetFX(sound.str_music[1], BASS_FX_BFX_PEAKEQ, 0);

    with vPar_Set[vi] do
    begin
      vPar_Set[vi].lBand := vi;
      vPar_Set[vi].fBandwidth := 1;
      vPar_Set[vi].fQ := 1;
      vPar_Set[vi].fCenter := 1000;
      vPar_Set[vi].fGain := 0;
      vPar_Set[vi].lChannel := BASS_BFX_CHANALL;
    end;
    if BASS_FXSetParameters(vi, @vPar_Set[vi])= false then
      ShowMessage('Wrong : ' + vi.ToString + '  error num :' + BASS_ErrorGetCode.ToString); // Here get the error
//if BASS_FXSetParameters(sound.str_music[1], @vPar_Set[vi])= false then
//      ShowMessage('Wrong : ' + vi.ToString + '  error num :' + BASS_ErrorGetCode.ToString); // Same here error
  end;

end;

In the Error codes show me that i have BASS_ERROR_HANDLE.
I use only one HSapmle.

Thank you.

Ian @ un4seen

  • Administrator
  • Posts: 21533
Re: Equalizer
« Reply #1 on: 6 Feb '19 - 12:20 »
You need to retain the handle from the BASS_ChannelSetFX call and use it in the BASS_FXSetParameters call(s). The BASS_FX_BFX_PEAKEQ effect supports multiple bands in a single instance, so you only need one BASS_ChannelSetFX call. For example, like this:

Code: [Select]
DWORD eqfx;

...

eqfx = BASS_ChannelSetFX(stream, BASS_FX_BFX_PEAKEQ, 0);
for (int b = 0; b < 10; b++) {
  BASS_BFX_PEAKEQ param;
  param.lBand = b; // the band number
  param.fBandwidth = ...
  param.fQ = ...
  param.fCenter = ...
  param.fGain = ...
  param.lChannel = BASS_BFX_CHANALL;
  BASS_FXSetParameters(eqfx, &param); // apply the parameters
}

If the BASS_ChannelSetFX call fails (returns 0), make sure the BASS_FX.DLL is loaded by calling a function from it, eg. BASS_FX_GetVersion during initialization.

azrael11

  • Posts: 25
Re: Equalizer
« Reply #2 on: 7 Feb '19 - 08:22 »
You need to retain the handle from the BASS_ChannelSetFX call and use it in the BASS_FXSetParameters call(s). The BASS_FX_BFX_PEAKEQ effect supports multiple bands in a single instance, so you only need one BASS_ChannelSetFX call. For example, like this:

Code: [Select]
DWORD eqfx;

...

eqfx = BASS_ChannelSetFX(stream, BASS_FX_BFX_PEAKEQ, 0);
for (int b = 0; b < 10; b++) {
  BASS_BFX_PEAKEQ param;
  param.lBand = b; // the band number
  param.fBandwidth = ...
  param.fQ = ...
  param.fCenter = ...
  param.fGain = ...
  param.lChannel = BASS_BFX_CHANALL;
  BASS_FXSetParameters(eqfx, &param); // apply the parameters
}

If the BASS_ChannelSetFX call fails (returns 0), make sure the BASS_FX.DLL is loaded by calling a function from it, eg. BASS_FX_GetVersion during initialization.

Ian Thank you very much.

It seems that cant load the plugin BASS_FX it returns 0 and the Bass_errorgetcode gives me 2.
It means that the versions cant fit.
I wonder so bcs i download the latest version both of them.
The bass i have the 2.4.14 and the Bass_FX i have the 2.4.12.1. So i must download the version 2.4.12 of bass to work or i am doing something wrong.
Here is the code ...
Code: [Select]
 
if (HiWord(BASS_GetVersion) <> BASSVERSION) then
  begin
    MessageBox(0, 'An incorrect version of BASS.DLL was loaded', nil, MB_ICONERROR);
    Halt;
  end;
  if not BASS_Init(-1, 44100, BASS_DEVICE_SPEAKERS, Winapi.Windows.HANDLE_PTR(Main_Form), nil) then
    MessageBox(0, 'Error initializing audio!', nil, MB_ICONERROR);
  if BASS_PluginLoad(PChar(extrafe.prog.Paths.Lib + 'bass_fx.dll'), 0) = 0 then
//  if BASS_PluginLoad(PChar('bass_fx.dll'), 0) = 0 then //try also this gives me the same result
  begin
    if High(BASS_FX_GetVersion) <> BASSVERSION then
      ShowMessage('incorrect version (Bass = ' + BASSVERSIONTEXT + ' <> ' + BASS_FX_GetVersion.ToString +
        ' (Bass error : ' + Bass_ErrorGetCode.ToString+ ')');
    ShowMessage('Plug in : BASS_FX not loading');
  end;

Another strange think i found is that if i change the Const path of bass.dll to lib\bass.dll and put the dll in the root folder lib then everything is ok the bass is loading just fine.
But when i change the const path of the bass_fx.dll to lib\bass_fx.dll then i get an error messege the bass.dll cant find an reinstallation maybe fix the problem.

Thank you.


Ian @ un4seen

  • Administrator
  • Posts: 21533
Re: Equalizer
« Reply #3 on: 7 Feb '19 - 14:05 »
BASS_PluginLoad is only for loading add-ons that provide support for additional file formats, so you can't load BASS_FX that way. You should call a BASS_FX function to force it to be loaded, eg. BASS_FX_GetVersion.

azrael11

  • Posts: 25
Re: Equalizer
« Reply #4 on: 8 Feb '19 - 06:55 »
BASS_PluginLoad is only for loading add-ons that provide support for additional file formats, so you can't load BASS_FX that way. You should call a BASS_FX function to force it to be loaded, eg. BASS_FX_GetVersion.

Oh I see...
I call it that way based on the sample code that gives the Bass_fx in the documentation file.

Code: [Select]
if BASS_FX_GetVersion <> BASS_GetVersion then
  begin
    ShowMessage('Plug in : BASS_FX not loading : incorrect version (Bass = ' + BASSVERSIONTEXT + ' <> ' +
      BASS_FX_GetVersion.ToString + ' (Bass error : ' + Bass_ErrorGetCode.ToString + ')');
  end;

and gives me that Bass version is 2.4 and Bass_Fx version is 33819649 and the bass_fx not loading.
I reapeat that i have the latest both of them libraries.

Thank you Ian again.



Ian @ un4seen

  • Administrator
  • Posts: 21533
Re: Equalizer
« Reply #5 on: 8 Feb '19 - 15:52 »
You can't compare the full BASS and BASS_FX version numbers like that (they will pretty much always be different) but you can compare the major version numbers, which are in the high 16 bits (HIWORD).

Note that if you can call the BASS_FX_GetVersion function then that means BASS_FX was loaded :)