daily pastebin goal
6%
SHARE
TWEET

Untitled

a guest Dec 16th, 2017 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private void equalizeSound() {
  2. //   set up the spinner
  3.         ArrayList<String> equalizerPresetNames = new ArrayList<String>();
  4.         ArrayAdapter<String> equalizerPresetSpinnerAdapter
  5.                 = new ArrayAdapter<String>(this,
  6.                 android.R.layout.simple_spinner_item,
  7.                 equalizerPresetNames);
  8.         equalizerPresetSpinnerAdapter
  9.                 .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  10.         Spinner equalizerPresetSpinner = (Spinner) findViewById(R.id.spinner);
  11.  
  12.         equalizerPresetNames.add("Custom");
  13.  
  14. //        get list of the device's equalizer presets
  15.         for (short i = 0; i < mEqualizer.getNumberOfPresets(); i++) {
  16.             equalizerPresetNames.add(mEqualizer.getPresetName(i));
  17.         }
  18.  
  19.         equalizerPresetSpinner.setAdapter(equalizerPresetSpinnerAdapter);
  20.  
  21. //        handle the spinner item selections
  22.         equalizerPresetSpinner.setOnItemSelectedListener(new AdapterView
  23.                 .OnItemSelectedListener() {
  24.  
  25.             @Override
  26.             public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
  27.                 //first list item selected by default and sets the preset accordingly
  28.                 mEqualizer.usePreset((short) position);
  29. //                get the number of frequency bands for this equalizer engine
  30.                 short numberFrequencyBands = mEqualizer.getNumberOfBands();
  31. //                get the lower gain setting for this equalizer band
  32.                 final short lowerEqualizerBandLevel = mEqualizer.getBandLevelRange()[0];
  33.  
  34. //                set seekBar indicators according to selected preset
  35.                 for (short i = 0; i < numberFrequencyBands; i++) {
  36.                     short equalizerBandIndex = i;
  37.                     SeekBar seekBar = (SeekBar) findViewById(equalizerBandIndex);
  38. //                    get current gain setting for this equalizer band
  39. //                    set the progress indicator of this seekBar to indicate the current gain value
  40.                     seekBar.setProgress(mEqualizer.getBandLevel(equalizerBandIndex) - lowerEqualizerBandLevel);
  41.                 }
  42.             }
  43.  
  44.             @Override
  45.             public void onNothingSelected(AdapterView<?> parent) {
  46. //                not used
  47.             }
  48.         });
  49.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top