我想使用Adobe
在ByteArray
Air中生成声音。声音应该是x秒的静音。我找到了用于生成字节的以下代码:
private function encode(data : ByteArray) : ByteArray
{
var channels : uint = 2;
var bits : uint = 16;
var rate : uint = 44100;
var bytes : ByteArray = new ByteArray();
bytes.endian = Endian.LITTLE_ENDIAN;
bytes.writeUTFBytes('RIFF');
bytes.writeInt(uint(data.length + 44));
bytes.writeUTFBytes('WAVE');
bytes.writeUTFBytes('fmt ');
bytes.writeInt(uint(16));
bytes.writeShort(uint(1));
bytes.writeShort(channels);
bytes.writeInt(rate);
bytes.writeInt(uint(rate * channels * (bits / 8)));
bytes.writeShort(uint(channels * (bits / 8)));
bytes.writeShort(bits);
bytes.writeUTFBytes('data');
bytes.writeInt(data.length);
bytes.writeBytes(data);
bytes.position = 0;
return bytes;
}
但是,当我使用Filereference保存文件并将其导入Flash文件时,我收到一条错误消息,提示读取文件时出现问题。
最佳答案
查看此开放源代码库。
http://code.google.com/p/micrecorder/downloads/list
它从麦克风捕获声音并将其另存为wav文件。
关于actionscript-3 - 使用byteArray和Adobe Air生成x秒的静音音频文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8518551/