Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
krismakesstuff committed Apr 29, 2024
2 parents 4150a4f + 5fee31c commit 6c259cd
Showing 1 changed file with 30 additions and 27 deletions.
57 changes: 30 additions & 27 deletions rnbo-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,37 +149,40 @@ export async function createRNBODevice(patchExportURL) {
downloadLink.download = fileName;
downloadLink.click();
}
else {

const reader = new FileReader();
//let arrayBuffer;

// returns and array buffer
reader.onloadend = function() {
console.log("FileReader onloadend");
console.log(reader.result);
//arrayBuffer = reader.result;

// decode audio data
context.decodeAudioData(reader.result, function(audioBuffer) {
console.log("Decoded audio data");
const waveBlob = bufferToWave(audioBuffer, audioBuffer.length);

let url = URL.createObjectURL(waveBlob);
console.log("waveBlob url: " + url);
let downloadLink = document.getElementById("download-link");
let fileName = "shift-recording-" + (Date.now() - date);

downloadLink.href = url;
downloadLink.download = fileName;
downloadLink.click();

}, function(e){"Error with decoding audio data" + e.err});
const reader = new FileReader();

// returns and array buffer
reader.onloadend = function() {
console.log("FileReader onloadend");
console.log(reader.result);

// decode audio data
context.decodeAudioData(reader.result, function(audioBuffer) {
console.log("Decoded audio data");

// writes the wave header for file
const waveBlob = bufferToWave(audioBuffer, audioBuffer.length);

let url = URL.createObjectURL(waveBlob);
console.log("waveBlob url: " + url);
let downloadLink = document.getElementById("download-link");
let fileName = "shift-recording-" + (Date.now() - date);

// downloads the file
downloadLink.href = url;
downloadLink.download = fileName;
downloadLink.click();

}, function(e){"Error with decoding audio data" + e.err});

}

// reads blob as an ArrayBuffer
reader.readAsArrayBuffer(recordedBlob[0]);
}

// reads blob as an ArrayBuffer
//reader.readAsArrayBuffer(recordedBlob[0]);


}

Expand Down

0 comments on commit 6c259cd

Please sign in to comment.