简体   繁体   English

Flash Player 10实时音频播放

[英]Flash Player 10 real-time audio playback

I'm trying to playback some sample data through the new real-time audio capabilities of Flash Player 10. I started with the example given at the bottom of this page on livedocs, which seems to work fine and plays a crystal clear tone. 我试图通过Flash Player 10中的我开始在底部给出的例子中,新的实时音频功能来播放一些示例数据页面LiveDocs上,这似乎是做工精细,并发挥着晶莹剔透的音色。

I assume that the two writeFloat 's in the example write to the left and right audio channels respectively and that the data being written is 32 bit (because of the float). 我假设示例中的两个writeFloat分别写入左右音频通道,并且正在写入的数据为32位(由于float)。

However. 然而。 I seem to be having trouble converting my old 8 bit audio data to a format that is understood by this interface. 我似乎无法将旧的8位音频数据转换为该接口可以理解的格式。 When I playback my sample data I can vaguely hear the sound I'm expecting but it is massively distorted. 当我播放样本数据时,我可以隐约听到我期望的声音,但是声音失真很大。 My sample data consists of raw 8 bit samples that ranges from 0..255 where 127 is silence. 我的样本数据由原始的8位样本组成,范围从0..255(其中127是静默)。

I've been trying different conversion formulas but I seem to be missing some vital information regarding this conversion. 我一直在尝试不同的转换公式,但似乎缺少一些有关此转换的重要信息。

Any help greatly appreciated. 任何帮助,不胜感激。

UPDATE: 更新:

The correct formula turns out to be: 正确的公式证明是:

f = (sample.data.readByte() - 127) / 255

尝试转换var newSample:Number =(Number(oldSample)-127.0)/127.0;

Make sure you are reading in your 8-bit data correctly. 确保正确读取8位数据。 If you are using the ByteArray-class then use readUnsignedByte (instead of readByte) to get a value between 0-255. 如果使用的是ByteArray类,则使用readUnsignedByte(而不是readByte)来获取0-255之间的值。 Then use the formula suggested by MontyGomery. 然后使用MontyGomery建议的公式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM