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);
      }
    }
  }
Exemple #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();
   }
 }
Exemple #3
-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));
     }
   }
 }