Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mext soundinfo math #2

Merged
merged 6 commits into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 102 additions & 98 deletions dist/wavefile.js

Large diffs are not rendered by default.

560 changes: 368 additions & 192 deletions docs/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/lib_wavefile-creator.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ <h1 class="page-title">lib/wavefile-creator.js</h1>
}
if (
(info.sampleRate == 44100 || info.sampleRate == 22050) &amp;&amp;
info.padding
!info.padding
) {
soundInformation += 4;
}
Expand Down
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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the issue that needed to be changed - was checking for if there was padding instead o

) {
soundInformation += 4;
}
Expand Down
183 changes: 95 additions & 88 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "prx-wavefile",
"version": "11.0.0-prx.1",
"version": "11.0.0-prx.3",
"description": "Create, read and write wav files according to the specs.",
"homepage": "https://github.com/rochars/wavefile",
"homepage": "https://github.com/PRX/prx-wavefile",
"author": "Rafael da Silva Rocha <rocha.rafaelsilva@gmail.com>",
"license": "MIT",
"main": "./dist/wavefile.js",
Expand Down Expand Up @@ -41,10 +41,10 @@
],
"repository": {
"type": "git",
"url": "git://github.com/rochars/wavefile.git"
"url": "git://github.com/PRX/prx-wavefile.git"
},
"bugs": {
"url": "https://github.com/rochars/wavefile/issues"
"url": "https://github.com/PRX/prx-wavefile/issues"
},
"directories": {
"bin": "bin",
Expand Down Expand Up @@ -76,15 +76,15 @@
"test-sr-sinc": "node ./node_modules/mocha/bin/_mocha test/resampler-full/sinc.js test/resampler-full/sinc-IIR.js test/resampler-full/sinc-no-lpf.js -R dot --timeout=1600000",
"test-umd": "node ./node_modules/mocha/bin/_mocha test/resampler test/dist test/src --umd --recursive -R dot --timeout=240000",
"test-tsc": "tsc ./test/TypeScript/index.ts && node -r esm ./test/TypeScript/index.js",
"test-cli": "wavefile ./test/files/M1F1-int12WE-AFsp.wav --tag=ICMT && wavefile ./test/files/M1F1-int12WE-AFsp.wav --resample=16000 --method=point ./test/files/out/to-sample-rate/M1F1-int12WE-AFsp-CLI.wav",
"test-cli": "prx-wavefile ./test/files/M1F1-int12WE-AFsp.wav --tag=ICMT && prx-wavefile ./test/files/M1F1-int12WE-AFsp.wav --resample=16000 --method=point ./test/files/out/to-sample-rate/M1F1-int12WE-AFsp-CLI.wav",
"test-dist": "npm run test-umd && npm run test-tsc && npm run test-cli",
"rollup-bundle": "rollup -c && npm run test-dist",
"doc": "./node_modules/.bin/jsdoc -c .jsdocrc -d docs -r README.md -t node_modules/docdash",
"build": "npm run lint && npm test && npm run rollup-bundle && npm run doc",
"coverage": "nyc report --reporter=lcov > coverage.lcov && codecov"
},
"devDependencies": {
"@ampproject/rollup-plugin-closure-compiler": "^0.13.0",
"@ampproject/rollup-plugin-closure-compiler": "^0.27.0",
"@rollup/plugin-commonjs": "^11.0.0",
"@rollup/plugin-node-resolve": "^6.0.0",
"byte-data": "^19.0.1",
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);
});
Binary file added test/files/44100_test.mp2
Binary file not shown.
Binary file modified test/files/out/test-mp2-i.wav
Binary file not shown.
Binary file modified test/files/out/test-mp2.wav
Binary file not shown.