AudioRecord录音和AudioTrack播放

AudioRecord使用

AudioRecord record = new AudioRecord(

MediaRecorder.AudioSource.MIC, sampleRate, channelConfig, audioFormat, bufferSize);

常用

AudioSource.DEFAULT // 默认音频源

AudioSource.MIC // 主麦克风

AudioSource.CAMCORDER // 与摄像头方向一致的麦克风

AudioSource.VOICE_RECOGNITION // 语音识别

AudioSource.VOICE_COMMUNICATION // 语音通话(回声消除等)

AudioSource.UNPROCESSED // 原始未处理的音频(Android 6.0+)

// 语音通话相关(需要特殊权限)

AudioSource.VOICE_UPLINK // 上行语音(发送)

AudioSource.VOICE_DOWNLINK // 下行语音(接收)

AudioSource.VOICE_CALL // 双向语音通话

系统级 AudioSource

AudioSource.VOICE_PERFORMANCE // 高性能语音(低延迟)

AudioSource.REMOTE_SUBMIX // 录制系统音频输出(需要权限)

AudioSource.ECHO_REFERENCE // 回声参考信号

AudioSource.RADIO_TUNER // 调谐器音频输入

AudioSource.HOTWORD // 热词检测

AudioSource.ULTRASOUND // 超声波音频

AudioTrack使用

/** Used to identify the volume of audio streams for notifications /
public static final int STREAM_NOTIFICATION = AudioSystem.STREAM_NOTIFICATION;
/
* @hide Used to identify the volume of audio streams for phone calls when connected

to bluetooth /
public static final int STREAM_BLUETOOTH_SCO = AudioSystem.STREAM_BLUETOOTH_SCO;
/
@hide Used to identify the volume of audio streams for enforced system sounds

in certain countries (e.g camera in Japan) /
public static final int STREAM_SYSTEM_ENFORCED = AudioSystem.STREAM_SYSTEM_ENFORCED;
/
* Used to identify the volume of audio streams for DTMF Tones /
public static final int STREAM_DTMF = AudioSystem.STREAM_DTMF;
/
* @hide Used to identify the volume of audio streams exclusively transmitted through the

speaker (TTS) of the device /
public static final int STREAM_TTS = AudioSystem.STREAM_TTS;
/
* Used to identify the volume of audio streams for accessibility prompts /
public static final int STREAM_ACCESSIBILITY = AudioSystem.STREAM_ACCESSIBILITY;
/
* @hide Used to identify the volume of audio streams for virtual assistant */
public static final int STREAM_ASSISTANT = AudioSystem.STREAM_ASSISTANT;

相关推荐
鼓掌MVP2 分钟前
华为云码道实战:用 CodeArts Agent + 智能化搜索工具 API 调用自主开发「非遗文旅宣传卡生成器」
前端·人工智能·ai·html·ai编程·ai智能体·ai自动化
武子康12 分钟前
100个AI玩家,不等于100位真实玩家
大数据·人工智能·claude
百度Geek说1 小时前
System 1 决策模型在Feed场景的应用
人工智能
shandianchengzi1 小时前
【记录】Windows11笔记本插入光驱和CD只转盘,没有盘符,不能读取
音视频·音频·媒体·cd·光驱·光盘·dvd
AAA修煤气灶刘哥1 小时前
AI 让我一晚能开三个项目,为什么还是做不完一个?
人工智能·程序员·代码规范
oil欧哟1 小时前
重新思考 Claude Code 最佳实践:Anthropic 内部的长周期与并行 Agent 工作流
人工智能
AAA修煤气灶刘哥1 小时前
明明输入了完整报错,知识库怎么净给我相似答案?
人工智能·后端·算法
Baihai_IDP2 小时前
便宜又好用的模型,为什么越来越集中在闭源阵营?
人工智能·面试·llm
沐言人生2 小时前
再见了FineReport!这个强大的开源报表BI系统,集AI智能体、透视表、多图表,多格式导出、定时分发功能于一体,可私有化部署
人工智能·架构
存储架构师-iVY2 小时前
从端侧192GB到云端PCIe 5.0:拆解AI时代的存储架构演进
大数据·人工智能·ai存储·lpcamm2·socamm2·pcie 5.0·统一内存架构