模块一 体验使用fmod
到 https://www.fmod.com/download 上下载fmod android版本的
这里我们用的是别人生成的so库
libfmod.so库
libfmodL.so库
操作步骤
1.在assets中存三个音频
由之前的fmod使用,我们可以知道音频会从assets中去取  file:///android_asset/
const char *Common_MediaPath(const char *fileName)
{char *filePath = (char *)calloc(256, sizeof(char));strcat(filePath, "file:///android_asset/");strcat(filePath, fileName);gPathList.push_back(filePath);return filePath;
}
2.在main目录下新建jni文件夹
将 D:\fmodstudioapi11001android\fmodstudioapi11001android\api\lowlevel 下的inc考入

3.playsound.cpp是主要文件
我们从D:\fmodstudioapi11001android\fmodstudioapi11001android\api\lowlevel\examples下获取

4.导入其他文件
common.h
common.cpp
common_platform.h
common_platform.cpp
===================上面都是最基本的
effects.cpp   控制音效的
(其中记得把导包的路径修改 )

5.从java文件中的MainActivity替换新建项目的MainActivity以及包名
6.将lib下的东西考入并导包 fmod.jar以及不同cpu的so库
 7.Android.mk文件
LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)
LOCAL_MODULE := fmod
LOCAL_SRC_FILES := libfmod.so
include $(PREBUILT_SHARED_LIBRARY)include $(CLEAR_VARS)
LOCAL_MODULE := fmodL
LOCAL_SRC_FILES := libfmodL.so
include $(PREBUILT_SHARED_LIBRARY)include $(CLEAR_VARS)LOCAL_MODULE    := qq_voicer
LOCAL_SRC_FILES := play_sound.cpp common.cpp common_platform.cpp
LOCAL_SHARED_LIBRARIES := fmod fmodL
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
上面两个是我们依赖的so库
最后面一个 LOCAL_SRC_FILES 是我们需要依赖的cpp文件
LOCAL_LDIBS是允许日志输出
8.Application.mk
APP_STL := gnustl_static
APP_ABI := all
运行效果
模块二 仿QQ变声
就是在原有基础上多加些东西channel给原生音频加上特效
 1)新建EffectUtils.java
package org.fmod.example;/*** Created by Boom on 2017/11/27.*/public class EffectUtils {//音效类型public static final int MODE_NORMAL = 0;public static final int MODE_LUOLI = 1;public static final int MODE_DASHU = 2;public static final int MODE_JINGSONG = 3;public static final int MODE_GAOGUAI = 4;public static final int MODE_KONGLING = 5;/*** 音效处理* @param path* @param type*/public native static void fix(String path,int type);static {System.loadLibrary("qq_voicer");}
}

2)javah生成头文件
org_fmod_example_EffectUtils.h
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_fmod_example_EffectUtils */#ifndef _Included_org_fmod_example_EffectUtils
#define _Included_org_fmod_example_EffectUtils
#ifdef __cplusplus
extern "C" {
#endif
#undef org_fmod_example_EffectUtils_MODE_NORMAL
#define org_fmod_example_EffectUtils_MODE_NORMAL 0L
#undef org_fmod_example_EffectUtils_MODE_LUOLI
#define org_fmod_example_EffectUtils_MODE_LUOLI 1L
#undef org_fmod_example_EffectUtils_MODE_DASHU
#define org_fmod_example_EffectUtils_MODE_DASHU 2L
#undef org_fmod_example_EffectUtils_MODE_JINGSONG
#define org_fmod_example_EffectUtils_MODE_JINGSONG 3L
#undef org_fmod_example_EffectUtils_MODE_GAOGUAI
#define org_fmod_example_EffectUtils_MODE_GAOGUAI 4L
#undef org_fmod_example_EffectUtils_MODE_KONGLING
#define org_fmod_example_EffectUtils_MODE_KONGLING 5L
/** Class:     org_fmod_example_EffectUtils* Method:    fix* Signature: (Ljava/lang/String;I)V*/
JNIEXPORT void JNICALL Java_org_fmod_example_EffectUtils_fix(JNIEnv *, jclass, jstring, jint);#ifdef __cplusplus
}
#endif
#endif

3)模仿effects.cpp文件自定义 effectfix.cpp文件

#include "inc/fmod.hpp"#include <stdlib.h>
#include <unistd.h>
#include "org_fmod_example_EffectUtils.h"#include <android/log.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 5using namespace FMOD;JNIEXPORT void JNICALL Java_org_fmod_example_EffectUtils_fix(JNIEnv *env, jclass jcls, jstring path_jstr, jint type){System *system;Sound *sound;Channel *channel;DSP *dsp;bool playing = true;float frequency = 0;const char* path_cstr = env->GetStringUTFChars(path_jstr,NULL);LOGI("%s",path_cstr);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);LOGI("%s","fix normal");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);//添加到channelchannel->addDSP(0,dsp);LOGI("%s","fix luoli");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);//添加到channelchannel->addDSP(0,dsp);LOGI("%s","fix dashu");break;case MODE_GAOGUAI://搞怪//提高说话的速度system->playSound(sound, 0, false, &channel);channel->getFrequency(&frequency);frequency = frequency * 1.6;channel->setFrequency(frequency);LOGI("%s","fix gaoguai");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);LOGI("%s","fix kongling");break;default:break;}} catch (...) {LOGE("%s","发生异常");goto end;}system->update();//释放资源//单位是微秒//每秒钟判断下是否在播放while(playing){channel->isPlaying(&playing);usleep(1000 * 1000);}goto end;
end:env->ReleaseStringUTFChars(path_jstr,path_cstr);sound->release();system->close();system->release();}
基本步骤
//初始化
System_Create(&system);
system->init(32, FMOD_INIT_NORMAL, NULL);
//创建声音
system->createSound(path_cstr, FMOD_DEFAULT, NULL, &sound);
//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);
system->update();
//释放资源
//单位是微秒
//每秒钟判断下是否在播放
while(playing){channel->isPlaying(&playing);usleep(1000 * 1000);
}

system->close();
system->release();

4)Android.mk修改为
LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)
LOCAL_MODULE := fmod
LOCAL_SRC_FILES := libfmod.so
include $(PREBUILT_SHARED_LIBRARY)include $(CLEAR_VARS)
LOCAL_MODULE := fmodL
LOCAL_SRC_FILES := libfmodL.so
include $(PREBUILT_SHARED_LIBRARY)include $(CLEAR_VARS)LOCAL_MODULE    := qq_voicer
LOCAL_SRC_FILES := effectfix.cpp
LOCAL_SHARED_LIBRARIES := fmod fmodL
LOCAL_LDLIBS := -llog
LOCAL_CPP_FEATURES := exceptions
include $(BUILD_SHARED_LIBRARY)
5)MainActivity就是更改布局
package org.fmod.example;import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;public class MainActivity extends Activity implements OnTouchListener, Runnable
{private TextView mTxtScreen;private Thread mThread;@Overrideprotected void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);// Create the text areamTxtScreen = new TextView(this);mTxtScreen.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10.0f);mTxtScreen.setTypeface(Typeface.MONOSPACE);// Create the buttonsButton[] buttons = new Button[9];for (int i = 0; i < buttons.length; i++){buttons[i] = new Button(this);buttons[i].setText(getButtonLabel(i));buttons[i].setOnTouchListener(this);buttons[i].setId(i);}// Create the button row layoutsLinearLayout llTopRowButtons = new LinearLayout(this);llTopRowButtons.setOrientation(LinearLayout.HORIZONTAL);LinearLayout llMiddleRowButtons = new LinearLayout(this);llMiddleRowButtons.setOrientation(LinearLayout.HORIZONTAL);LinearLayout llBottomRowButtons = new LinearLayout(this);llBottomRowButtons.setOrientation(LinearLayout.HORIZONTAL);// Create the main view layoutLinearLayout llView = new LinearLayout(this);llView.setOrientation(LinearLayout.VERTICAL);       // Create layout parametersLayoutParams lpLayout = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f);// Set up the view hierarchyllTopRowButtons.addView(buttons[0], lpLayout);llTopRowButtons.addView(buttons[6], lpLayout);llTopRowButtons.addView(buttons[1], lpLayout);llMiddleRowButtons.addView(buttons[4], lpLayout);llMiddleRowButtons.addView(buttons[8], lpLayout);llMiddleRowButtons.addView(buttons[5], lpLayout);llBottomRowButtons.addView(buttons[2], lpLayout);llBottomRowButtons.addView(buttons[7], lpLayout);llBottomRowButtons.addView(buttons[3], lpLayout);llView.addView(mTxtScreen, lpLayout);llView.addView(llTopRowButtons);llView.addView(llMiddleRowButtons);llView.addView(llBottomRowButtons);setContentView(llView);// Request necessary permissions/* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){String[] perms = { "android.permission.RECORD_AUDIO", "android.permission.WRITE_EXTERNAL_STORAGE" };if (checkSelfPermission(perms[0]) == PackageManager.PERMISSION_DENIED ||checkSelfPermission(perms[1]) == PackageManager.PERMISSION_DENIED){requestPermissions(perms, 200);}}*/org.fmod.FMOD.init(this);mThread = new Thread(this, "Example Main");mThread.start();setStateCreate();}@Overrideprotected void onStart(){super.onStart();setStateStart();}@Overrideprotected void onStop(){setStateStop();super.onStop();}@Overrideprotected void onDestroy(){setStateDestroy();try{mThread.join();}catch (InterruptedException e) { }org.fmod.FMOD.close();super.onDestroy();}@Overridepublic boolean onTouch(View view, MotionEvent motionEvent){if (motionEvent.getAction() == MotionEvent.ACTION_DOWN){buttonDown(view.getId()); }else if (motionEvent.getAction() == MotionEvent.ACTION_UP){buttonUp(view.getId());   }           return true;}@Overridepublic void run(){main();}public void updateScreen(final String text){runOnUiThread(new Runnable(){@Overridepublic void run(){mTxtScreen.setText(text);}});}private native String getButtonLabel(int index);private native void buttonDown(int index);private native void buttonUp(int index);private native void setStateCreate();private native void setStateStart();private native void setStateStop();private native void setStateDestroy();private native void main();static {/** To simplify our examples we try to load all possible FMOD* libraries, the Android.mk will copy in the correct ones* for each example. For real products you would just load* 'fmod' and if you use the FMOD Studio tool you would also* load 'fmodstudio'.*///System.loadLibrary("stlport_shared");System.loadLibrary("qq_voicer");}
}
效果(这个是照着别人后面写的)

自学体验使用fmod 以及 仿QQ变声 fmod相关推荐

  1. 仿QQ变声功能的实现

    Android ndk开发之QQ变声 要做出QQ变声的效果,用Android系统自带的MediaPlayer是无法实现的,只能另想他法了.听说汤姆猫是用SoundTouch实现的,而QQ是用FMOD实 ...

  2. android fmod,Android利用Fmod仿QQ变声音效

    看到QQ一些变声音效,这些声音效果可以采用SoundTouch,Fmod去处理.这篇文章我们用Fmod去实现变声音效的处理.fmod官网https://www.fmod.com/,fmod Ex 声音 ...

  3. NDK开发(四):仿QQ变声

    效果 相关资料:fmod官网https://www.fmod.com/download下载需要的资源库 构建项目 首先构建支持C++的android工程,将需要的c库考入工程 这里只需要inc文件下的 ...

  4. NDK开发—仿QQ变声器

    1.实现功能前的准备 这是我学习NDK的一个练手项目.虽然最后实现的结果并不是非常专业,但是确实能改变声音的音色,这是非常适合NDK新手的项目. 1.1.主要原理 通过修改声音的属性来实现声音音色的变 ...

  5. Android 开发之 QQ变声功能实现

    1.简介 在QQ中我们使用到的一个功能就是变声,QQ是使用FMOD实现的,那么同样的我们也使用FMOD让自己的应用可以变音 2.FMOD简介 fmod Ex 声音系统是为游戏开发者准备的革命性音频引擎 ...

  6. 音视频开发之旅(五) -----变声 FMOD和soundTouch使用和对比

    1前言 这边先穿插一下变声相关的知识 ,这一章主要讲音频的处理.大家应该也接触过这类应用,比如QQ的变声,或者在游戏直播里,一些主播使用的变速器,那么,到底是如何做到这样的效果呢?这一篇文章将会给大家 ...

  7. Android NDK开发之旅25 NDK 模仿QQ变声特效

    ###前言 我们这次用到的是fmod这个库,fmod是音效引擎游戏开发革命引擎,著名的游戏开发引擎CosCos2D.U3D都封装了这个库. 学习NDK的目的就是为了让我们的APP能够使用C/C++开源 ...

  8. NDK开发——Android Studio+CMake实现QQ变声效果

    项目演示 Github:https://github.com/AndroidHensen/NDKVoice 项目分析 项目采用Fmod开源库,一个非常简单通用的音频引擎,对原始声音进行音效的处理即可做 ...

  9. Android开发之Fmod开发引擎库-----变声

    最近接到一个项目需求,大概是围绕***变声***这个功能展开的. 我从来没有写过这样的项目,抱着好奇的心态百度了一番,找到了一个是为游戏开发者准备的革命性音频引擎------FMOD开发引擎库. 1. ...

最新文章

  1. 树莓派光照传感器java_树莓派上使用光照强度检测(BH1750)传感器
  2. xdm,把我大学四年能用到的软件都分享给你。
  3. ExcelAndJSON的设计决策
  4. ASP.NET Web 服务、企业服务和 .NET Remoting 的性能
  5. 推荐系统学习(四)推荐系统学习资料(补充中...)
  6. python 怎么样才有output_[学]Python用户手册笔记_4_Input and Output
  7. c语言文件名错误的是,C语言程序错误,不能正常读写文件,求解啊
  8. VScode中快速生成vue模板
  9. 按键精灵使用百度文字识别(百度ocr)教程
  10. 赚钱App研究之格式转换类app
  11. mysql中常用的三种插入数据的语句
  12. mysql 1.4安装步骤_从零开始搭建系统1.4——MySql安装及配置
  13. win10打印机无法删除怎么办
  14. 市场调研公司欧睿国际揭晓2019年十大全球消费趋势
  15. ubuntu16.04 rtl8821ce无线网卡wifi频繁掉线问题解决
  16. BCD编码(8421编码)
  17. 基于Robot Studio的工业机器人汽车喷涂仿真设计
  18. 进销存管理软件2021下载量最多的排行榜前五名
  19. DL_POLY下并行计算出错问题解决
  20. Glass-theme cod mw2 for win7|Windows7主题下载

热门文章

  1. ifly error code 讯飞离线识别错误码
  2. 飞行器翼尖加速度和控制面的MPC控制
  3. 如果电脑不小心按了关机,但突然又不想关机了,应该怎样立刻取消?
  4. 618新事:消费升级和市场下沉
  5. 功能测试用例编写2(商城注册登录及购物车模块)
  6. useRequest使用日志
  7. JData算法大赛-用户购买预测
  8. linked library ‘libPods-xxx.a‘ is missing one or more architectures required by this target: armv7.
  9. 数据建模实战:方寸之间玩转购物篮分析
  10. 本公众号最新的单细胞推文目录