Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 更改音频速度,然后另存为新文件_Javascript_Audio - Fatal编程技术网

Javascript 更改音频速度,然后另存为新文件

Javascript 更改音频速度,然后另存为新文件,javascript,audio,Javascript,Audio,我是否可以用javascript编程更改音频文件的播放速度,并将其另存为新文件 我能想到的唯一解决方案是通过web audio api节点传输音频文件,改变播放速率,并将输出记录为wav文件。但这并不理想,因为我必须全程播放文件才能录制新版本。您可以使用(Web音频API)处理音频。 这将处理音频,而无需等待实时播放 //will hold the sped up audio var spedUpBuffer; //Create the context var offlineCtx = ne

我是否可以用javascript编程更改音频文件的播放速度,并将其另存为新文件

我能想到的唯一解决方案是通过web audio api节点传输音频文件,改变播放速率,并将输出记录为wav文件。但这并不理想,因为我必须全程播放文件才能录制新版本。

您可以使用(Web音频API)处理音频。 这将处理音频,而无需等待实时播放

//will hold the sped up audio
var spedUpBuffer;

//Create the context 
var offlineCtx = new OfflineAudioContext(2,44100*40,44100);//(channels,length,Sample rate);

//create source node and load buffer
var source = offlineCtx.createBufferSource();
source.buffer = yourBuffer;

//speed the playback up
source.playbackRate.value = 1.25;

//lines the audio for rendering
source.start(0);

//renders everything you lined up
offlineCtx.startRendering();
offlineCtx.oncomplete = function(e) {
//copies the rendered buffer into your variable.
spedUpBuffer = e.renderedBuffer;
}