how get FMOD output progressbar & play & pause in android java activity

做~自己de王妃 提交于 2019-12-02 07:21:35

问题


i use FMOD library in android and i don't know how get output progressbar or fast play/pause/stop sound with effect's like: https://play.google.com/store/apps/details?id=com.baviux.voicechanger&hl=en

i try to use fomd document's and i know how can i get output but for that's problem's i don't find anything.

i'm a beginner in android & ndk.

this is my code and i can't control play pause or stop and get output progressbar in java activity:

System *system;
Sound *sound;
DSP *dsp;
Channel *channel;
float frequency;
bool isPlaying = true;
FMOD_RESULT result;


System_Create(&system);
if (save == 1) {
    unsigned int outputhandle;
    system->setOutput(FMOD_OUTPUTTYPE_WAVWRITER);
    system->init(32, FMOD_INIT_NORMAL,(void *) "/sdcard/sound.mp3");


} else{
    system->init(32, FMOD_INIT_NORMAL, NULL);
}


const char *path_cstr = env->GetStringUTFChars(path_jstr, NULL);

try {
    system->createSound(path_cstr, FMOD_DEFAULT, NULL, &sound);
    switch (type) {
        case TYPE_NORMAL: 
            LOGI("%s", path_cstr)
            system->playSound(sound, 0, false, &channel);
            LOGI("%s", "fix normal");
            break;
        case TYPE_LOLITA: 
            system->createDSPByType(FMOD_DSP_TYPE_PITCHSHIFT, &dsp);   
            dsp->setParameterFloat(FMOD_DSP_PITCHSHIFT_PITCH, 8.0);     
            system->playSound(sound, 0, false, &channel);
            channel->addDSP(0, dsp);
            break;

        case TYPE_UNCLE:  
            system->createDSPByType(FMOD_DSP_TYPE_PITCHSHIFT, &dsp);
            dsp->setParameterFloat(FMOD_DSP_PITCHSHIFT_PITCH, 0.8);
            system->playSound(sound, 0, false, &channel);
            channel->addDSP(0, dsp);
            break;

        case TYPE_THRILLER:  
            system->createDSPByType(FMOD_DSP_TYPE_TREMOLO, &dsp);    
            dsp->setParameterFloat(FMOD_DSP_TREMOLO_SKEW, 5);         
            system->playSound(sound, 0, false, &channel);
            channel->addDSP(0, dsp);


            break;
        case TYPE_FUNNY:  
            system->createDSPByType(FMOD_DSP_TYPE_NORMALIZE, &dsp);    
            system->playSound(sound, 0, false, &channel);
            channel->addDSP(0, dsp);

            channel->getFrequency(&frequency);
            frequency = frequency * 2;                                  
            channel->setFrequency(frequency);
            break;
        case TYPE_ETHEREAL: 
            system->createDSPByType(FMOD_DSP_TYPE_ECHO, &dsp);          
            dsp->setParameterFloat(FMOD_DSP_ECHO_DELAY, 300);           
            dsp->setParameterFloat(FMOD_DSP_ECHO_FEEDBACK, 20);        

            system->playSound(sound, 0, false, &channel);
            channel->addDSP(0, dsp);
            break;
        case TYPE_Sajjad: 

            system->createDSPByType(FMOD_DSP_TYPE_CHORUS, &dsp);
            dsp->setParameterFloat(FMOD_DSP_CHORUS_DEPTH, 90.0f);

            system->playSound(sound, 0, false, &channel);

            channel->addDSP(0, dsp);
            channel->getFrequency(&frequency);
           // frequency = frequency * 2;                                 
            channel->setFrequency(frequency);

            break;


    }
} catch (...) {
    LOGE("%s", "catch exception...")
    goto end;
}

system->update();

while (isPlaying) {
    channel->isPlaying(&isPlaying);
    usleep(1000 * 1000);
}

goto end;


end:
env->ReleaseStringUTFChars(path_jstr, path_cstr);
sound->release();
system->close();
system->release();

i'm a beginner please give me some code.

来源:https://stackoverflow.com/questions/58788796/how-get-fmod-output-progressbar-play-pause-in-android-java-activity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!