From 09281c3aac813f3da7fb3a5fe6d4b2b7749aeb2e Mon Sep 17 00:00:00 2001 From: hyperturtle Date: Wed, 12 Aug 2020 23:03:18 -0700 Subject: [PATCH] Update index.js From https://sites.google.com/site/musicgapi/technical-documents/wav-file-format. > One tricky thing about RIFF file chunks is that they must be word aligned. This means that their total size must be a multiple of 2 bytes (ie. 2, 4, 6, 8, and so on). If a chunk contains an odd number of data bytes, causing it not to be word aligned, an extra padding byte with a value of zero must follow the last data byte. This extra padding byte is not counted in the chunk size, therefor a program must always word align a chunk headers size value in order to calculate the offset of the following chunk. --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index f4f7474..5d133f3 100644 --- a/index.js +++ b/index.js @@ -229,6 +229,7 @@ function decode(buffer) { break; } pos = next; + if (pos%2) pos +=1; } }