如何使用loadPCMFromByteArray?
有人能够成功使用 Flash 11 中的新 Sound 方法 loadPCMFromByteArray 吗?每当我使用它时,我都会听到重复的滴答声。
还有一种方法可以在该方法中设置深度(位)?看来这个loadPCMFromByteArray只能理解32位PCM数据。
我已经查找了示例,但没有找到有效的示例
这是我的示例代码,请注意,我不断向 soundBA (ByteArray 对象)添加数据,并在将其传递给 loadPCMFromByteArray 方法后清除它,我也是如此我只是被迫进行检查(8192 * 4),因为看起来 loadPCMFromByeArray 方法只理解 32 位音频样本,我如何将其设置为读取 8 位和 16 位样品?:
if (soundBA.bytesAvailable >= (8192 * 4 * channels))
{
soundPlayer.loadPCMFromByteArray(soundBA, soundBA.bytesAvailable / 4, "float", false, 22050);
soundChannel = soundPlayer.play();
soundBA.clear();
}
has anyone been able to use the new Sound method loadPCMFromByteArray in Flash 11 successfully? I just end up hearing repeating ticking sound whenever I use it.
And also is there a way to set the depth (bits) in that method? it seems that this loadPCMFromByteArray only understands 32bit PCM data.
I've looked for examples but I've found no working examples
Here is my sample code, please note that I'm continously adding data to the soundBA (ByteArray object) and clearing it after passing it to the loadPCMFromByteArray method, also I'm just forced to do a check (8192 * 4) since it really seems that the loadPCMFromByeArray method only understands 32bit audio samples, how can I set it to read 8-bit and 16-bit samples?:
if (soundBA.bytesAvailable >= (8192 * 4 * channels))
{
soundPlayer.loadPCMFromByteArray(soundBA, soundBA.bytesAvailable / 4, "float", false, 22050);
soundChannel = soundPlayer.play();
soundBA.clear();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我正在寻找与你相同的东西,但我已经有了部分答案。
在尝试使用“loadPCMFromByteArray”函数之前,我使用 as3wavsound lib 它使用音频操作库称为“sazameki”。最后一个库为您提供了将 8 位或 16 位转码为数字向量的方法。您只需获取该向量并将其写入 ByteArray 中:
然后为其提供“loadPCMFromByteArray”函数。您应该会遇到错误,因为您在 ByteArray 上的位置不好。所以重置一下吧。
您的最终代码应如下所示:
我希望这可以帮助您。
I'm looking for the same thing as you but I already have a part of the answer.
Before trying to use "loadPCMFromByteArray" function, I was using as3wavsound lib which uses an audio manipulating library called "sazameki". This last library gives you ways to transcode 8 or 16 bits to a vector of Numbers. You just have to take that vector and write it into a ByteArray with:
then give it "loadPCMFromByteArray" function. You should have an error because your position on the ByteArray is not good. So reset it.
Your final code should look like that:
I hope this could help you.
我无法使用 loadPCMFromByteArray 它给了我这个错误:
通过静态类型 flash.media:Sound 的引用调用可能未定义的方法 loadPCMFromByteArray。
I cannot use loadPCMFromByteArray it gives me this error :
Call to a possibly undefined method loadPCMFromByteArray through a reference with static type flash.media:Sound.