当前位置:操作系统 > 安卓/Android >>

Android Audio代码分析20 - queryEffects函数

 

今天开始看看AudioEffect相关的接口。

这个类,之前有看过。不过当时只是从类的定义出发,了解了一下基本的内容。

这次从测试代码使用的接口出发,逐步撕开AudioEffect的面纱。

 

 

*****************************************源码*************************************************

    //Test case 0.0: test queryEffects() and available effects

    @LargeTest

    public void test0_0QueryEffects() throws Exception {

 

 

        AudioEffect.Descriptor[] desc = AudioEffect.queryEffects();

 

 

        assertTrue("test0_0QueryEffects: number of effects < 4: "+desc.length, (desc.length >= 4));

 

 

        boolean hasEQ = false;

        boolean hasBassBoost = false;

        boolean hasVirtualizer = false;

        boolean hasEnvReverb = false;

 

 

        for (int i = 0; i < desc.length; i++) {

            if (desc[i].type.equals(AudioEffect.EFFECT_TYPE_EQUALIZER)) {

                hasEQ = true;

            } if (desc[i].type.equals(AudioEffect.EFFECT_TYPE_BASS_BOOST)) {

                hasBassBoost = true;

            } else if (desc[i].type.equals(AudioEffect.EFFECT_TYPE_VIRTUALIZER)) {

                hasVirtualizer = true;

            }

            else if (desc[i].type.equals(AudioEffect.EFFECT_TYPE_ENV_REVERB)) {

                hasEnvReverb = true;

            }

        }

        assertTrue("test0_0QueryEffects: equalizer not found", hasEQ);

        assertTrue("test0_0QueryEffects: bass boost not found", hasBassBoost);

        assertTrue("test0_0QueryEffects: virtualizer not found", hasVirtualizer);

        assertTrue("test0_0QueryEffects: environmental reverb not found", hasEnvReverb);

    }

**********************************************************************************************

源码路径:

frameworks\base\media\tests\mediaframeworktest\src\com\android\mediaframeworktest\functional\MediaAudioEffectTest.java

 

 

#######################说明################################

    //Test case 0.0: test queryEffects() and available effects

    @LargeTest

    public void test0_0QueryEffects() throws Exception {

 

 

        AudioEffect.Descriptor[] desc = AudioEffect.queryEffects();

++++++++++++++++++++++++++++Descriptor++++++++++++++++++++++++++++++++++++

    /**

     * The effect descriptor contains information on a particular effect implemented in the

     * audio framework:<br>

     * <ul>

     *  <li>type: UUID corresponding to the OpenSL ES inte易做图ce implemented by this effect</li>

     *  <li>uuid: UUID for this particular implementation</li>

     *  <li>connectMode: {@link #EFFECT_INSERT} or {@link #EFFECT_AUXILIARY}</li>

     *  <li>name: human readable effect name</li>

     *  <li>implementor: human readable effect implementor name</li>

     * </ul>

     * The method {@link #queryEffects()} returns an array of Descriptors to facilitate effects

     * enumeration.

     */

    public static class Descriptor {

 

 

        public Descriptor() {

        }

 

 

        public Descriptor(String type, String uuid, String connectMode,

                String name, String implementor) {

            this.type = UUID.fromString(type);

            this.uuid = UUID.fromString(uuid);

            this.connectMode = connectMode;

            this.name = name;

            this.implementor = implementor;

        }

 

 

        /**

         *  Indicates the generic type of the effect (Equalizer, Bass boost ...). The UUID

         *  corresponds to the OpenSL ES Inte易做图ce ID for this type of effect.

         */

        public UUID type;

        /**

         *  Indicates the particular implementation of the effect in that type. Several effects

         *  can have the same type but this uuid is unique to a given implementation.

         */

// 上次看AudioEffect类的时候,对type和uuid的区别还不是很清楚

// 看了这儿的注释,就比较清楚了

        public UUID uuid;

        /**

         *  Indicates if the effect is of insert category {@link #EFFECT_INSERT} or auxiliary

         *  category {@link #EFFECT_AUXILIARY}. Insert effects (Typically an Equalizer) are applied

         *  to the entire audio source and usually not shared by several sources. Auxiliary effects

         *  (typically a reverberator) are applied to part of the signal (wet) and the effect output

         * 

补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,