AudioEffect release - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for AudioEffect release method.

This code example shows how to use the following methods:release, getBandLevel, getBandLevelRange, getNumberOfBands, setBandLevel
    public void test1_0BandLevel() throws Exception { 
        boolean result = false;
        String msg = "test1_0BandLevel()";
        getEqualizer(0); 
        try { 
            short numBands = mEqualizer.getNumberOfBands();
            assertTrue(msg + ": not enough bands", numBands >= MIN_NUMBER_OF_BANDS);
 
            short[] levelRange = mEqualizer.getBandLevelRange();
            assertTrue(msg + ": min level too high", levelRange[0] <= MIN_BAND_LEVEL);
            assertTrue(msg + ": max level too low", levelRange[1] >= MAX_BAND_LEVEL);
 
            mEqualizer.setBandLevel((short)0, levelRange[1]);
            short level = mEqualizer.getBandLevel((short)0);
            // 10% margin on actual level compared to requested level 
            assertTrue(msg + ": setBandLevel failed",
                    ((float)level > (float)levelRange[1] * 0.9f) &&
                    ((float)level < (float)levelRange[1] * 1.1f));
            result = true;
        } catch (IllegalArgumentException e) {

9
CodeRank
This code example shows how to use the following methods:release, getCurrentPreset, getNumberOfPresets, getPresetName, usePreset
    public void test1_2Presets() throws Exception { 
        boolean result = false;
        String msg = "test1_2Presets()";
        getEqualizer(0); 
        try { 
            short numPresets = mEqualizer.getNumberOfPresets();
            assertTrue(msg + ": getNumberOfPresets failed", numPresets >= MIN_NUMBER_OF_PRESETS);
            mEqualizer.usePreset((short)(numPresets - 1));
            short preset = mEqualizer.getCurrentPreset();
            assertEquals(msg + ": usePreset failed", preset, (short)(numPresets - 1));
            String name = mEqualizer.getPresetName(preset);
            assertNotNull(msg + ": getPresetName failed", name);
            result = true;
        } catch (IllegalArgumentException e) {
            msg = msg.concat(": Bad parameter value");
            loge(msg, "Bad parameter value");
        } catch (UnsupportedOperationException e) {
            msg = msg.concat(": get parameter() rejected");
            loge(msg, "get parameter() rejected");
        } catch (IllegalStateException e) {

7
CodeRank
This code example shows how to use the following methods:release, getProperties, setProperties
    public void test1_1Properties() throws Exception { 
        boolean result = false;
        String msg = "test1_1Properties()";
        getBassBoost(0); 
        try { 
            BassBoost.Settings settings = mBassBoost.getProperties();
            String str = settings.toString();
            settings = new BassBoost.Settings(str);
            mBassBoost.setProperties(settings);
            result = true;
        } catch (IllegalArgumentException e) {
            msg = msg.concat(": Bad parameter value");
            loge(msg, "Bad parameter value");
        } catch (UnsupportedOperationException e) {
            msg = msg.concat(": get parameter() rejected");
            loge(msg, "get parameter() rejected");
        } catch (IllegalStateException e) {
            msg = msg.concat("get parameter() called in wrong state");
            loge(msg, "get parameter() called in wrong state");
        } finally { 

9
CodeRank
This code example shows how to use the following methods:release, getProperties, setProperties
    public void test1_1Properties() throws Exception { 
        boolean result = false;
        String msg = "test1_1Properties()";
        getVirtualizer(0); 
        try { 
            Virtualizer.Settings settings = mVirtualizer.getProperties();
            String str = settings.toString();
            settings = new Virtualizer.Settings(str);
            mVirtualizer.setProperties(settings);
            result = true;
        } catch (IllegalArgumentException e) {
            msg = msg.concat(": Bad parameter value");
            loge(msg, "Bad parameter value");
        } catch (UnsupportedOperationException e) {
            msg = msg.concat(": get parameter() rejected");
            loge(msg, "get parameter() rejected");
        } catch (IllegalStateException e) {
            msg = msg.concat("get parameter() called in wrong state");
            loge(msg, "get parameter() called in wrong state");
        } finally { 

8
CodeRank
This code example shows how to use the following methods:release, getPreset, setPreset
    public void test1_0Preset() throws Exception { 
        boolean result = false;
        String msg = "test1_0Preset()";
        getReverb(0); 
        try { 
            mReverb.setPreset((short)PresetReverb.PRESET_LARGEROOM);
            short preset = mReverb.getPreset();
            assertEquals(msg +": got incorrect preset",
                         (short)PresetReverb.PRESET_LARGEROOM,
                         preset);
            result = true;
        } catch (IllegalArgumentException e) {
            msg = msg.concat(": Bad parameter value");
            loge(msg, "Bad parameter value");
        } catch (UnsupportedOperationException e) {
            msg = msg.concat(": get parameter() rejected");
            loge(msg, "get parameter() rejected");
        } catch (IllegalStateException e) {
            msg = msg.concat("get parameter() called in wrong state");
            loge(msg, "get parameter() called in wrong state");

9
CodeRank
This code example shows how to use the following methods:release, getDensity, getDiffusion, setDensity, setDiffusion
    public void test1_4DiffusionAndDensity() throws Exception { 
        boolean result = false;
        String msg = "test1_4DiffusionAndDensity()";
        getReverb(0); 
        try { 
            mReverb.setDiffusion((short)500);
            short diffusion = mReverb.getDiffusion();
            assertTrue(msg +": got incorrect diffusion",
                    ((float)diffusion > (float)(500 / RATIO_TOLERANCE)) &&
                    ((float)diffusion < (float)(500 * RATIO_TOLERANCE)));
 
            mReverb.setDensity((short)500);
            short density = mReverb.getDensity();
            assertTrue(msg +": got incorrect density",
                    ((float)density > (float)(500 / RATIO_TOLERANCE)) &&
                    ((float)density < (float)(500 * RATIO_TOLERANCE)));
 
            result = true;
        } catch (IllegalArgumentException e) {
            msg = msg.concat(": Bad parameter value");

8
CodeRank
This code example shows how to use the following methods:release, getRoundedStrength, getStrengthSupported, setStrength
    public void test1_0Strength() throws Exception { 
        boolean result = false;
        String msg = "test1_0Strength()";
        getBassBoost(0); 
        try { 
            if (mBassBoost.getStrengthSupported()) {
                mBassBoost.setStrength((short)TEST_STRENGTH);
                short strength = mBassBoost.getRoundedStrength();
                // allow 10% difference between set strength and rounded strength 
                assertTrue(msg +": got incorrect strength",
                        ((float)strength > (float)TEST_STRENGTH * 0.9f) &&
                        ((float)strength < (float)TEST_STRENGTH * 1.1f));
            } else { 
                short strength = mBassBoost.getRoundedStrength();
                assertTrue(msg +": got incorrect strength", strength >= 0 && strength <= 1000);
            } 
            result = true;
        } catch (IllegalArgumentException e) {
            msg = msg.concat(": Bad parameter value");
            loge(msg, "Bad parameter value");

7
CodeRank
This code example shows how to use the following methods:release, getProperties, setProperties
    public void test1_1Properties() throws Exception { 
        boolean result = false;
        String msg = "test1_1Properties()";
        getVirtualizer(0); 
        try { 
            Virtualizer.Settings settings = mVirtualizer.getProperties();
            String str = settings.toString();
            settings = new Virtualizer.Settings(str);
            mVirtualizer.setProperties(settings);
            result = true;
        } catch (IllegalArgumentException e) {
            msg = msg.concat(": Bad parameter value");
            loge(msg, "Bad parameter value");
        } catch (UnsupportedOperationException e) {
            msg = msg.concat(": get parameter() rejected");
            loge(msg, "get parameter() rejected");
        } catch (IllegalStateException e) {
            msg = msg.concat("get parameter() called in wrong state");
            loge(msg, "get parameter() called in wrong state");
        } finally { 

8
CodeRank
This code example shows how to use the following methods:release, getPreset, setPreset
    public void test1_0Preset() throws Exception { 
        boolean result = false;
        String msg = "test1_0Preset()";
        getReverb(0); 
        try { 
            mReverb.setPreset((short)PresetReverb.PRESET_LARGEROOM);
            short preset = mReverb.getPreset();
            assertEquals(msg +": got incorrect preset",
                         (short)PresetReverb.PRESET_LARGEROOM,
                         preset);
            result = true;
        } catch (IllegalArgumentException e) {
            msg = msg.concat(": Bad parameter value");
            loge(msg, "Bad parameter value");
        } catch (UnsupportedOperationException e) {
            msg = msg.concat(": get parameter() rejected");
            loge(msg, "get parameter() rejected");
        } catch (IllegalStateException e) {
            msg = msg.concat("get parameter() called in wrong state");
            loge(msg, "get parameter() called in wrong state");

7
CodeRank
This code example shows how to use the following methods:release, getCurrentPreset, getNumberOfPresets, getPresetName, usePreset
    public void test1_2Presets() throws Exception { 
        boolean result = false;
        String msg = "test1_2Presets()";
        getEqualizer(0); 
        try { 
            short numPresets = mEqualizer.getNumberOfPresets();
            assertTrue(msg + ": getNumberOfPresets failed", numPresets >= MIN_NUMBER_OF_PRESETS);
            mEqualizer.usePreset((short)(numPresets - 1));
            short preset = mEqualizer.getCurrentPreset();
            assertEquals(msg + ": usePreset failed", preset, (short)(numPresets - 1));
            String name = mEqualizer.getPresetName(preset);
            assertNotNull(msg + ": getPresetName failed", name);
            result = true;
        } catch (IllegalArgumentException e) {
            msg = msg.concat(": Bad parameter value");
            loge(msg, "Bad parameter value");
        } catch (UnsupportedOperationException e) {
            msg = msg.concat(": get parameter() rejected");
            loge(msg, "get parameter() rejected");
        } catch (IllegalStateException e) {

6
CodeRank

Related AudioEffect release Questions & Answers:

release Method Overview
Releases the native AudioEffect resources.
See Code Examples for other Android AudioEffect Methods: