Beispiel #1
0
  public static void updateEqualizerSettings(Context context) {

    SharedPreferences mPreferences =
        context.getSharedPreferences(
            APOLLO_PREFERENCES, Context.MODE_WORLD_READABLE | Context.MODE_WORLD_WRITEABLE);

    if (mBoost != null) {
      mBoost.setEnabled(mPreferences.getBoolean("simple_eq_boost_enable", false));
      mBoost.setStrength((short) (mPreferences.getInt("simple_eq_bboost", 0) * 10));
    }

    if (mEqualizer != null) {
      mEqualizer.setEnabled(mPreferences.getBoolean("simple_eq_equalizer_enable", false));
      short numBands = mEqualizer.getNumberOfBands() <= 6 ? mEqualizer.getNumberOfBands() : 6;
      short r[] = mEqualizer.getBandLevelRange();
      short min_level = r[0];
      short max_level = r[1];
      for (int i = 0; i <= (numBands - 1); i++) {
        int new_level =
            min_level
                + (max_level - min_level)
                    * mPreferences.getInt("simple_eq_seekbars" + String.valueOf(i), 100)
                    / 100;
        mEqualizer.setBandLevel((short) i, (short) new_level);
      }
    }
  }
Beispiel #2
0
 public void initBassBoost() {
   try {
     bassBoost = getBassBoost();
     if (null != bassBoost) {
       bassBoost.setEnabled(true);
       BassBoost.Settings bassBoostSettingTemp = bassBoost.getProperties();
       BassBoost.Settings bassBoostSetting =
           new BassBoost.Settings(bassBoostSettingTemp.toString());
       bassBoostSetting.strength = 0;
       bassBoost.setProperties(bassBoostSetting);
       Log.e("bbSetTemp", bassBoost.getProperties().toString());
     }
   } catch (Exception localException) {
     localException.printStackTrace();
   }
 }
Beispiel #3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.equalizer_main);
    if (null == getEqualizer() || null == getVirtualizer() || null == getBassBoost()) finish();
    startService(new Intent(this, MyService.class));
    prefs = getPreferences(MODE_PRIVATE);

    initApp();

    initEqualizer();

    if (Utils.isOn) {
      enableAll();
    } else {
      disableAll();

      onOffBtn.setImageResource(R.drawable.off_btn);
      Utils.isOn = false;

      Log.e("eqActive", Boolean.toString(equalizer.getEnabled()));
      dontTouch.setVisibility(View.VISIBLE);
      equalizer.setEnabled(false);

      equalizer.release();
      bassBoost.release();
      virtualizer.release();
      disableAll();
    }
    super.onCreate(savedInstanceState);
  }
Beispiel #4
0
 public static void releaseEqualizer() {
   if (mEqualizer != null) {
     mEqualizer.release();
   }
   if (mBoost != null) {
     mBoost.release();
   }
 }
Beispiel #5
0
  private void initDB() {

    final int DEF = 15;
    myProgressDataSource = new ProgressDataSource(this);
    myProgressDataSource.open();

    values = myProgressDataSource.getAllPgs();

    Log.e("valSize", Integer.toString(values.size()));

    if (values.size() == 0) {
      myProgressDataSource.createProgress(DEF, DEF, DEF, DEF, DEF, 0, 0, 0);
    } else {
      Log.e("valuesPgs", Integer.toString(values.get(0).getProgress(1)));
      int progress;
      presetsSpinner.setSelection(values.get(0).getUser());

      ProgressClass value = values.get(0);
      setValues(sbP1, sb1, band1, value.getProgress(1));
      setValues(sbP2, sb2, band2, value.getProgress(2));
      setValues(sbP3, sb3, band3, value.getProgress(3));
      setValues(sbP4, sb4, band4, value.getProgress(4));
      setValues(sbP5, sb5, band5, value.getProgress(5));
      progress = values.get(0).getArc(1);
      Log.e("dbSK1", Integer.toString(progress));
      sk1.setProgress(progress);
      sk1pgs = progress;
      bassBoost.setStrength((short) (progress * 10));
      progress = values.get(0).getArc(2);
      Log.e("dbSK2", Integer.toString(progress));
      sk2.setProgress(progress);
      sk2pgs = progress;
      virtualizer.setStrength((short) (progress * 10));
    }
    myProgressDataSource.close();
  }
Beispiel #6
0
  @Override
  public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

    seekBar.setProgress(progress);

    // ===========================================temporary
    if (seekBar == sk1) {

      BassBoost.Settings settings = bassBoost.getProperties();
      settings.strength = ((short) (progress * 10));
      bassBoost.setProperties(settings);
      if (progress != 0) {
        presetsSpinner.setSelection(0);
      }
      sk1pgs = progress;

    } else if (seekBar == sk2) {

      virtualizer.setStrength((short) (progress * 10));
      if (progress != 0) {
        presetsSpinner.setSelection(0);
      }
      sk2pgs = progress;
    }

    // ===============================================/temporary

    if (progress == 15) progress = 0;
    else progress = progress - 15;

    if (seekBar == sb1) {

      sbP1.setText(Integer.toString(progress));
      presetsSpinner.setSelection(0);
      Utils.changeAtBand(equalizer, band1, progress);

    } else if (seekBar == sb2) {

      sbP2.setText(Integer.toString(progress));
      presetsSpinner.setSelection(0);
      Utils.changeAtBand(equalizer, band2, progress);

    } else if (seekBar == sb3) {

      sbP3.setText(Integer.toString(progress));
      presetsSpinner.setSelection(0);
      Utils.changeAtBand(equalizer, band3, progress);

    } else if (seekBar == sb4) {

      sbP4.setText(Integer.toString(progress));
      presetsSpinner.setSelection(0);
      Utils.changeAtBand(equalizer, band4, progress);

    } else if (seekBar == sb5) {

      sbP5.setText(Integer.toString(progress));
      presetsSpinner.setSelection(0);
      Utils.changeAtBand(equalizer, band5, progress);
    }
    Utils.setEqPrefs(MyEqualizer.this, true);
  }
Beispiel #7
-1
 public static void setEqualizer(Context context, int audioSessionId) {
   if (Utils.getEqPrefs(context)) {
     Equalizer equalizer = new Equalizer(1, audioSessionId);
     BassBoost bassBoost = new BassBoost(2, audioSessionId);
     Virtualizer virtualizer = new Virtualizer(3, audioSessionId);
     equalizer.setEnabled(true);
     bassBoost.setEnabled(true);
     virtualizer.setEnabled(true);
     ProgressDataSource myProgressDataSource = new ProgressDataSource(context);
     myProgressDataSource.open();
     List<ProgressClass> values = myProgressDataSource.getAllPgs();
     if (values.size() == 0) {
       myProgressDataSource.createProgress(0, 0, 0, 0, 0, 0, 0, 0);
     } else {
       // Set equalizer
       Utils.changeAtBand(equalizer, (short) 0, values.get(0).getProgress(1) - 15);
       Utils.changeAtBand(equalizer, (short) 1, values.get(0).getProgress(2) - 15);
       Utils.changeAtBand(equalizer, (short) 2, values.get(0).getProgress(3) - 15);
       Utils.changeAtBand(equalizer, (short) 3, values.get(0).getProgress(4) - 15);
       Utils.changeAtBand(equalizer, (short) 4, values.get(0).getProgress(5) - 15);
       // Set bassboost
       bassBoost.setStrength((short) (values.get(0).getArc(1) * 10));
       // Set virtualizer
       virtualizer.setStrength((short) (values.get(0).getArc(2) * 10));
     }
   }
 }