我知道如何在 ActionScript 3中录制音频。但是是否可以从 ActionScript 的最终声音文件中删除某些内容?
我的用例是,用户可以跳到声音文件中的某个特定点(我可以管理该点)并从那里开始录音(基本上覆盖了文件的其余部分)。
在 ActionScript 3中是否可行?
谢谢。
更新:
这是我使用过的代码,它可以正常工作,但是旧唱片却被淘汰了。我不知道为什么“selectedTime”是用户在波形图示中选择的时间的毫秒值; 44100是我的采样率。
existingByte = new ByteArray();
var extract:Number = Math.floor ((selectedTime)*44.1);
sound.extract(existingByte, extract);
mic.recordData(existingByte);
// in the mic class:
public function recordData(existingByteArray:ByteArray=null):void {
if(existingByteArray == null) {
raw = new ByteArray();
} else {
raw = existingByteArray;
raw.position = raw.length;
}
mic.addEventListener(SampleDataEvent.SAMPLE_DATA, dataHandler);
}
private function dataHandler(event:SampleDataEvent):void {
try {
raw.writeBytes(event.data);
} catch(e) {
this.stopRecording();
}
}
最佳答案
是。当您从音频流中接收字节时,会将这些字节附加到主缓冲区中。如果您想进行录音等打孔。您需要知道要冲入的主缓冲区的偏移量。因此,与其从头开始写入缓冲区,不如从用户单击的偏移量写入缓冲区。您必须将鼠标指针与主缓冲区中的偏移量相关联。然后,当您收到新的音频时,只需覆盖该缓冲区中的值即可。如果您想要打孔,那么它只会覆盖音频的一小部分。您将需要在主缓冲区中的一个端点也要停止写入新数据。用户可以突出显示音频的一部分以说出进/出点。
您必须将ByteArrays用于两个缓冲区。您可以使用Sound.extract()从Sound中提取原始字节。其他原始音频来源也可以在这里应用:
var master : ByteArray; // assume this is loaded with some audio
public function punchIn( startLocation : index, sound : Sound ) : void {
sound.extract( master, sound.bytesTotal, startLocation );
}
通过更改长度参数,您可以进行切入和切出功能。
关于flash - 在 ActionScript 中剪切声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8897154/