.wav file in question
i got it from here, the upright piano best quality wav sound bank
i made this script to load it into to a FileReader:
const file = document.getElementById("file");
const fr = new FileReader();
file.onchange = function(e) {
fr.readAsArrayBuffer(file.files[0]);
}
fr.onload = function() {
const bytes = new Uint8Array(fr.result);
function byteString(a, b) {
let c = "";
for(let i = b; i >= a; i -= 1) {
const byte = bytes[i].toString(2), shift = new Array(8 - byte.length + 1).join("0");
c += shift + byte;
}
return parseInt(c, 2);
}
const channels = byteString(22, 23);
const sampleRate = byteString(24, 27);
const bitsPerSample = byteString(34, 35);
const length = byteString(40, 43);
// console.log(bytes); // running this line with that file on stackoverflow crashed my browser
console.log(channels, sampleRate, bitsPerSample, length);
}
<!DOCTYPE html>
<html oncontextmenu="return false">
<head>
<meta charset="utf-8">
<title>visualizer</title>
</head>
<body>
<label for="wav">wav file: </label>
<input type="file" id="file" name="wav">
</body>
</html>
channels and sampleRate for thisit seems this file doesn't follow the specification, but audio software and stuff are still able to play it
how do i find the bits per sample and the number of bytes in the signal data?
also, how do i find the signal data? i want to make a waveform visualizer