- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我在使用 Android API AudioTrack 对象播放生成的正弦音频信号时遇到问题。当正弦信号的振幅高于 40 左右(由于 16 位 PCM 格式,最大可能振幅值为 36535)时一切正常,但是当我将振幅设置为低于 40 时,除非我更改音量级别,否则不会播放任何声音侧面上下按钮(如果我改变它并不重要上或下)。
即使这样,声音也只出现一秒钟然后又消失,应该持续 10 秒钟。我在 SGS 2 上遇到了这个问题。我怀疑这个问题是由于操作系统核心的某些限制造成的,也许它认为这种低信号就像噪音一样。
如果有人知道可能是什么问题并给我一些解决方法,我将不胜感激。
最佳答案
我也有类似的问题。在我的应用程序中,我必须在开始时静音播放(正弦波振幅为 0),然后在 2 秒后我播放振幅 = 10000 的正弦波。
但是有时,即使我开始播放 AudioTrack(静态模式,流是 MUSIC),我也听不到任何声音,只有在我手动更改音量后我才开始听到我的声音。在播放任何声音(甚至无声)之前,我以编程方式将流音量设置为最大,并通过信号幅度控制输出音量。
你知道这是什么原因吗?
更新:
深入研究问题后我发现了一件奇怪的事情,当设备处于这种奇怪的状态时,我对 AudioManager.setStreamVolume 的调用不起作用。我检查了这个:
int max = mAudioManager.getStreamMaxVolume(SoundConfig.outputStreamType); // max = 15
int v = mAudioManager.getStreamVolume(SoundConfig.outputStreamType); // v = 0
mAudioManager.setStreamVolume(SoundConfig.outputStreamType, max, 0);
v = mAudioManager.getStreamVolume(SoundConfig.outputStreamType); // v = 0
之后我开始分析logcat的输出,我发现的是:- 在奇怪的状态下设置音量并开始播放看起来像:
12-19 12:45:37.120: D/AudioService(192): getStreamVolume(12)
12-19 12:45:40.970: D/AudioSystem(192): getParameters() ERROR : can't get parameters
12-19 12:45:40.970: D/AudioService(192): getStreamVolume(12)
12-19 12:45:45.680: D/AudioService(192): getStreamVolume(12)
12-19 12:45:50.120: I/AudioPolicyManager(110): startOutput() output 1, stream 3, session 6
12-19 12:45:50.120: I/AudioPolicyManager(110): getDeviceForStrategy() strategy 0, device 4
12-19 12:45:50.120: I/AudioPolicyManager(110): getDeviceForStrategy() strategy 0, device 4
12-19 12:45:50.120: I/AudioFlinger(110): start output streamType (0, 3) for 1
12-19 12:45:50.120: D/AudioHardware(110): AudioStreamOutALSA::setParameters() start_output_streamtype=3
12-19 15:25:02.521: D/AudioHardware(110): AudioHardware pcm playback is exiting standby.
但在正常状态下(在我上下按下音量按钮之后)它看起来像:
12-19 15:25:02.481: D/AudioSystem(193): getParameters() ERROR : can't get parameters
12-19 15:25:02.481: D/AudioService(193): getStreamVolume(12)
12-19 15:25:02.481: I/AudioService(193): AudioFocus abandonAudioFocus() from android.media.AudioManager#413cbf68com.kinsa.manager.CAndroidManager#414087a0
12-19 15:25:02.491: I/AudioService(193): AudioFocus requestAudioFocus() from android.media.AudioManager#413cbf68com.kinsa.manager.CAndroidManager#414087a0
12-19 15:25:02.491: D/AudioSystem(193): getParameters() ERROR : can't get parameters
12-19 15:25:02.491: D/AudioHardware(110): AudioStreamOutALSA::setParameters() music_volume_index=1
12-19 15:25:02.491: D/AudioService(193): getStreamVolume(12)
12-19 15:25:02.491: D/AudioService(193): getStreamVolume(12)
12-19 15:25:02.491: D/AudioService(193): getStreamVolume(12)
12-19 15:25:02.491: D/AudioSystem(193): getParameters() ERROR : can't get parameters
12-19 15:25:02.501: D/AudioService(193): getStreamVolume(12)
12-19 15:25:02.501: D/AudioService(193): getStreamVolume(12)
12-19 15:25:02.501: D/AudioService(193): getStreamVolume(12)
12-19 15:25:02.501: D/AudioHardware(110): AudioStreamOutALSA::setParameters() music_volume_index=15
12-19 15:25:02.521: I/AudioPolicyManager(110): startOutput() output 1, stream 3, session 3
12-19 15:25:02.521: I/AudioPolicyManager(110): getDeviceForStrategy() strategy 0, device 4
12-19 15:25:02.521: I/AudioPolicyManager(110): getDeviceForStrategy() strategy 0, device 4
12-19 15:25:02.521: I/AudioFlinger(110): start output streamType (0, 3) for 1
12-19 15:25:02.521: D/AudioHardware(110): AudioStreamOutALSA::setParameters() start_output_streamtype=3
12-19 15:25:02.521: D/AudioHardware(110): AudioHardware pcm playback is exiting standby.
在第二种情况下,我看到硬件如何将音量设置为最大,然后退出待机状态,但在第一种情况下并没有发生。但为什么?相同的代码,唯一的区别是在第二种情况下按下音量按钮后执行它。
关于Android AudioTrack 对象不会播放安静的正弦信号(低于大约 15 分贝),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8416889/
我需要围绕半径大约为 X 米的点 (lon,lat) 创建一个圆。 该点是通过等效于 geomFromEwkt('SRID=1;POINT(lon lat)') 生成的。 我知道 postgis 的缓
代码实现了读取文件(包含大量url)的功能,每个url都通过“evhttp_uri_parse”获取主机和路径。但是有一个错误,evhttp_uri_parse解析失败,返回NULL。可能原因是堆栈溢
所以我有两个进程,一个客户端进程,一个服务器进程。用户可以向客户端发出命令,当用户输入命令时客户端会将命令长度发送给服务器,之后再发送实际的命令。 服务器首先发回响应的长度,然后发送回响应。 我可以执
我从enwiki-latest-pagelinks.sql.gz下载了dumps.wikimedia.org/enwiki/latest/转储。 我开始将表导入到mysql数据库中: mysql -D
我有一个带有 Jw 音频播放器的 php 页面,并且有大约 5500 个链接,在每个链接的 onclick 事件上都附加了一个 javascript 函数。 php 正在生成文件的确切相对路径和名称,
我有一个大约 2GB 的巨大文本文件,我试图用 C# 解析它。该文件具有行和列的自定义分隔符。我想解析文件并提取数据并通过插入列标题并将 RowDelimiter 替换为换行符并将 ColumnDel
我已经建立了几个网站,出于某种原因,当我“喜欢”一篇博客文章或喜欢这个网站时,它们都不会再贴到我的墙上了。 (使用 iframe)示例: http://madhatterulti.com/ http:
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 8 年前。 Improve this qu
我有一个与 LongPoll 一起工作的服务,当我收到我的数据时一切正常,但是当我没有收到数据时,我收到的是空结果(长轮询最大时间 == 25 秒)我的服务有时会关闭手动(我没有在服务列表中看到它)。
对于用于 Android 和应用内购买的最佳支付 API 是否达成共识? 在谷歌上搜索“Android 支付 api”,有大量来自 paypal、sms 和信用卡公司等的点击。但其中大部分文章已有多年
我的查询执行时间很长,大约 120 秒。 任何人都可以帮我重写这个查询。 请参阅下面的解释计划和表格结构。 我们经常在慢日志中收到此查询。 查询: select count(*) as col_
我正在尝试找到一种方法来对墓 map 像进行近似分割(在文化科学中的 CBIR 背景下 - 但这不是主题)。到目前为止,我正在使用这个策略: 模糊图像两次(实验结果) 应用 Canny 边缘检测器 寻
当您在 Google 中搜索时(我几乎可以肯定 Altavista 做了同样的事情),它会显示“关于 xxxx 的结果 1-10”... 这一直让我感到惊讶......“关于”是什么意思? 他们怎么能
今天我们的一台 Linux 服务器在打开出站请求时遇到问题。我已经查看了这个答案,Increasing the maximum number of tcp/ip connections in linu
我在 MVC4 站点中使用 NuGet 的最新 SignalR。使用sample hub code (或任何代码),我遇到一些奇怪的连接问题。一切加载正常,SignalR 进行协商调用并记录“Even
有人可以帮帮我吗?我的 GUI 有问题。这会过快地接收过多数据,以至于事件处理程序会完全阻塞 GUI 以供用户输入。 后台程序用于向 GUI 发送解决方案(作为文本),但 GUI 处理数据的速度不够快
假设我有一段代码,例如 for (j = 0; j 180) { c.fillStyle = 'red' } c.fi
我正在创建 2 名玩家的游戏,每个玩家都有自己的区域。我希望每个玩家都可以用一根手指触摸自己的区域。所以首先我将“达阵”功能限制为“2 个指针”。 public boolean touchDown(i
进程运行卡在 32000 (± 5%) 左右 ~# cat/proc/sys/kernel/threads-max127862 ~# ulimit -s堆栈大小(千字节,-s)2048 可用内存:3,
我有一个问题。我的应用程序在某些 Android 设备(Android 版本 5 到 6)的后台运行(如前台服务)。应用程序连接到服务器(TCP 连接)并且它们至少每 45 秒交换一次数据。 如果屏幕
我是一名优秀的程序员,十分优秀!