【发布时间】:2014-04-27 15:11:40
【问题描述】:
我正在使用带有 ActionScript3 的 Adobe AIR 来播放从 iOS 设备上的麦克风录制的声音。 我使用 FileStream.writeFloat 方法将麦克风样本(单声道)存储在一个文件中。 后来我创建了一个 Sound 对象并注册到 SampleEvent,在 SampleEvent 中我读取了之前存储的带有麦克风样本的文件并将它们写入两次(因为输出是立体声)。
问题是,当我在 AIR 模拟器中运行它时,它运行良好,并且重放声音很好,而当我在 iOS 设备 (iPad) 上播放它时,声音运行速度是原来的两倍。
private function onSampleData(event : SampleDataEvent):void
{
// the following lines of code are modifying the sound object and creates a "pitch" effect
var sample:Number;
var outputLength:int = 0;
while (outputLength < 2048) {
// until we have filled up enough output buffer
if (_micSamplesStream.bytesAvailable < 4)
{
break;
}
// read out the left and right channels at this position
sample = _micSamplesStream.readFloat();
// write the samples to our output buffer
event.data.writeFloat(sample);
event.data.writeFloat(sample);
outputLength++;
}
}
【问题讨论】:
标签: ios apache-flex audio mobile air