Author Topic: [Android] - Making 10 band equalizer, frequencies and Bandwidth  (Read 3024 times)

HappiestGabbler

  • Posts: 42
I want to make 10-band equalizer, which frequencies i need to use? and i don't know what i need to set to bandwidth..

i have tried to set bandwidth to 0.5F, but i didn't hear difference between nominal frequency and changed frequency  :(

Ian @ un4seen

  • Administrator
  • Posts: 20427
A 10 band equalizer would typically use a bandwidth of 12 semitones (1 octave) with the bands centred at the following frequencies: 31.25, 62.5, 125, 250, 500, 1000, 2000, 4000, 8000, 16000.

HappiestGabbler

  • Posts: 42
A 10 band equalizer would typically use a bandwidth of 12 semitones (1 octave) with the bands centred at the following frequencies: 31.25, 62.5, 125, 250, 500, 1000, 2000, 4000, 8000, 16000.

Thank you! but it doesn't work... :(

I don't hear any changes in sound..

Also, i deleted reverb

I use FXTest from examples, that is my code of "OpenClicked" method:

 
Code: [Select]
public void OpenClicked(View v) {
String[] list=filepath.list();
if (list==null) list=new String[0];
if (!filepath.getPath().equals("/")) {
filelist=new String[list.length+1];
filelist[0]="..";
System.arraycopy(list, 0, filelist, 1, list.length);
} else
filelist=list;
        new AlertDialog.Builder(this)
.setTitle("Choose a file to play")
.setItems(filelist, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
File sel;
if (filelist[which].equals("..")) sel=filepath.getParentFile();
else sel=new File(filepath, filelist[which]);
if (sel.isDirectory()) {
filepath=sel;
OpenClicked(null);
} else {
String file=sel.getPath();
// first free the current one (try both MOD and stream - it must be one of them)
BASS.BASS_MusicFree(chan);
BASS.BASS_StreamFree(chan);
if ((chan=BASS.BASS_StreamCreateFile(file, 0, 0, BASS.BASS_SAMPLE_LOOP))==0
&& (chan=BASS.BASS_MusicLoad(file, 0, 0, BASS.BASS_SAMPLE_LOOP|BASS.BASS_MUSIC_RAMP, 1))==0) {
// whatever it is, it ain't playable
((Button)findViewById(R.id.open)).setText("press here to open a file");
Error("Can't play the file");
return;
}
((Button)findViewById(R.id.open)).setText(file);
// setup the effects and start playing
fx[0]=BASS.BASS_ChannelSetFX(chan, BASS.BASS_FX_DX8_PARAMEQ, 0);
fx[1]=BASS.BASS_ChannelSetFX(chan, BASS.BASS_FX_DX8_PARAMEQ, 0);
fx[2]=BASS.BASS_ChannelSetFX(chan, BASS.BASS_FX_DX8_PARAMEQ, 0);
fx[3]=BASS.BASS_ChannelSetFX(chan, BASS.BASS_FX_DX8_PARAMEQ, 0);
fx[4]=BASS.BASS_ChannelSetFX(chan, BASS.BASS_FX_DX8_PARAMEQ, 0);
fx[5]=BASS.BASS_ChannelSetFX(chan, BASS.BASS_FX_DX8_PARAMEQ, 0);
fx[6]=BASS.BASS_ChannelSetFX(chan, BASS.BASS_FX_DX8_PARAMEQ, 0);
fx[7]=BASS.BASS_ChannelSetFX(chan, BASS.BASS_FX_DX8_PARAMEQ, 0);
fx[8]=BASS.BASS_ChannelSetFX(chan, BASS.BASS_FX_DX8_PARAMEQ, 0);
fx[9]=BASS.BASS_ChannelSetFX(chan, BASS.BASS_FX_DX8_PARAMEQ, 0);

BASS.BASS_DX8_PARAMEQ p=new BASS.BASS_DX8_PARAMEQ();


p.fGain=0;
                         p.fBandwidth = 1;
                         p.fCenter=31.25F;
                         BASS.BASS_FXSetParameters(fxBands[0], p);
                         p.fCenter=62.5F;
                         BASS.BASS_FXSetParameters(fxBands[1], p);
                         p.fCenter=125;
                         BASS.BASS_FXSetParameters(fxBands[2], p);
                         p.fCenter=250;
                        BASS.BASS_FXSetParameters(fxBands[3], p);
                        p.fCenter=500;
                        BASS.BASS_FXSetParameters(fxBands[4], p);
                        p.fCenter=1000;
                        BASS.BASS_FXSetParameters(fxBands[5], p);
                        p.fCenter=2000;
                        BASS.BASS_FXSetParameters(fxBands[6], p);
                        p.fCenter=4000;
                        BASS.BASS_FXSetParameters(fxBands[7], p);
                        p.fCenter=8000;
                        BASS.BASS_FXSetParameters(fxBands[8], p);
                        p.fCenter=16000;
                        BASS.BASS_FXSetParameters(fxBands[9], p);

UpdateFX((SeekBar)findViewById(R.id.eq1));
UpdateFX((SeekBar)findViewById(R.id.eq2));
UpdateFX((SeekBar)findViewById(R.id.eq3));
    UpdateFX((SeekBar)findViewById(R.id.eq4));
UpdateFX((SeekBar)findViewById(R.id.eq5));
UpdateFX((SeekBar)findViewById(R.id.eq6));
UpdateFX((SeekBar)findViewById(R.id.eq7));
UpdateFX((SeekBar)findViewById(R.id.eq8));
UpdateFX((SeekBar)findViewById(R.id.eq9));
UpdateFX((SeekBar)findViewById(R.id.eq10));
BASS.BASS_ChannelPlay(chan, false);
}
}
})
    .show();
}

Other methods which i changed:

1)OnCreate method:

 
Code: [Select]
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

filepath=Environment.getExternalStorageDirectory();

// initialize default output device
if (!BASS.BASS_Init(-1, 44100, 0)) {
Error("Can't initialize device");
return;
}

// enable floating-point (actually 8.24 fixed-point) DSP/FX
BASS.BASS_SetConfig(BASS.BASS_CONFIG_FLOATDSP, 1);

        SeekBar.OnSeekBarChangeListener osbcl=new SeekBar.OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {}

@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
UpdateFX(seekBar);
}
};
((SeekBar)findViewById(R.id.eq1)).setOnSeekBarChangeListener(osbcl);
((SeekBar)findViewById(R.id.eq2)).setOnSeekBarChangeListener(osbcl);
((SeekBar)findViewById(R.id.eq3)).setOnSeekBarChangeListener(osbcl);
((SeekBar)findViewById(R.id.eq4)).setOnSeekBarChangeListener(osbcl);
((SeekBar)findViewById(R.id.eq5)).setOnSeekBarChangeListener(osbcl);
((SeekBar)findViewById(R.id.eq6)).setOnSeekBarChangeListener(osbcl);
((SeekBar)findViewById(R.id.eq7)).setOnSeekBarChangeListener(osbcl);
((SeekBar)findViewById(R.id.eq8)).setOnSeekBarChangeListener(osbcl);
((SeekBar)findViewById(R.id.eq9)).setOnSeekBarChangeListener(osbcl);
((SeekBar)findViewById(R.id.eq10)).setOnSeekBarChangeListener(osbcl);
    }


2)UpdateFX method:

Code: [Select]
public void UpdateFX(SeekBar sb) {
        int v=sb.getProgress();
        int n=Integer.parseInt((String)sb.getTag());

            BASS.BASS_DX8_PARAMEQ p=new BASS.BASS_DX8_PARAMEQ();
            BASS.BASS_FXGetParameters(fx[n], p);
            p.fGain=v-10;
            BASS.BASS_FXSetParameters(fx[n], p);

    }


Finally,  i changed array:

 
Code: [Select]
int[] fx=new int[10];
« Last Edit: 28 Feb '14 - 15:34 by HappiestGabbler »

Ian @ un4seen

  • Administrator
  • Posts: 20427
Code: [Select]
                         p.fBandwidth = 1;

The BASS_DX8_PARAMEQ "fBandwidth" parameter is in semitones (not octaves), so that should be 12. If you still hear no effect, then please try stepping through the UpdateFX function to confirm that the calls in there are successful (via the return values).

HappiestGabbler

  • Posts: 42
Code: [Select]
                        p.fBandwidth = 1;

The BASS_DX8_PARAMEQ "fBandwidth" parameter is in semitones (not octaves), so that should be 12. If you still hear no effect, then please try stepping through the UpdateFX function to confirm that the calls in there are successful (via the return values).


I changed "fBandwidth" to 12, now i hear the difference, but when i try to change high frequency i hear that low frequency changes instead high...
« Last Edit: 28 Feb '14 - 15:35 by HappiestGabbler »

Ian @ un4seen

  • Administrator
  • Posts: 20427
If you check the return value of the getTag call for the troublesome bands in the UpdateFX function, what is it? The FXTEST example uses the "tag" field to map each EQ slider to a particular band (tag=0 for 1st band, tag=1 for 2nd band, etc), and it sounds like you might not have set "tag" values when adding the extra bands to the UI.

HappiestGabbler

  • Posts: 42
If you check the return value of the getTag call for the troublesome bands in the UpdateFX function, what is it? The FXTEST example uses the "tag" field to map each EQ slider to a particular band (tag=0 for 1st band, tag=1 for 2nd band, etc), and it sounds like you might not have set "tag" values when adding the extra bands to the UI.

Thank you!!! i solved my problem) i forgot to set tags in main.xml :P
You really helped me, thank you :)
« Last Edit: 1 Mar '14 - 09:00 by HappiestGabbler »