当前位置:网站首页>AutoJs学习-变声器模板
AutoJs学习-变声器模板
2022-07-16 07:57:00 【芝麻粒儿】
关于作者
众所周知,人生是一个漫长的流程,不断克服困难,不断反思前进的过程。在这个过程中会产生很多对于人生的质疑和思考,于是我决定将自己的思考,经验和故事全部分享出来,以此寻找共鸣 !!!
专注于Android/Unity和各种游戏开发技巧,以及各种资源分享(网站、工具、素材、源码、游戏等)
有什么需要欢迎私我,交流群让学习不再孤单。

本文约2.8千字,新手阅读需要10分钟,复习需要3分钟 【收藏随时查阅不再迷路】
实践过程
//作用是个变声器。//理论上可以制作汤姆猫的变声功能。但是算法我不会就没写。
//设定音频数据的采样率方式和字节位数。获得出缓冲区尺寸。
//通过缓冲区尺寸新建播放器和录音器。
//开启播放器和录音器。
//循环从录音器中拿取录音数据。放入播放器中播放。
//也可以对录音数据进行处理,然后再播放。达到变声的效果。(这部分没做)
importClass(android.media.MediaRecorder);
importClass(android.media.AudioRecord);
importClass(android.media.AudioManager);
importClass(android.media.AudioTrack);
importClass(android.media.AudioFormat);
var sampleRateInHz = 44100;
var channelConfig = AudioFormat.CHANNEL_OUT_STEREO;
var audioFormat = AudioFormat.ENCODING_PCM_8BIT;
var bufferSizeInBytes = AudioTrack.getMinBufferSize(sampleRateInHz, channelConfig, audioFormat);
var audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRateInHz, channelConfig, audioFormat, bufferSizeInBytes, AudioTrack.MODE_STREAM);
audioTrack.play();
var bufferSizeInBytes_ = AudioRecord.getMinBufferSize(sampleRateInHz, channelConfig, audioFormat);
var audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC, sampleRateInHz, channelConfig, audioFormat, bufferSizeInBytes_);
try {
audioRecord.startRecording();
} catch (e) {
toastLog("无录音权限\n已停止");
exit();
};
events.on("exit", function() {
log("结束运行");
audioTrack.stop();
audioTrack.release();
audioRecord.stop();
audioRecord.release(); //释放资源
});
var audioData = new Mbyte(bufferSizeInBytes_);
while (true) {
var readSize = audioRecord.read(audioData, 0, audioData.length);
if (AudioRecord.ERROR_INVALID_OPERATION != readSize) {
//在这里处理录音数据。audioData byte PCM音频数据。
audioTrack.write(audioData, 0, audioData.length); //play raw audio bytes
};
};
function Mbyte(length) {
return util.java.array("byte", length);
};
其他
作者:小空和小芝中的小空
转载说明-务必注明来源:https://zhima.blog.csdn.net/
这位道友请留步️,我观你气度不凡,谈吐间隐隐有王者霸气,日后定有一番大作为!!!旁边有点赞收藏今日传你,点了吧,未来你成功️,我分文不取,若不成功️,也好回来找我。
温馨提示:点击下方卡片获取更多意想不到的资源。
边栏推荐
- 基于poll实现聊天室
- Minuterie haute performance
- MySQL field type selection
- Special testing of mobile applications [reprint ~ Test Engineer full stack technology advancement and practice]
- JS Object. keys()
- Codeforces Round #583 (Div. 1 + Div. 2) - A, D, E
- Analysis on the necessity and key functions of the construction of video monitoring platform for comprehensive building
- async函数实现多个请求处理
- 面试常问的shell基础,你会了吗?
- 通過制定願景克服數字化轉型挑戰
猜你喜欢

数据的存储【C语言】

Soft exam (intermediate software designer) exam information
![[batch dos-cmd command - summary and summary] - symbolic link, hard link, soft link, directory link (mklink)](/img/6a/3ad123f7015b63e5a8e0e45dd523bd.png)
[batch dos-cmd command - summary and summary] - symbolic link, hard link, soft link, directory link (mklink)

Notes - how to do in-depth learning in poor data

Small target detection 2_ OHEM

Detailed explanation of the decision table method of common test case design methods

C语言——常用字符串函数的实现

Error establishing connection between MySQL and idea

How to add PTZ control to the easycvr video retrieval page?

【批处理DOS-CMD命令-汇总和小结】-符号链接、硬链接、软链接、目录联结(mklink)
随机推荐
AcWing 135. 最大子序和
A Zuo's aspiration
Small target detection 2_ OHEM
Calculate the Euclidean distance between the row vectors of two matrices
Chapter 3: runtime data area - independent space
全链路压测 :测试要做的准备工作
leetcode:378. 有序矩阵中第 K 小的元素
cv2.setMouseCallback()显示鼠标点击图片的像素值和位置
Win10 timed running program
通過制定願景克服數字化轉型挑戰
How to understand the difference between aav2/2, aav2/5, aav2/8 and aav2/9
AcWing 133. 蚯蚓
物联网无线传输技术参数对比表
面试常问的shell基础,你会了吗?
Analysis on the necessity and key functions of the construction of video monitoring platform for comprehensive building
Differences between get requests and post requests and usage examples
Iowait understanding
Async function implements multiple request processing
Detailed explanation of Flink resource management
Page break before \ page break inside \ page break after usage