diff --git a/codec/adpcm/adpcm.js b/cmd/audio-player/adpcm.js similarity index 91% rename from codec/adpcm/adpcm.js rename to cmd/audio-player/adpcm.js index 2637fff5..c1362938 100644 --- a/codec/adpcm/adpcm.js +++ b/cmd/audio-player/adpcm.js @@ -30,6 +30,10 @@ let est, // Estimation of sample based on quantised ADPCM nibble. idx, // Index to step used for estimation. step; +function decodeSample(nibble) { + return new Uint8Array([1, 2]) +} + function decode(b) { // b should be a Uint8Array if (!(b instanceof Uint8Array)) { @@ -49,15 +53,15 @@ function decode(b) { var nib2 = twoNibs >> 4; var nib1 = (nib2 << 4) ^ twoNibs var firstBytes = decodeSample(nib1) - concat(result, firstBytes) + result = concat(result, firstBytes) var secondBytes = decodeSample(nib2) - concat(result, secondBytes) + result = concat(result, secondBytes) } if (b[3] == 1) { var padNib = b[b.length - 1] var samp = decodeSample(padNib) - concat(result, samp) + result = concat(result, samp) } return result; diff --git a/cmd/audio-player/index.html b/cmd/audio-player/index.html index d8e7aa23..d4015ab4 100644 --- a/cmd/audio-player/index.html +++ b/cmd/audio-player/index.html @@ -5,6 +5,7 @@ Audio Player + diff --git a/cmd/audio-player/main.js b/cmd/audio-player/main.js index c81deb05..84e171d9 100644 --- a/cmd/audio-player/main.js +++ b/cmd/audio-player/main.js @@ -7,14 +7,21 @@ window.onload = function () { reader.onload = event => { bytes = new Uint8Array(event.target.result) + console.log(bytes.slice(0, 16)) + + var decoded = decode(bytes) + console.log("playing file") - var player = new PCMPlayer({ - encoding: '16bitInt', - channels: 1, - sampleRate: 48000, - flushingTime: 2000 - }); - player.feed(bytes) + + console.log(decoded.slice(0, 16)) + + // var player = new PCMPlayer({ + // encoding: '16bitInt', + // channels: 1, + // sampleRate: 48000, + // flushingTime: 2000 + // }); + // player.feed(bytes) } reader.onerror = error => reject(error) reader.readAsArrayBuffer(input)