Skip to content

Commit

Permalink
Correctly calc mext sound info for 44.1 and no padding
Browse files Browse the repository at this point in the history
  • Loading branch information
kookster committed Apr 29, 2022
1 parent a0626f5 commit b904b07
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/wavefile-creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class WaveFileCreator extends WaveFileParser {
}
if (
(info.sampleRate == 44100 || info.sampleRate == 22050) &&
info.padding
!info.padding
) {
soundInformation += 4;
}
Expand Down
16 changes: 8 additions & 8 deletions test/dist/cart/cart-rw.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

0 comments on commit b904b07

Please sign in to comment.