如何使用SuperpoweredNBandEQ均衡设备的音频流?

时间:2019-01-22 10:24:28

标签: android c++ superpowered

通过使用SuperpoweredNBandEQ()类,尝试使31段均衡器适用于设备的所有多媒体内容,我只能使其与麦克风一起工作,而不能与媒体一起工作。

我的测试代码:


    static SuperpoweredAndroidAudioIO *audioIO;
    static SuperpoweredNBandEQ *eq;
    static float *floatBuffer;



    // This is called periodically by the audio engine.
    static bool audioProcessing (
            void * __unused clientdata, // custom pointer
            short int *audio,          // buffer of interleaved samples
            int numberOfFrames,        // number of frames to process
            int __unused samplerate    // sampling rate
    ) {
        SuperpoweredShortIntToFloat(audio, floatBuffer, (unsigned int)numberOfFrames);
        SuperpoweredFloatToShortInt(floatBuffer, audio,(unsigned int)numberOfFrames);

        eq->process(floatBuffer, floatBuffer, (unsigned int)numberOfFrames);

        return true;
    }

    extern "C" JNIEXPORT void
    Java_com_oxidocs_equalizer_Home_StartAudio(
            JNIEnv * __unused env,
            jobject  __unused obj,
            jint    samplerate,
            jint buffersize
    ){

        float bands []= {20,25,31,40,50,63,80,100,125,160,200,250,315,400,500,630,800,1000,12500,1600,2000,2500,3150,4000,5000,6300,8000,10000,12500,16000,20000};

        // allocate audio buffer
        floatBuffer = (float *)malloc(sizeof(float) * 2 * buffersize);

        // initialize Eq
        eq = new SuperpoweredNBandEQ((unsigned int) samplerate, bands);

        // init audio with audio callback function
        audioIO = new SuperpoweredAndroidAudioIO (
                samplerate,                     // sampling rate
                buffersize,                     // buffer size
                false,                           // enableInput
                true,                           // enableOutput
                audioProcessing,                // process callback function
                NULL,                           // clientData
                -1,                             // inputStreamType (-1 = default)
                SL_ANDROID_STREAM_MEDIA,        // outputStreamType (-1 = default)
                buffersize * 2                  // latencySamples
        );

    }

    extern "C" JNIEXPORT void
    Java_com_oxidocs_equalizer_Home_StartEqualizer (
            JNIEnv * __unused env,
            jobject  __unused obj
    ){
        eq->setBand((unsigned int)23, (float)36.0 );
        eq->enable(true);
    }

我尝试处理媒体流,但只能用麦克风

0 个答案:

没有答案