Author Topic: Equalizer on Raspberry (BASS ARM6)  (Read 229 times)

rdkartono

  • Posts: 11
Equalizer on Raspberry (BASS ARM6)
« on: 17 Mar '17 - 10:36 »
Been trying to make Equalizer work on Raspberry this whole week, but not succesful yet. I use JAVA in Eclipse for programming.

Of course, I have loaded libbass_fx.so sucessfully, and can get BASS_FX_GetVersion number sucessfully.

Bass_ChannelSetFX function, can return FX Handler numbers (I want to use 10 bands Equalizer) normally.
Code: [Select]
int BASS_FX_DX8_PARAMEQ = 7;

EqualizerHandle[ii] = bass.BASS_ChannelSetFX(ch_handle, BASS_FX_DX8_PARAMEQ, 0);   // return normal values

Code: [Select]
int BASS_FX_BFX_PEAKEQ = 0x10004;

EqualizerHandle[ii] = bass.BASS_ChannelSetFX(ch_handle, BASS_FX_BFX_PEAKEQ, 0);   // return normal values


1. If I use BASS_DX8_PARAMEQ, both BASS_FXGetParameters and BASS_FXSetParameters return TRUE. But I felt nothing change in MP3 songs played. Structure on BASS_DX8_PARAMEQ as follow :
Code: [Select]
public class BASS_DX8_PARAMEQ extends Structure implements Structure.ByReference {
public float fCenter;
public float fBandwidth;
public float fGain;
@Override
protected List<String> getFieldOrder() {
// TODO Auto-generated method stub
return Arrays.asList("fCenter","fBandwidth","fGain");
}

}

2. If I use BASS_BFX_PEAKEQ, both BASS_FXGetParameters and BASS_FXSetParameters return FALSE. Tried all examples I could find, but still no hope. Structure on BASS_BFX_PEAKEQ as follow :
Code: [Select]
public class BASS_BFX_PEAKEQ extends Structure implements Structure.ByReference   {
public int lBand;                        // [0...............n] more bands means more memory & cpu usage
    public float fBandwidth;                // [0.1...........<10] in octaves - fQ is not in use (Bandwidth has a priority over fQ)
    public float fQ;                        // [0...............1] the EE kinda definition (linear) (if Bandwidth is not in use)
    public float fCenter;                    // [1Hz..<info.freq/2] in Hz
    public float fGain;                        // [-15dB...0...+15dB] in dB (can be above/below these limits)
    public int lChannel;                    // BASS_BFX_CHANxxx flag/s
@Override
protected List<String> getFieldOrder() {
// TODO Auto-generated method stub
return Arrays.asList("lBand","fBandwidth","fQ","fCenter","fGain","lChannel");
}
}


If anybody have experiences about it, please share your tips.

Thanks.

Ian @ un4seen

  • Administrator
  • Posts: 20210
Re: Equalizer on Raspberry (BASS ARM6)
« Reply #1 on: 17 Mar '17 - 16:43 »
To confirm whether the effect parameters are being handled correctly, if you call BASS_FXGetParameters straight after BASS_ChannelSetFX, what values do you get? The BASS_DX8_PARAMEQ "fCenter" should default to 8000, "fBandwidth" to 12, and "fGain" to 0. If that's fine, also try calling BASS_FXGetParameters straight after BASS_FXSetParameters, and check whether you get back the same values as you just set (reset the parameter structure in between to be sure they're not just untouched).

rdkartono

  • Posts: 11
Re: Equalizer on Raspberry (BASS ARM6)
« Reply #2 on: 18 Mar '17 - 06:47 »
thanks for the hint, Ian.

I will try it on Monday, and update with results.

rdkartono

  • Posts: 11
Re: Equalizer on Raspberry (BASS ARM6)
« Reply #3 on: 20 Mar '17 - 01:46 »
To confirm whether the effect parameters are being handled correctly, if you call BASS_FXGetParameters straight after BASS_ChannelSetFX, what values do you get? The BASS_DX8_PARAMEQ "fCenter" should default to 8000, "fBandwidth" to 12, and "fGain" to 0. If that's fine, also try calling BASS_FXGetParameters straight after BASS_FXSetParameters, and check whether you get back the same values as you just set (reset the parameter structure in between to be sure they're not just untouched).

Tried your suggestion this morning, with following complete code :

For version of Bass_FX i use this code :

Code: [Select]
System.out.println("BASS_FX version="+bassfx.BASS_FX_GetVersion());

and I got result : BASS_FX version=33819393

For Equalizer i use this code :

Code: [Select]
public boolean PrepareBassEqualizer(int ch_handle){
if (ch_handle==0) {
for (int ii=0;ii<10;ii++) {
if (EqualizerHandle[ii]!=0) {
EqualizerHandle[ii]=0;
}
}
return false;
}

bass.BASS_FXReset(ch_handle);
BASS_DX8_PARAMEQ eq = new BASS_DX8_PARAMEQ();
for (int ii=0;ii<10;ii++) {
EqualizerHandle[ii] = bass.BASS_ChannelSetFX(ch_handle, BASS_CONSTANT.BASS_FX_DX8_PARAMEQ, 0);
if (EqualizerHandle[ii]!=0) {
bass.BASS_FXGetParameters(EqualizerHandle[ii], eq);
System.out.println("Previous Band "+ii);
System.out.println("Previous fCenter="+eq.fCenter);
System.out.println("Previous fGain="+eq.fGain);
System.out.println("Previous fBandwidth="+eq.fBandwidth);
eq.fCenter = EqualizerFrequency[ii];
eq.fBandwidth = EqualizerBW[ii];
eq.fGain = EqualizerGain[ii];
if (bass.BASS_FXSetParameters(EqualizerHandle[ii], eq)==false) {
int err = bass.BASS_ErrorGetCode();
switch(err) {
case BASS_CONSTANT.BASS_ERROR_HANDLE :
System.out.println("Prepare EQ band "+ii+" fail, handle invalid");
break;
case BASS_CONSTANT.BASS_ERROR_ILLPARAM :
System.out.println("Prepare EQ band "+ii+" fail, Parameter invalid");
break;
default :
System.out.println("Prepare EQ band "+ii+" fail, errorcode="+err);
break;
}
} else {
System.out.println("Prepare EQ band "+ii+" sucess");
bass.BASS_FXGetParameters(EqualizerHandle[ii], eq);
System.out.println("Current band "+ii);
System.out.println("Current fCenter="+eq.fCenter);
System.out.println("Current fGain="+eq.fGain);
System.out.println("Current fBandwidth="+eq.fBandwidth);
}
} else {
int err = bass.BASS_ErrorGetCode();
switch(err) {
case BASS_CONSTANT.BASS_ERROR_HANDLE :
System.out.println("ChannelSetFX band "+ii+" fail, Handle is not valid");
break;
case BASS_CONSTANT.BASS_ERROR_ILLTYPE :
System.out.println("ChannelSetFX band "+ii+" fail, Type is invalid");
break;
case BASS_CONSTANT.BASS_ERROR_FORMAT :
System.out.println("ChannelSetFX band "+ii+" fail, Effect only apply to stereo/mono channel");
break;
default :
System.out.println("ChannelSetFX band "+ii+" fail, Error code="+err);
break;
}

}
}
return true;
}

So basically, I do ChannelSetFX for 10 times (then i got 10 EQ handles), then I do FXGetParameters , printout previous values, then change values accordingly, then FXSetParameters.
If TRUE, then i recheck again using FXGetParameters for current values.

Result printout are :

Code: [Select]
Previous Band 0
Previous fCenter=0.0
Previous fGain=0.0
Previous fBandwidth=0.0
Prepare EQ band 0 sucess
Current band 0
Current fCenter=32.0
Current fGain=0.0
Current fBandwidth=0.5

Previous Band 1
Previous fCenter=32.0
Previous fGain=0.0
Previous fBandwidth=0.5
Prepare EQ band 1 sucess
Current band 1
Current fCenter=64.0
Current fGain=0.0
Current fBandwidth=0.5

Previous Band 2
Previous fCenter=64.0
Previous fGain=0.0
Previous fBandwidth=0.5
Prepare EQ band 2 sucess
Current band 2
Current fCenter=125.0
Current fGain=0.0
Current fBandwidth=0.5

Previous Band 3
Previous fCenter=125.0
Previous fGain=0.0
Previous fBandwidth=0.5
Prepare EQ band 3 sucess
Current band 3
Current fCenter=250.0
Current fGain=0.0
Current fBandwidth=2.0

Previous Band 4
Previous fCenter=250.0
Previous fGain=0.0
Previous fBandwidth=2.0
Prepare EQ band 4 sucess
Current band 4
Current fCenter=500.0
Current fGain=0.0
Current fBandwidth=2.0

Previous Band 5
Previous fCenter=500.0
Previous fGain=0.0
Previous fBandwidth=2.0
Prepare EQ band 5 sucess
Current band 5
Current fCenter=1000.0
Current fGain=0.0
Current fBandwidth=4.0

Previous Band 6
Previous fCenter=1000.0
Previous fGain=0.0
Previous fBandwidth=4.0
Prepare EQ band 6 sucess
Current band 6
Current fCenter=2000.0
Current fGain=0.0
Current fBandwidth=4.0

Previous Band 7
Previous fCenter=2000.0
Previous fGain=0.0
Previous fBandwidth=4.0
Prepare EQ band 7 sucess
Current band 7
Current fCenter=4000.0
Current fGain=0.0
Current fBandwidth=4.0

Previous Band 8
Previous fCenter=4000.0
Previous fGain=0.0
Previous fBandwidth=4.0
Prepare EQ band 8 sucess
Current band 8
Current fCenter=8000.0
Current fGain=0.0
Current fBandwidth=8.0

Previous Band 9
Previous fCenter=8000.0
Previous fGain=0.0
Previous fBandwidth=8.0
Prepare EQ band 9 sucess
Current band 9
Current fCenter=16000.0
Current fGain=0.0
Current fBandwidth=8.0


So the strange things are :
1. The first FXGetParameters for getting previous values, dont return fCenter=8000, fGain=0, fBandwidth=12... instead it return 0 values for the first handler. Second handler return first handler's value. Third handler return second handler's value, and so on.. This seems incorrect...

2. FXSetParameters returned TRUE for all EQ handles, so I check again with FXGetParameters for current values. Seems returning correct values.

So.. i guess FXSetParameters and FXGetParameters are still not working for Raspberry (ARM) ?

rdkartono

  • Posts: 11
Re: Equalizer on Raspberry (BASS ARM6)
« Reply #4 on: 20 Mar '17 - 02:09 »
I confirmed that this Equalizer is not working on Raspberry (ARM).

I played with Equalizer on Websocket page. I made 10 vertical slider and link it with this code :
Code: [Select]
public boolean UpdateEqualizer(int band, int gain) {
if (EqualizerHandle[band]==0) return false;
if (gain<-15) gain = -15;
if (gain>15) gain=15;

BASS_DX8_PARAMEQ eq = new BASS_DX8_PARAMEQ();
if (bass.BASS_FXGetParameters(EqualizerHandle[band], eq)==false) {
int err = bass.BASS_ErrorGetCode();
switch(err) {
case BASS_CONSTANT.BASS_ERROR_HANDLE :
System.out.println("FXGetParameter EQ "+band+" failed, handle invalid");
break;
case BASS_CONSTANT.BASS_ERROR_ILLPARAM :
System.out.println("FXGetParameter EQ "+band+" failed, Parameter value invalid");
break;
default :
System.out.println("FXGetParameter EQ "+band+" failed, errorcode="+err);
break;
}
} else {
System.out.println("band "+band+" previous fGain="+eq.fGain+" on fCenter="+eq.fCenter);
}
EqualizerGain[band]=(float)gain;
eq.fGain = EqualizerGain[band];
if (bass.BASS_FXSetParameters(EqualizerHandle[band], eq)) {
bass.BASS_FXGetParameters(EqualizerHandle[band], eq);
System.out.println("band "+band+" current fGain="+eq.fGain+" on fCenter="+eq.fCenter);
return true;
} else {
int err = bass.BASS_ErrorGetCode();
switch(err) {
case BASS_CONSTANT.BASS_ERROR_HANDLE :
System.out.println("FXSetParameter EQ "+band+" failed, handle invalid");
break;
case BASS_CONSTANT.BASS_ERROR_ILLPARAM :
System.out.println("FXSetParameter EQ "+band+" failed, Parameter invalid");
break;
default :
System.out.println("FXSetParameter EQ "+band+" failed, errorcode="+err);
break;
}
return false;
}

}

and i got results :
Code: [Select]
band 0 previous fGain=0.0 on fCenter=0.0
band 0 current fGain=1.0 on fCenter=0.0
New Value for 32 Hz : 1                                             ---> this from slider 0 result, not code result
band 0 previous fGain=0.0 on fCenter=0.0
band 0 current fGain=3.0 on fCenter=0.0
New Value for 32 Hz : 3                                             ---> slider 0 result, not code reuslt
band 0 previous fGain=0.0 on fCenter=0.0
band 0 current fGain=4.0 on fCenter=0.0
New Value for 32 Hz : 4                                            ----> slider 0 result, not code result
band 0 previous fGain=0.0 on fCenter=0.0
band 0 current fGain=6.0 on fCenter=0.0
New Value for 32 Hz : 6
band 0 previous fGain=0.0 on fCenter=0.0
band 0 current fGain=7.0 on fCenter=0.0
New Value for 32 Hz : 7
band 0 previous fGain=0.0 on fCenter=0.0
band 0 current fGain=9.0 on fCenter=0.0
New Value for 32 Hz : 9
band 0 previous fGain=0.0 on fCenter=0.0
band 0 current fGain=10.0 on fCenter=0.0
New Value for 32 Hz : 10
band 0 previous fGain=0.0 on fCenter=0.0
band 0 current fGain=12.0 on fCenter=0.0
New Value for 32 Hz : 12
band 0 previous fGain=0.0 on fCenter=0.0
band 0 current fGain=13.0 on fCenter=0.0
New Value for 32 Hz : 13
band 0 previous fGain=0.0 on fCenter=0.0
band 0 current fGain=14.0 on fCenter=0.0
New Value for 32 Hz : 14
band 0 previous fGain=0.0 on fCenter=0.0
band 0 current fGain=15.0 on fCenter=0.0
New Value for 32 Hz : 15

Suprisingly adding some System.out.println to check logs, showing that previous values set on function PrepareEqualizer is not saved on FXSetParameters.
Calling another FXGetParameters on function UpdateEqualizer, showing that all values are 0.

Is there any wrong in my codes ?

Ian @ un4seen

  • Administrator
  • Posts: 20210
Re: Equalizer on Raspberry (BASS ARM6)
« Reply #5 on: 20 Mar '17 - 15:23 »
It looks like there's a problem in how the parameter structure (BASS_BFX_PEAKEQ) is being passed to BASS_FXSetParameters/BASS_FXGetParameters. I'm not familiar with the JNA way of passing parameters between Java and C (I've only used JNI to do it), but perhaps there is a problem in that? How have you declared the BASS_FXSetParameters/BASS_FXGetParameters functions?

To confirm whether the BASS_FX_DX8_PARAMEQ effect and BASS_BFX_PEAKEQ parameters are working correctly outside of Java, please try building and running the FXTEST example. You can get the examples from the standard Linux BASS package (replace the MAKEFILE.IN file with the version from the ARM Linux package). Go to the BASS directory in a Terminal window and type "make fxtest".

rdkartono

  • Posts: 11
Re: Equalizer on Raspberry (BASS ARM6)
« Reply #6 on: 22 Mar '17 - 03:06 »
FINALLY !!!

Instead of using class or structure, i just make an array of  float, length=3 floats (index 0=fCenter, index 1=fBandwidth, index 2 = fGain), and bass it to BASS_FXSetParameters and BASS_FXGetParameters, and they are working just right !!

Thanks Ian for tips given.