#include <jni.h>
#include
#include “fmodlinux.h”
#include “fmod.hpp”
#include <stdlib.h>
#include “common.h”
#include “fmod_errors.h”
#include “fmod_codec.h”
#define LOGI(FORMAT,…) __android_log_print(ANDROID_LOG_INFO,“jason”,FORMAT,##VA_ARGS);
#define LOGE(FORMAT,…) __android_log_print(ANDROID_LOG_ERROR,“jason”,FORMAT,##VA_ARGS);
#define MODE_NORMAL 0
#define MODE_LUOLI 1
#define MODE_DASHU 2
#define MODE_JINGSONG 3
#define MODE_GAOGUAI 4
#define MODE_KONGLING 5
using namespace FMOD;
extern “C”
JNIEXPORT jstring JNICALL
Java_com_example_administrator_myapplication_MainActivity_stringFromJNI(
JNIEnv* env, jstring path_jstr,jint type,
jobject /* this */) {
std::string hello = “Hello from C++”;
System *system;
Sound *sound;
Channel *channel;
DSP *dsp;
bool playing = true;
float frequency = 0;
const char* path_cstr = env->GetStringUTFChars(path_jstr,NULL);
try {
//初始化
System_Create(&system);
system->init(32, FMOD_INIT_NORMAL, NULL);
//创建声音
system->createSound(path_cstr, FMOD_DEFAULT, NULL, &sound);
switch (type) {
case MODE_NORMAL:
//原生播放
system->playSound(sound, 0, false, &channel);
break;
case MODE_LUOLI:
//萝莉
//DSP digital signal process
//dsp -> 音效 创建fmod中预定义好的音效
//FMOD_DSP_TYPE_PITCHSHIFT dsp,提升或者降低音调用的一种音效
system->createDSPByType(FMOD_DSP_TYPE_PITCHSHIFT,&dsp);
//设置音调的参数
dsp->setParameterFloat(FMOD_DSP_PITCHSHIFT_PITCH,2.5);
system->playSound(sound, 0, false, &channel);
//添加到channel
channel->addDSP(0,dsp);
break;
case MODE_JINGSONG:
//惊悚
system->createDSPByType(FMOD_DSP_TYPE_TREMOLO,&dsp);
dsp->setParameterFloat(FMOD_DSP_TREMOLO_SKEW, 0.5);
system->playSound(sound, 0, false, &channel);
channel->addDSP(0,dsp);
break;
case MODE_DASHU:
//大叔
system->createDSPByType(FMOD_DSP_TYPE_PITCHSHIFT,&dsp);
dsp->setParameterFloat(FMOD_DSP_PITCHSHIFT_PITCH,0.8);
system->playSound(sound, 0, false, &channel);
//添加到channel
channel->addDSP(0,dsp);
break;
case MODE_GAOGUAI:
//搞怪
//提高说话的速度
system->playSound(sound, 0, false, &channel);
channel->getFrequency(&frequency);
frequency = frequency * 1.6;
channel->setFrequency(frequency);
break;
case MODE_KONGLING:
//空灵
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;
default:
break;
}
} catch (...) {
goto end;
}
system->update();
//释放资源
//单位是微秒
//每秒钟判断下是否在播放
while(playing){
channel->isPlaying(&playing);
}
goto end;
end:
env->ReleaseStringUTFChars(path_jstr,path_cstr);
sound->release();
system->close();
system->release();
return env->NewStringUTF(hello.c_str());
}
I get this error
Error:(56) undefined reference to FMOD::ChannelControl::addDSP(int, FMOD::DSP*)' Error:(39) undefined reference to
FMOD::System::createSound(char const*, unsigned int, FMOD_CREATESOUNDEXINFO*, FMOD::Sound**)’
Error:(54) undefined reference to FMOD::System::playSound(FMOD::Sound*, FMOD::ChannelGroup*, bool, FMOD::Channel**)' Error:(52) undefined reference to
FMOD::DSP::setParameterFloat(int, float)’
Error:(43) undefined reference to FMOD::System::playSound(FMOD::Sound*, FMOD::ChannelGroup*, bool, FMOD::Channel**)' Error:(36) undefined reference to
FMOD::System::init(int, unsigned int, void*)’
Error:(62) undefined reference to FMOD::DSP::setParameterFloat(int, float)' Error:(61) undefined reference to
FMOD::System::createDSPByType(FMOD_DSP_TYPE, FMOD::DSP**)’
Error:(50) undefined reference to FMOD::System::createDSPByType(FMOD_DSP_TYPE, FMOD::DSP**)' Error:(63) undefined reference to
FMOD::System::playSound(FMOD::Sound*, FMOD::ChannelGroup*, bool, FMOD::Channel**)’
Error:(64) undefined reference to `FMOD::ChannelControl::addDSP(int, FMOD::DSP*)’
how to deal with it, i just want to play sound in android system with fmod