我目前正在編輯具多重功效我的MP3文件,像這樣網絡音頻API - 下載MP3編輯
var mainVerse = document.getElementById('audio1');
var s = source;
source.disconnect(audioCtx.destination);
for (var i in filters1) {
s.connect(filters1[i]);
s = filters1[i];
}
s.connect(audioCtx.destination);
的MP3播放相應的與它的過濾器在網絡上。是否有可能使用這些新的效果創建和下載一個新的MP3文件,使用網絡音頻API或任何寫入MP3容器JavaScript庫?如果不是最好在網上解決這個問題?
更新 - 使用OfflineAudioContext
使用示例代碼https://developer.mozilla.org/en-US/docs/Web/API/OfflineAudioContext/oncomplete
我使用像這樣離線節點嘗試;
var audioCtx = new AudioContext();
var offlineCtx = new OfflineAudioContext(2,44100*40,44100);
osource = offlineCtx.createBufferSource();
function getData() {
request = new XMLHttpRequest();
request.open('GET', 'Song1.mp3', true);
request.responseType = 'arraybuffer';
request.onload = function() {
var audioData = request.response;
audioCtx.decodeAudioData(audioData, function(buffer) {
myBuffer = buffer;
osource.buffer = myBuffer;
osource.connect(offlineCtx.destination);
osource.start();
//source.loop = true;
offlineCtx.startRendering().then(function(renderedBuffer) {
console.log('Rendering completed successfully');
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
var song = audioCtx.createBufferSource();
song.buffer = renderedBuffer;
song.connect(audioCtx.destination);
song.start();
rec = new Recorder(song, {
workerPath: 'Recorderjs/recorderWorker.js'
});
rec.exportWAV(function(e){
rec.clear();
Recorder.forceDownload(e, "filename.wav");
});
}).catch(function(err) {
console.log('Rendering failed: ' + err);
// Note: The promise should reject when startRendering is called a second time on an OfflineAudioContext
});
});
}
request.send();
}
// Run getData to start the process off
getData();
仍然讓錄音機下載一個空文件,我使用歌曲源作爲錄音機的來源。歌曲播放和所有與他的代碼,但錄音機不下載它
您正在尋找recorder.js https://github.com/mattdiamond/Recorderjs –
@RaphaelSerota您好,我只是檢查圖書館,我不知道如何讓'forceDownload'工作一個已經存在的信號源(而不是用麥克風記錄,即'rec.record(),rec.stop()')。我目前正在執行以下操作:rec = new Recorder(s,{{{}}};}};}}; rec.exportWAV(函數(e)中{ \t Recorder.forceDownload(例如, 「FILENAME.WAV」); });'...但FILENAME.WAV文件是一個空的wav文件...任何建議? – Thatdude1