android audiorecord初始化失败相关资料收集
We're also struggling with audio recording on some Samsung Android Devices. Unfortunately it seems to be very broken, as even different revisions of the same phone model are behaving differently with the same codebase.
Here are my current findings, hoping you find something useful:
1. Broken Initialization:
Unfortunately, the strategy you are using to query for valid recording configurations will fail at least on Samsung Galaxy Young and Ace models running Android 2.3 The problem is that some invalid AudioRecord configurations instead of simply failing, will completely brick the audio capture subsystem if tried. You'll need to reset the phone to recover from this state.
2. Inconsistent Sampling-Rate support along revisions of same phone model
On an older Galaxy Ace Phone, recording @ 11025Hz, 16-bit mono will succeed. On newer Ace revisions, this AudioRecord configuration will be accepted as valid, but the resulting recording will be distorted, with a "chipmunk" effect. A very popular guitar tuner app that has hardcoded this sampling rate is failing to give proper tuning readings on these phones precisely because of this problem!
3. Extremely low volume audio capture on some configurations.
In Galaxy Young and Galaxy Ace, recording from the mic or default audio source @ 44,100Hz (the supposedly canonical rate where everything should work fine) produces an undistorted, but extremely low-volume recording. I haven't found yet a way to fix this other than software amplification (which is the equivalent of magnifying a very low res image, with the consecuent "jageddnes" of the result).
4. Failure to support the canonical 44,100Hz sampling rate on every audio capture source.
In Galaxy Young and Galaxy Ace, recording from the Camcorder source fails @ 44,100Hz. (again, the configuration will be accepted as valid) producing complete garbage. However, recording @ 8,000Hz, 16,000Hz and 48,000Hz works fine and produces a recording with very acceptable volume levels. What is frustrating is that according to the Android documentation, 44,100Hz is a sampling rate all devices SHOULD support.
5. OpenSL does not fix any of the problems reported.
Working with the NDK and OpenSL produces the same described results. It seems that the AudioRecorder class is simply wrapping calls to OpenSL, and the problem is either hardware based, or buried at a lower-level tier in the kernel code.
This situation is very unfortunately indeed, as these models are becoming very popular - at least in Mexico.
Good luck - and please report if you had better luck working with these phones. =)
一种通用的初始化audiorecord的方式:
private static int[] mSampleRates = new int[] { 8000, 11025, 22050, 44100 };
public AudioRecord findAudioRecord() {
for (int rate: mSampleRates) { for (short audioFormat: new short[] { AudioFormat.ENCODING_PCM_8BIT, AudioFormat.ENCODING_PCM_16BIT }) { for (short channelConfig: new short[] { AudioFormat.CHANNEL_IN_MONO, AudioFormat.CHANNEL_IN_STEREO }) { try { Log.i("vipul", "Attempting rate " + rate + "Hz, bits: " + audioFormat + ", channel: " + channelConfig); int bufferSize = AudioRecord.getMinBufferSize(rate, channelConfig, audioFormat); if (bufferSize != AudioRecord.ERROR_BAD_VALUE) { // check if we can instantiate and have a success AudioRecord recorder = new AudioRecord( AudioSource.DEFAULT, rate, channelConfig, audioFormat, bufferSize); if (recorder.getState() == AudioRecord.STATE_INITIALIZED) return recorder; } } catch (Exception e) { e.printStackTrace(); } } } } return null;}
android audiorecord初始化失败相关资料收集的更多相关文章
- AssetBundle机制相关资料收集
原地址:http://www.cnblogs.com/realtimepixels/p/3652075.html AssetBundle机制相关资料收集 最近网友通过网站搜索Unity3D在手机及其他 ...
- FastAdmin 导入 Excel 相关资料收集 (2018-08-14)
FastAdmin 导入 Excel 相关资料收集 新版本一键CRUD后自带导入功能,但是默认被禁用,如何启动 https://forum.fastadmin.net/thread/540 Excel ...
- FastAdmin 导出 Excel 相关资料收集 (2018-08-14)
FastAdmin 导出 Excel 相关资料收集 导出 Excel 文件时身份证号变成科学计数法怎么办? https://forum.fastadmin.net/thread/1346 姊妹篇 Fa ...
- Android Notification 消息通知 相关资料.md
目录 Android Notification 消息通知 相关资料 Android 5.0 Lollipop (API 21)无法正常显示通知图标,只能看到一个白色方块或灰色方块的问题 解决方案 参考 ...
- iOS10以及xCode8相关资料收集
兼容iOS 10 资料整理笔记 源文:http://www.jianshu.com/p/0cc7aad638d9 1.Notification(通知) 自从Notification被引入之后,苹果就不 ...
- MPEG 编解码相关资料收集
以下是我搜集的关于MPEG1/2的编解码相关的资料: (注:mpge帧内编码是基于jpeg编码的,所以请务必先理解jpeg的编解码原理.) 1:Introduction to MPEG 2 Video ...
- Android ADT初始化失败
在android的官网上买下载android的adt完了,进行解压之后,开始点击 eclipse.exe,果然给了我一个惊喜,那就是 [ Failed to create the Java Virtu ...
- kafka负载均衡相关资料收集(三)
apache kafka系列之Producer处理逻辑 下文是转载的,原文链接地址:点这儿 [转] Kafka ProducerKafka Producer处理逻辑kafka生产者处理逻辑apache ...
- kafka负载均衡相关资料收集(二)
[转]关于kafka producer 分区策略的思考 from:http://blog.csdn.net/ouyang111222/article/details/51086037 今天跑了一个简单 ...
- kafka负载均衡相关资料收集(一)
key为null时Kafka会将消息发送给哪个分区? 当你编写kafka Producer时, 会生成KeyedMessage对象. 1 KeyedMessage<K, V> keyedM ...
随机推荐
- Vue08 数据代理
1 说明 所谓"数据代理",是指 通过一个对象代理对另一个对象的属性进行读或写操作. 2 简单示例 2.1 代码 let obj = {x:100}; let obj2 = {y: ...
- .NET WebAPI 跨域问题(has been blocked by CORS policy:No Access-Control-Allow-Ogigin header is present on the requested resource)
一.什么是跨域 1. 跨域解释 跨域指的是浏览器不能执行其他网站的脚本.它是由浏览器的同源策略造成的,是浏览器施加的安全限制. 同源指的是:域名,协议,端口均相同. 2. 什么情况下会导致跨域 2.1 ...
- 5步带你入门GaussDB(DWS)的GDS导入导出
摘要:本篇文档为使用GDS导入示例的具体简单步骤和示例. 本文分享自华为云社区<带你快速入门GDS导入导出,玩转PB级数仓GaussDB(DWS)>,作者: yd_220527686. 1 ...
- echarts的颜色渐变
官网文档解释 // 线性渐变,前四个参数分别是 x0, y0, x2, y2, //范围从 0 - 1,相当于在图形包围盒中的百分比, //如果 global 为 `true`,则该四个值是绝对的像素 ...
- SX【2020.01.09】NOIP提高组模拟赛(day1)
[2020.01.09]NOIP提高组模拟赛(day1) 这次考得不理想,只做了前两题,后两题没时间做,说明做题速度偏慢. source : 100 + 20 + 0 + 0 = 120 rank7 ...
- ViT简述【Transformer】
目录 结构概述 图像切patch Patch0 Position Embedding Multi-Head Attention 代码[Pytorch] Transformer在NLP任务中表现很好,但 ...
- forEach、for in 、 for of三者的区别
1.for 原始的遍历: 其实除了这三种方法以外还有一种最原始的遍历,自Javascript诞生起就一直用的 就是for循环,它用来遍历数组 var arr = [1,2,3,4] for(var i ...
- GPS地图生成02之经典算法体验
经典的利用轨迹生成地图的算法与数据集可寻找于:Mapconstruction by pfoser Mapconstruction by pfoser数据集中,雅典数据集投影坐标系为(UTM, GGRS ...
- PostgreSQL中的row_number() 与distinct用法说明
一.示例 这两个SQL执行所得到的数据是一样的! select count(s.*) from ( select *, row_number() over (partition by fee_dat ...
- ASP.net EF动态映射实体
1.配置EF与建立实体模型这里不做过多介绍.主要介绍如何动态映射实体模型 1.1.实现过程有很多种方式我们这里使用接口.然后扫描所有继承了该接口的实体类然后映射(也可以自行扩展使用特性) 首先我们新建 ...