-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmp3.js
More file actions
22 lines (21 loc) · 730 Bytes
/
mp3.js
File metadata and controls
22 lines (21 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
async function buildMp3(audioBuffer, bitrate, vbr) {
message.innerText = "Browser Storage Writing";
writeFile("audioBufferL", audioBuffer.getChannelData(0));
if(audioBuffer.numberOfChannels==2){
writeFile("audioBufferR", audioBuffer.getChannelData(1));
}
message.innerText = "Start Encode";
const ret = await Instance.encode(
audioBuffer.sampleRate,
audioBuffer.numberOfChannels,
bitrate, vbr, audioBuffer.length);
console.log("Result: ", ret);
message.innerText = "Complete";
if (ret > 0){
return Module.FS.readFile("output.mp3");
}
return;
}
function writeFile(name,x){
Module.FS.writeFile(name, new Uint8Array(x.buffer));
}