From b904b0795c0cd4721e9eaab10e4c6127568a00a7 Mon Sep 17 00:00:00 2001 From: Andrew Kuklewicz Date: Fri, 29 Apr 2022 00:57:34 -0400 Subject: [PATCH] Correctly calc mext sound info for 44.1 and no padding --- lib/wavefile-creator.js | 2 +- test/dist/cart/cart-rw.js | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/wavefile-creator.js b/lib/wavefile-creator.js index 770506d..d44f3b1 100644 --- a/lib/wavefile-creator.js +++ b/lib/wavefile-creator.js @@ -182,7 +182,7 @@ export class WaveFileCreator extends WaveFileParser { } if ( (info.sampleRate == 44100 || info.sampleRate == 22050) && - info.padding + !info.padding ) { soundInformation += 4; } diff --git a/test/dist/cart/cart-rw.js b/test/dist/cart/cart-rw.js index 50a7c99..809ff76 100644 --- a/test/dist/cart/cart-rw.js +++ b/test/dist/cart/cart-rw.js @@ -145,31 +145,31 @@ describe("Create an bwf mpeg cart file from info and an mp2 file", function() { ); assert.equal(wav.mext.frameSize, 768); - assert.equal(wav.mext.soundInformation, 12); + assert.equal(wav.mext.soundInformation, 8); }); describe("Create a bwf mpeg cart file from an mp2 file", function() { let wav = new WaveFile(); - wav.fromMpeg(fs.readFileSync(path + "test.mp2")); + wav.fromMpeg(fs.readFileSync(path + "44100_test.mp2")); fs.writeFileSync(path + "out/test-mp2.wav", wav.toBuffer()); wav = new WaveFile(fs.readFileSync(path + "out/test-mp2.wav")); - assert.equal(wav.fmt.sampleRate, 48000); + assert.equal(wav.fmt.sampleRate, 44100); assert.equal(wav.fmt.byteRate, 32000); assert.equal(wav.fmt.numChannels, 2); - assert.equal(wav.fmt.blockAlign, 768); + assert.equal(wav.fmt.blockAlign, 835); assert.equal(wav.fmt.numChannels, 2); assert.equal(wav.fmt.headBitRate, 256000); assert.equal(wav.fmt.headLayer, 2); - assert.equal(wav.fact.dwSampleLength, 269568); + assert.equal(wav.fact.dwSampleLength, 1323648); assert.equal( wav.bext.codingHistory, - "A=MPEG1L2,F=48000,B=256,M=stereo,T=wavefile\r\n\u0000\u0000" + "A=MPEG1L2,F=44100,B=256,M=stereo,T=wavefile\r\n\u0000\u0000" ); - assert.equal(wav.mext.frameSize, 768); - assert.equal(wav.mext.soundInformation, 3); + assert.equal(wav.mext.frameSize, 835); + assert.equal(wav.mext.soundInformation, 7); });