【问题标题】:Play sound with ActionScript3 on iOS cause undesired effects在 iOS 上使用 ActionScript3 播放声音会导致不良影响
【发布时间】:2014-04-27 15:11:40
【问题描述】:

我正在使用带有 ActionScript3 的 Adob​​e 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


    【解决方案1】:

    我已将应用程序构建为 ad-hoc 包并使用 TestFlight 将其安装在 iPad 上,现在一切正常。

    我猜在调试期间,Adobe AIR 未能足够快地填充声音缓冲区并导致失真。

    【讨论】:

      猜你喜欢
      • 2018-11-07
      • 2023-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-03
      • 2011-08-12
      相关资源
      最近更新 更多