@@ 6-83 (lines=78) @@ | ||
3 | * |
|
4 | */ |
|
5 | ||
6 | var assert = require('assert'); |
|
7 | ||
8 | describe('read 32bit IEEE from disk and write to new file', function() { |
|
9 | ||
10 | let fs = require("fs"); |
|
11 | let wavefile = require("../index.js"); |
|
12 | let path = "test/files/"; |
|
13 | ||
14 | let wBytes = fs.readFileSync(path + "32bitIEEE-16kHz-bext-mono.wav"); |
|
15 | let wav = new wavefile.WaveFile(wBytes); |
|
16 | let wav2 = new wavefile.WaveFile(wav.toBytes()); |
|
17 | fs.writeFileSync(path + "/out/32bitIEEE-16kHz-bext-mono.wav", wav2.toBytes()); |
|
18 | ||
19 | it("toBytes should return a array of bytes", |
|
20 | function() { |
|
21 | assert.ok(wav.toBytes()); |
|
22 | }); |
|
23 | it("chunkId should be 'RIFF'", |
|
24 | function() { |
|
25 | assert.equal(wav2.chunkId, "RIFF"); |
|
26 | }); |
|
27 | it("subChunk1Id should be 'fmt '", |
|
28 | function() { |
|
29 | assert.equal(wav2.subChunk1Id, "fmt "); |
|
30 | }); |
|
31 | it("format should be 'WAVE'", |
|
32 | function() { |
|
33 | assert.equal(wav2.format, "WAVE"); |
|
34 | }); |
|
35 | it("subChunk1Size should be 16", |
|
36 | function() { |
|
37 | assert.equal(wav2.subChunk1Size, 16); |
|
38 | }); |
|
39 | it("audioFormat should be 3 (IEEE)", |
|
40 | function() { |
|
41 | assert.equal(wav2.audioFormat, 3); |
|
42 | }); |
|
43 | it("numChannels should be 1", |
|
44 | function() { |
|
45 | assert.equal(wav2.numChannels, 1); |
|
46 | }); |
|
47 | it("sampleRate should be 16000", |
|
48 | function() { |
|
49 | assert.equal(wav2.sampleRate, 16000); |
|
50 | }); |
|
51 | it("byteRate should be 64000", |
|
52 | function() { |
|
53 | assert.equal(wav2.byteRate, 64000); |
|
54 | }); |
|
55 | it("blockAlign should be 4", |
|
56 | function() { |
|
57 | assert.equal(wav2.blockAlign, 4); |
|
58 | }); |
|
59 | it("bitsPerSample should be 32", |
|
60 | function() { |
|
61 | assert.equal(wav2.bitsPerSample, 32); |
|
62 | }); |
|
63 | it("subChunk2Id should be 'data'", |
|
64 | function() { |
|
65 | assert.equal(wav2.subChunk2Id, 'data'); |
|
66 | }); |
|
67 | it("subChunk2Size should be > 0", |
|
68 | function() { |
|
69 | assert.ok(wav2.subChunk2Size > 0); |
|
70 | }); |
|
71 | it("samples.length should be > 0", |
|
72 | function() { |
|
73 | assert.ok(wav2.samples_.length > 0); |
|
74 | }); |
|
75 | it("samples_ on the new file should have the same length as in the original file", |
|
76 | function() { |
|
77 | assert.equal(wav2.samples_.length, wav.samples_.length); |
|
78 | }); |
|
79 | it("samples_ on the new file should be same as the original file", |
|
80 | function() { |
|
81 | assert.deepEqual(wav2.samples_, wav.samples_); |
|
82 | }); |
|
83 | }); |
|
84 |
@@ 6-79 (lines=74) @@ | ||
3 | * |
|
4 | */ |
|
5 | ||
6 | var assert = require('assert'); |
|
7 | ||
8 | describe('read 32bit PCM from disk and write to new file', function() { |
|
9 | ||
10 | let fs = require("fs"); |
|
11 | let wavefile = require("../index.js"); |
|
12 | let path = "test/files/"; |
|
13 | ||
14 | let wBytes = fs.readFileSync(path + "32bit-48kHz-noBext-mono.wav"); |
|
15 | let wav = new wavefile.WaveFile(wBytes); |
|
16 | let wav2 = new wavefile.WaveFile(wav.toBytes()); |
|
17 | fs.writeFileSync(path + "/out/32bit-48kHz-noBext-mono.wav", wav2.toBytes()); |
|
18 | ||
19 | it("chunkId should be 'RIFF'", |
|
20 | function() { |
|
21 | assert.equal(wav2.chunkId, "RIFF"); |
|
22 | }); |
|
23 | it("subChunk1Id should be 'fmt '", |
|
24 | function() { |
|
25 | assert.equal(wav2.subChunk1Id, "fmt "); |
|
26 | }); |
|
27 | it("format should be 'WAVE'", |
|
28 | function() { |
|
29 | assert.equal(wav2.format, "WAVE"); |
|
30 | }); |
|
31 | it("subChunk1Size should be 16", |
|
32 | function() { |
|
33 | assert.equal(wav2.subChunk1Size, 16); |
|
34 | }); |
|
35 | it("audioFormat should be 1 (PCM)", |
|
36 | function() { |
|
37 | assert.equal(wav2.audioFormat, 1); |
|
38 | }); |
|
39 | it("numChannels should be 1", |
|
40 | function() { |
|
41 | assert.equal(wav2.numChannels, 1); |
|
42 | }); |
|
43 | it("sampleRate should be 48000", |
|
44 | function() { |
|
45 | assert.equal(wav2.sampleRate, 48000); |
|
46 | }); |
|
47 | it("byteRate should be 192000", |
|
48 | function() { |
|
49 | assert.equal(wav2.byteRate, 192000); |
|
50 | }); |
|
51 | it("blockAlign should be 4", |
|
52 | function() { |
|
53 | assert.equal(wav2.blockAlign, 4); |
|
54 | }); |
|
55 | it("bitsPerSample should be 32", |
|
56 | function() { |
|
57 | assert.equal(wav2.bitsPerSample, 32); |
|
58 | }); |
|
59 | it("subChunk2Id should be 'data'", |
|
60 | function() { |
|
61 | assert.equal(wav2.subChunk2Id, 'data'); |
|
62 | }); |
|
63 | it("subChunk2Size should be > 0", |
|
64 | function() { |
|
65 | assert.ok(wav2.subChunk2Size > 0); |
|
66 | }); |
|
67 | it("samples.length should be > 0", |
|
68 | function() { |
|
69 | assert.ok(wav2.samples_.length > 0); |
|
70 | }); |
|
71 | it("samples_ on the new file should have the same length as in the original file", |
|
72 | function() { |
|
73 | assert.equal(wav2.samples_.length, wav.samples_.length); |
|
74 | }); |
|
75 | it("samples_ on the new file should be same as the original file", |
|
76 | function() { |
|
77 | assert.deepEqual(wav2.samples_, wav.samples_); |
|
78 | }); |
|
79 | }); |
|
80 |
@@ 6-79 (lines=74) @@ | ||
3 | * |
|
4 | */ |
|
5 | ||
6 | var assert = require('assert'); |
|
7 | ||
8 | describe('read 64-bit file from disk and write to new file', function() { |
|
9 | ||
10 | let fs = require("fs"); |
|
11 | let wavefile = require("../index.js"); |
|
12 | let path = "test/files/"; |
|
13 | ||
14 | let wBytes = fs.readFileSync(path + "64bit-48kHz-noBext-mono.wav"); |
|
15 | let wav = new wavefile.WaveFile(wBytes); |
|
16 | let wav2 = new wavefile.WaveFile(wav.toBytes()); |
|
17 | fs.writeFileSync(path + "/out/64bit-48kHz-noBext-mono.wav", wav2.toBytes()); |
|
18 | ||
19 | it("chunkId should be 'RIFF'", |
|
20 | function() { |
|
21 | assert.equal(wav2.chunkId, "RIFF"); |
|
22 | }); |
|
23 | it("subChunk1Id should be 'fmt '", |
|
24 | function() { |
|
25 | assert.equal(wav2.subChunk1Id, "fmt "); |
|
26 | }); |
|
27 | it("format should be 'WAVE'", |
|
28 | function() { |
|
29 | assert.equal(wav2.format, "WAVE"); |
|
30 | }); |
|
31 | it("subChunk1Size should be 16", |
|
32 | function() { |
|
33 | assert.equal(wav2.subChunk1Size, 16); |
|
34 | }); |
|
35 | it("audioFormat should be 3 (IEEE)", |
|
36 | function() { |
|
37 | assert.equal(wav2.audioFormat, 3); |
|
38 | }); |
|
39 | it("numChannels should be 1", |
|
40 | function() { |
|
41 | assert.equal(wav2.numChannels, 1); |
|
42 | }); |
|
43 | it("sampleRate should be 48000", |
|
44 | function() { |
|
45 | assert.equal(wav2.sampleRate, 48000); |
|
46 | }); |
|
47 | it("byteRate should be 384000", |
|
48 | function() { |
|
49 | assert.equal(wav2.byteRate, 384000); |
|
50 | }); |
|
51 | it("blockAlign should be 8", |
|
52 | function() { |
|
53 | assert.equal(wav2.blockAlign, 8); |
|
54 | }); |
|
55 | it("bitsPerSample should be 64", |
|
56 | function() { |
|
57 | assert.equal(wav2.bitsPerSample, 64); |
|
58 | }); |
|
59 | it("subChunk2Id should be 'data'", |
|
60 | function() { |
|
61 | assert.equal(wav2.subChunk2Id, 'data'); |
|
62 | }); |
|
63 | it("subChunk2Size should be > 0", |
|
64 | function() { |
|
65 | assert.ok(wav2.subChunk2Size > 0); |
|
66 | }); |
|
67 | it("samples.length should be > 0", |
|
68 | function() { |
|
69 | assert.ok(wav2.samples_.length > 0); |
|
70 | }); |
|
71 | it("samples_ on the new file should have the same length as in the original file ", |
|
72 | function() { |
|
73 | assert.equal(wav2.samples_.length, wav.samples_.length); |
|
74 | }); |
|
75 | it("samples_ on the new file should be same as the original file ", |
|
76 | function() { |
|
77 | assert.deepEqual(wav2.samples_, wav.samples_); |
|
78 | }); |
|
79 | }); |
|
80 |
@@ 6-79 (lines=74) @@ | ||
3 | * |
|
4 | */ |
|
5 | ||
6 | var assert = require('assert'); |
|
7 | ||
8 | describe('read 24bit file from disk and write to new file', function() { |
|
9 | ||
10 | let fs = require("fs"); |
|
11 | let wavefile = require("../index.js"); |
|
12 | let path = "test/files/"; |
|
13 | ||
14 | let wBytes = fs.readFileSync(path + "24bit-16kHz-bext-mono.wav"); |
|
15 | let wav = new wavefile.WaveFile(wBytes); |
|
16 | let wav2 = new wavefile.WaveFile(wav.toBytes()); |
|
17 | fs.writeFileSync(path + "/out/24bit-16kHz-bext-mono.wav", wav2.toBytes()); |
|
18 | ||
19 | it("chunkId should be 'RIFF'", |
|
20 | function() { |
|
21 | assert.equal(wav2.chunkId, "RIFF"); |
|
22 | }); |
|
23 | it("subChunk1Id should be 'fmt '", |
|
24 | function() { |
|
25 | assert.equal(wav2.subChunk1Id, "fmt "); |
|
26 | }); |
|
27 | it("format should be 'WAVE'", |
|
28 | function() { |
|
29 | assert.equal(wav2.format, "WAVE"); |
|
30 | }); |
|
31 | it("subChunk1Size should be 16", |
|
32 | function() { |
|
33 | assert.equal(wav2.subChunk1Size, 16); |
|
34 | }); |
|
35 | it("audioFormat should be 1 (PCM)", |
|
36 | function() { |
|
37 | assert.equal(wav2.audioFormat, 1); |
|
38 | }); |
|
39 | it("numChannels should be 1", |
|
40 | function() { |
|
41 | assert.equal(wav2.numChannels, 1); |
|
42 | }); |
|
43 | it("sampleRate should be 16000", |
|
44 | function() { |
|
45 | assert.equal(wav2.sampleRate, 16000); |
|
46 | }); |
|
47 | it("byteRate should be 48000", |
|
48 | function() { |
|
49 | assert.equal(wav2.byteRate, 48000); |
|
50 | }); |
|
51 | it("blockAlign should be 3", |
|
52 | function() { |
|
53 | assert.equal(wav2.blockAlign, 3); |
|
54 | }); |
|
55 | it("bitsPerSample should be 24", |
|
56 | function() { |
|
57 | assert.equal(wav2.bitsPerSample, 24); |
|
58 | }); |
|
59 | it("subChunk2Id should be 'data'", |
|
60 | function() { |
|
61 | assert.equal(wav2.subChunk2Id, 'data'); |
|
62 | }); |
|
63 | it("subChunk2Size should be > 0", |
|
64 | function() { |
|
65 | assert.ok(wav2.subChunk2Size > 0); |
|
66 | }); |
|
67 | it("samples.length should be > 0", |
|
68 | function() { |
|
69 | assert.ok(wav2.samples_.length > 0); |
|
70 | }); |
|
71 | it("samples_ on the new file should have the same length as in the original file", |
|
72 | function() { |
|
73 | assert.equal(wav2.samples_.length, wav.samples_.length); |
|
74 | }); |
|
75 | it("samples_ on the new file should be same as the original file", |
|
76 | function() { |
|
77 | assert.deepEqual(wav2.samples_, wav.samples_); |
|
78 | }); |
|
79 | }); |
|
80 |
@@ 6-79 (lines=74) @@ | ||
3 | * |
|
4 | */ |
|
5 | ||
6 | var assert = require('assert'); |
|
7 | ||
8 | describe('read 8-bit file from disk and write to new file', function() { |
|
9 | ||
10 | let fs = require("fs"); |
|
11 | let wavefile = require("../index.js"); |
|
12 | let path = "test/files/"; |
|
13 | ||
14 | let wBytes = fs.readFileSync(path + "8bit-16kHz-bext-mono.wav"); |
|
15 | let wav = new wavefile.WaveFile(wBytes); |
|
16 | let wav2 = new wavefile.WaveFile(wav.toBytes()); |
|
17 | fs.writeFileSync(path + "/out/8bit-16kHz-bext-mono.wav", wav2.toBytes()); |
|
18 | ||
19 | it("chunkId should be 'RIFF'", |
|
20 | function() { |
|
21 | assert.equal(wav2.chunkId, "RIFF"); |
|
22 | }); |
|
23 | it("subChunk1Id should be 'fmt '", |
|
24 | function() { |
|
25 | assert.equal(wav2.subChunk1Id, "fmt "); |
|
26 | }); |
|
27 | it("format in should be 'WAVE'", |
|
28 | function() { |
|
29 | assert.equal(wav2.format, "WAVE"); |
|
30 | }); |
|
31 | it("subChunk1Size should be 16", |
|
32 | function() { |
|
33 | assert.equal(wav2.subChunk1Size, 16); |
|
34 | }); |
|
35 | it("audioFormat should be 1 (PCM)", |
|
36 | function() { |
|
37 | assert.equal(wav2.audioFormat, 1); |
|
38 | }); |
|
39 | it("numChannels should be 1", |
|
40 | function() { |
|
41 | assert.equal(wav2.numChannels, 1); |
|
42 | }); |
|
43 | it("sampleRate should be 16000", |
|
44 | function() { |
|
45 | assert.equal(wav2.sampleRate, 16000); |
|
46 | }); |
|
47 | it("byteRate should be 16000", |
|
48 | function() { |
|
49 | assert.equal(wav2.byteRate, 16000); |
|
50 | }); |
|
51 | it("blockAlign should be 1", |
|
52 | function() { |
|
53 | assert.equal(wav2.blockAlign, 1); |
|
54 | }); |
|
55 | it("bitsPerSample should be 8", |
|
56 | function() { |
|
57 | assert.equal(wav2.bitsPerSample, 8); |
|
58 | }); |
|
59 | it("subChunk2Id should be 'data'", |
|
60 | function() { |
|
61 | assert.equal(wav2.subChunk2Id, 'data'); |
|
62 | }); |
|
63 | it("subChunk2Size should be > 0", |
|
64 | function() { |
|
65 | assert.ok(wav2.subChunk2Size > 0); |
|
66 | }); |
|
67 | it("samples.length should be > 0", |
|
68 | function() { |
|
69 | assert.ok(wav2.samples_.length > 0); |
|
70 | }); |
|
71 | it("samples_ on the new file should have the same length as in the original file ", |
|
72 | function() { |
|
73 | assert.equal(wav2.samples_.length, wav.samples_.length); |
|
74 | }); |
|
75 | it("samples_ on the new file should be same as the original file ", |
|
76 | function() { |
|
77 | assert.deepEqual(wav2.samples_, wav.samples_); |
|
78 | }); |
|
79 | }); |
|
80 |
@@ 6-89 (lines=84) @@ | ||
3 | * |
|
4 | */ |
|
5 | ||
6 | var assert = require('assert'); |
|
7 | ||
8 | describe('read 16bit file from disk and write to new file', function() { |
|
9 | ||
10 | let fs = require("fs"); |
|
11 | let wavefile = require("../index.js"); |
|
12 | let path = "test/files/"; |
|
13 | ||
14 | let wBytes = fs.readFileSync(path + "16-bit-8kHz-noBext-mono.wav"); |
|
15 | let wav = new wavefile.WaveFile(); |
|
16 | ||
17 | wav.fromBytes(wBytes); |
|
18 | ||
19 | let wav2 = new wavefile.WaveFile(); |
|
20 | ||
21 | let bytes3 = wav.toBytes(); |
|
22 | ||
23 | wav2.fromBytes(bytes3); |
|
24 | ||
25 | let bytes4 = wav2.toBytes(); |
|
26 | ||
27 | fs.writeFileSync(path + "/out/16-bit-8kHz-noBext-mono.wav", bytes4); |
|
28 | ||
29 | it("chunkId should be 'RIFF'", |
|
30 | function() { |
|
31 | assert.equal(wav2.chunkId, "RIFF"); |
|
32 | }); |
|
33 | it("subChunk1Id should be 'fmt '", |
|
34 | function() { |
|
35 | assert.equal(wav2.subChunk1Id, "fmt "); |
|
36 | }); |
|
37 | it("format should be 'WAVE'", |
|
38 | function() { |
|
39 | assert.equal(wav2.format, "WAVE"); |
|
40 | }); |
|
41 | it("subChunk1Size should be 16", |
|
42 | function() { |
|
43 | assert.equal(wav2.subChunk1Size, 16); |
|
44 | }); |
|
45 | it("audioFormat should be 1 (PCM)", |
|
46 | function() { |
|
47 | assert.equal(wav2.audioFormat, 1); |
|
48 | }); |
|
49 | it("numChannels should be 1", |
|
50 | function() { |
|
51 | assert.equal(wav2.numChannels, 1); |
|
52 | }); |
|
53 | it("sampleRate should be 8000", |
|
54 | function() { |
|
55 | assert.equal(wav2.sampleRate, 8000); |
|
56 | }); |
|
57 | it("byteRate should be 16000", |
|
58 | function() { |
|
59 | assert.equal(wav2.byteRate, 16000); |
|
60 | }); |
|
61 | it("blockAlign should be 2", |
|
62 | function() { |
|
63 | assert.equal(wav2.blockAlign, 2); |
|
64 | }); |
|
65 | it("bitsPerSample should be 16", |
|
66 | function() { |
|
67 | assert.equal(wav2.bitsPerSample, 16); |
|
68 | }); |
|
69 | it("subChunk2Id should be 'data'", |
|
70 | function() { |
|
71 | assert.equal(wav2.subChunk2Id, 'data'); |
|
72 | }); |
|
73 | it("subChunk2Size should be > 0", |
|
74 | function() { |
|
75 | assert.ok(wav2.subChunk2Size > 0); |
|
76 | }); |
|
77 | it("samples.length should be > 0", |
|
78 | function() { |
|
79 | assert.ok(wav2.samples_.length > 0); |
|
80 | }); |
|
81 | it("samples_ on the new file should have the same length as in the original file", |
|
82 | function() { |
|
83 | assert.equal(wav2.samples_.length, wav.samples_.length); |
|
84 | }); |
|
85 | it("samples_ on the new file should be same as the original file", |
|
86 | function() { |
|
87 | assert.deepEqual(wav2.samples_, wav.samples_); |
|
88 | }); |
|
89 | }); |
|
90 |
@@ 6-87 (lines=82) @@ | ||
3 | * |
|
4 | */ |
|
5 | ||
6 | var assert = require('assert'); |
|
7 | ||
8 | describe('read 4-bit file from disk and write to new file', function() { |
|
9 | ||
10 | let fs = require("fs"); |
|
11 | let wavefile = require("../index.js"); |
|
12 | let path = "test/files/"; |
|
13 | ||
14 | let wBytes = fs.readFileSync(path + "4bit-imaadpcm-8kHz-noBext-mono.wav"); |
|
15 | let wav = new wavefile.WaveFile(wBytes); |
|
16 | let wav2 = new wavefile.WaveFile(wav.toBytes()); |
|
17 | fs.writeFileSync(path + "/out/4bit-imaadpcm-8kHz-noBext-mono.wav", wav2.toBytes()); |
|
18 | ||
19 | it("chunkId should be 'RIFF'", |
|
20 | function() { |
|
21 | assert.equal(wav2.chunkId, "RIFF"); |
|
22 | }); |
|
23 | it("subChunk1Id should be 'fmt '", |
|
24 | function() { |
|
25 | assert.equal(wav2.subChunk1Id, "fmt "); |
|
26 | }); |
|
27 | it("format should be 'WAVE'", |
|
28 | function() { |
|
29 | assert.equal(wav2.format, "WAVE"); |
|
30 | }); |
|
31 | it("subChunk1Size should be 20", |
|
32 | function() { |
|
33 | assert.equal(wav2.subChunk1Size, 20); |
|
34 | }); |
|
35 | it("audioFormat should be 17 (IMA ADPCM)", |
|
36 | function() { |
|
37 | assert.equal(wav2.audioFormat, 17); |
|
38 | }); |
|
39 | it("numChannels should be 1", |
|
40 | function() { |
|
41 | assert.equal(wav2.numChannels, 1); |
|
42 | }); |
|
43 | it("sampleRate should be 8000", |
|
44 | function() { |
|
45 | assert.equal(wav2.sampleRate, 8000); |
|
46 | }); |
|
47 | it("byteRate should be 4055", |
|
48 | function() { |
|
49 | assert.equal(wav2.byteRate, 4055); |
|
50 | }); |
|
51 | it("blockAlign should be 256", |
|
52 | function() { |
|
53 | assert.equal(wav2.blockAlign, 256); |
|
54 | }); |
|
55 | it("bitsPerSample should be 4", |
|
56 | function() { |
|
57 | assert.equal(wav2.bitsPerSample, 4); |
|
58 | }); |
|
59 | it("factChunkId should be 'fact'", |
|
60 | function() { |
|
61 | assert.equal(wav2.factChunkId, 'fact'); |
|
62 | }); |
|
63 | it("factChunkSize should be 4", |
|
64 | function() { |
|
65 | assert.equal(wav2.factChunkSize, 4); |
|
66 | }); |
|
67 | it("subChunk2Id should be 'data'", |
|
68 | function() { |
|
69 | assert.equal(wav2.subChunk2Id, 'data'); |
|
70 | }); |
|
71 | it("subChunk2Size should be > 0", |
|
72 | function() { |
|
73 | assert.ok(wav2.subChunk2Size > 0); |
|
74 | }); |
|
75 | it("samples.length should be > 0", |
|
76 | function() { |
|
77 | assert.ok(wav2.samples_.length > 0); |
|
78 | }); |
|
79 | it("samples_ on the new file should have the same length as in the original file", |
|
80 | function() { |
|
81 | assert.equal(wav2.samples_.length, wav.samples_.length); |
|
82 | }); |
|
83 | it("samples_ on the new file should be same as the original file", |
|
84 | function() { |
|
85 | assert.deepEqual(wav2.samples_, wav.samples_); |
|
86 | }); |
|
87 | }); |
|
88 |
@@ 6-87 (lines=82) @@ | ||
3 | * |
|
4 | */ |
|
5 | ||
6 | var assert = require('assert'); |
|
7 | ||
8 | describe('read 4-bit file from disk and write to new file (different APDCM source)', function() { |
|
9 | ||
10 | let fs = require("fs"); |
|
11 | let wavefile = require("../index.js"); |
|
12 | let path = "test/files/"; |
|
13 | ||
14 | let wBytes = fs.readFileSync(path + "4-bit-imaadpcm-8kHz-noBext-mono-reaper.wav"); |
|
15 | let wav = new wavefile.WaveFile(wBytes); |
|
16 | let wav2 = new wavefile.WaveFile(wav.toBytes()); |
|
17 | fs.writeFileSync(path + "/out/4-bit-imaadpcm-8kHz-noBext-mono-reaper.wav", wav2.toBytes()); |
|
18 | ||
19 | it("chunkId should be 'RIFF'", |
|
20 | function() { |
|
21 | assert.equal(wav2.chunkId, "RIFF"); |
|
22 | }); |
|
23 | it("subChunk1Id should be 'fmt '", |
|
24 | function() { |
|
25 | assert.equal(wav2.subChunk1Id, "fmt "); |
|
26 | }); |
|
27 | it("format should be 'WAVE'", |
|
28 | function() { |
|
29 | assert.equal(wav2.format, "WAVE"); |
|
30 | }); |
|
31 | it("subChunk1Size should be 20", |
|
32 | function() { |
|
33 | assert.equal(wav2.subChunk1Size, 20); |
|
34 | }); |
|
35 | it("audioFormat should be 17 (IMA ADPCM)", |
|
36 | function() { |
|
37 | assert.equal(wav2.audioFormat, 17); |
|
38 | }); |
|
39 | it("numChannels should be 1", |
|
40 | function() { |
|
41 | assert.equal(wav2.numChannels, 1); |
|
42 | }); |
|
43 | it("sampleRate should be 8000", |
|
44 | function() { |
|
45 | assert.equal(wav2.sampleRate, 8000); |
|
46 | }); |
|
47 | it("byteRate should be 4000", |
|
48 | function() { |
|
49 | assert.equal(wav2.byteRate, 4000); |
|
50 | }); |
|
51 | it("blockAlign should be 1024", |
|
52 | function() { |
|
53 | assert.equal(wav2.blockAlign, 1024); |
|
54 | }); |
|
55 | it("bitsPerSample should be 4", |
|
56 | function() { |
|
57 | assert.equal(wav2.bitsPerSample, 4); |
|
58 | }); |
|
59 | it("factChunkId should be 'fact'", |
|
60 | function() { |
|
61 | assert.equal(wav2.factChunkId, 'fact'); |
|
62 | }); |
|
63 | it("factChunkSize should be 4", |
|
64 | function() { |
|
65 | assert.equal(wav2.factChunkSize, 4); |
|
66 | }); |
|
67 | it("subChunk2Id should be 'data'", |
|
68 | function() { |
|
69 | assert.equal(wav2.subChunk2Id, 'data'); |
|
70 | }); |
|
71 | it("subChunk2Size should be > 0", |
|
72 | function() { |
|
73 | assert.ok(wav2.subChunk2Size > 0); |
|
74 | }); |
|
75 | it("samples.length should be > 0", |
|
76 | function() { |
|
77 | assert.ok(wav2.samples_.length > 0); |
|
78 | }); |
|
79 | it("samples_ on the new file should have the same length as in the original file", |
|
80 | function() { |
|
81 | assert.equal(wav2.samples_.length, wav.samples_.length); |
|
82 | }); |
|
83 | it("samples_ on the new file should be same as the original file", |
|
84 | function() { |
|
85 | assert.deepEqual(wav2.samples_, wav.samples_); |
|
86 | }); |
|
87 | }); |
|
88 |
@@ 7-70 (lines=64) @@ | ||
4 | * |
|
5 | */ |
|
6 | ||
7 | let assert = require("assert"); |
|
8 | ||
9 | describe("4-bit IMA ADPCM reading", function() { |
|
10 | ||
11 | let fs = require("fs"); |
|
12 | let wavefile = require("../index.js"); |
|
13 | let path = "test/files/"; |
|
14 | ||
15 | let wBytes = fs.readFileSync(path + '4bit-imaadpcm-8kHz-noBext-mono.wav'); |
|
16 | let wav = new wavefile.WaveFile(wBytes); |
|
17 | ||
18 | it("chunkId should be 'RIFF'", |
|
19 | function() { |
|
20 | assert.equal(wav.chunkId, "RIFF"); |
|
21 | }); |
|
22 | it("subChunk1Id should be 'fmt '", |
|
23 | function() { |
|
24 | assert.equal(wav.subChunk1Id, "fmt "); |
|
25 | }); |
|
26 | it("format should be 'WAVE'", |
|
27 | function() { |
|
28 | assert.equal(wav.format, "WAVE"); |
|
29 | }); |
|
30 | it("subChunk1Size should be 20", |
|
31 | function() { |
|
32 | assert.equal(wav.subChunk1Size, 20); |
|
33 | }); |
|
34 | it("audioFormat should be 17 (IMA ADPCM)", |
|
35 | function() { |
|
36 | assert.equal(wav.audioFormat, 17); |
|
37 | }); |
|
38 | it("numChannels should be 1", |
|
39 | function() { |
|
40 | assert.equal(wav.numChannels, 1); |
|
41 | }); |
|
42 | it("sampleRate should be 8000", |
|
43 | function() { |
|
44 | assert.equal(wav.sampleRate, 8000); |
|
45 | }); |
|
46 | it("bitsPerSample should be 4", |
|
47 | function() { |
|
48 | assert.equal(wav.bitsPerSample, 4); |
|
49 | }); |
|
50 | it("factChunkId should be 'fact'", |
|
51 | function() { |
|
52 | assert.equal(wav.factChunkId, 'fact'); |
|
53 | }); |
|
54 | it("factChunkSize should be 4", |
|
55 | function() { |
|
56 | assert.equal(wav.factChunkSize, 4); |
|
57 | }); |
|
58 | it("subChunk2Id should be 'data'", |
|
59 | function() { |
|
60 | assert.equal(wav.subChunk2Id, 'data'); |
|
61 | }); |
|
62 | it("subChunk2Size should be > 0", |
|
63 | function() { |
|
64 | assert.ok(wav.subChunk2Size > 0); |
|
65 | }); |
|
66 | it("samples.length should be > 0", |
|
67 | function() { |
|
68 | assert.ok(wav.samples_.length > 0); |
|
69 | }); |
|
70 | }); |
|
71 |
@@ 6-69 (lines=64) @@ | ||
3 | * |
|
4 | */ |
|
5 | ||
6 | let assert = require("assert"); |
|
7 | ||
8 | describe("32-bit IEEE (with bwf) reading", function() { |
|
9 | ||
10 | let fs = require("fs"); |
|
11 | let wavefile = require("../index.js"); |
|
12 | let path = "test/files/"; |
|
13 | ||
14 | let wBytes = fs.readFileSync(path + "32bitIEEE-16kHz-bext-mono.wav"); |
|
15 | let wav = new wavefile.WaveFile(wBytes); |
|
16 | ||
17 | it("chunkId should be 'RIFF'", |
|
18 | function() { |
|
19 | assert.equal(wav.chunkId, "RIFF"); |
|
20 | }); |
|
21 | it("subChunk1Id should be 'fmt '", |
|
22 | function() { |
|
23 | assert.equal(wav.subChunk1Id, "fmt "); |
|
24 | }); |
|
25 | it("format should be 'WAVE'", |
|
26 | function() { |
|
27 | assert.equal(wav.format, "WAVE"); |
|
28 | }); |
|
29 | it("subChunk1Size should be 16", |
|
30 | function() { |
|
31 | assert.equal(wav.subChunk1Size, 16); |
|
32 | }); |
|
33 | it("audioFormat should be 3 (IEEE)", |
|
34 | function() { |
|
35 | assert.equal(wav.audioFormat, 3); |
|
36 | }); |
|
37 | it("numChannels should be 1", |
|
38 | function() { |
|
39 | assert.equal(wav.numChannels, 1); |
|
40 | }); |
|
41 | it("sampleRate should be 16000", |
|
42 | function() { |
|
43 | assert.equal(wav.sampleRate, 16000); |
|
44 | }); |
|
45 | it("byteRate should be 64000", |
|
46 | function() { |
|
47 | assert.equal(wav.byteRate, 64000); |
|
48 | }); |
|
49 | it("blockAlign should be 4", |
|
50 | function() { |
|
51 | assert.equal(wav.blockAlign, 4); |
|
52 | }); |
|
53 | it("bitsPerSample should be 32", |
|
54 | function() { |
|
55 | assert.equal(wav.bitsPerSample, 32); |
|
56 | }); |
|
57 | it("subChunk2Id be 'data'", |
|
58 | function() { |
|
59 | assert.equal(wav.subChunk2Id, 'data'); |
|
60 | }); |
|
61 | it("subChunk2Size should be > 0", |
|
62 | function() { |
|
63 | assert.ok(wav.subChunk2Size > 0); |
|
64 | }); |
|
65 | it("samples.length should be > 0", |
|
66 | function() { |
|
67 | assert.ok(wav.samples_.length > 0); |
|
68 | }); |
|
69 | }); |
|
70 |
@@ 6-69 (lines=64) @@ | ||
3 | * |
|
4 | */ |
|
5 | ||
6 | let assert = require("assert"); |
|
7 | ||
8 | describe("64-bit reading", function() { |
|
9 | ||
10 | let fs = require("fs"); |
|
11 | let wavefile = require("../index.js"); |
|
12 | let path = "test/files/"; |
|
13 | ||
14 | let wBytes = fs.readFileSync(path + "64bit-48kHz-noBext-mono.wav"); |
|
15 | let wav = new wavefile.WaveFile(wBytes); |
|
16 | ||
17 | it("chunkId should be 'RIFF'", |
|
18 | function() { |
|
19 | assert.equal(wav.chunkId, "RIFF"); |
|
20 | }); |
|
21 | it("subChunk1Id should be 'fmt '", |
|
22 | function() { |
|
23 | assert.equal(wav.subChunk1Id, "fmt "); |
|
24 | }); |
|
25 | it("format should be 'WAVE'", |
|
26 | function() { |
|
27 | assert.equal(wav.format, "WAVE"); |
|
28 | }); |
|
29 | it("subChunk1Size should be 16", |
|
30 | function() { |
|
31 | assert.equal(wav.subChunk1Size, 16); |
|
32 | }); |
|
33 | it("audioFormat should be 3 (IEEE)", |
|
34 | function() { |
|
35 | assert.equal(wav.audioFormat, 3); |
|
36 | }); |
|
37 | it("numChannels should be 1", |
|
38 | function() { |
|
39 | assert.equal(wav.numChannels, 1); |
|
40 | }); |
|
41 | it("sampleRate should be 48000", |
|
42 | function() { |
|
43 | assert.equal(wav.sampleRate, 48000); |
|
44 | }); |
|
45 | it("byteRate should be 384000", |
|
46 | function() { |
|
47 | assert.equal(wav.byteRate, 384000); |
|
48 | }); |
|
49 | it("blockAlign should be 8", |
|
50 | function() { |
|
51 | assert.equal(wav.blockAlign, 8); |
|
52 | }); |
|
53 | it("bitsPerSample should be 64", |
|
54 | function() { |
|
55 | assert.equal(wav.bitsPerSample, 64); |
|
56 | }); |
|
57 | it("subChunk2Id should be 'data'", |
|
58 | function() { |
|
59 | assert.equal(wav.subChunk2Id, 'data'); |
|
60 | }); |
|
61 | it("subChunk2Size should be > 0", |
|
62 | function() { |
|
63 | assert.ok(wav.subChunk2Size > 0); |
|
64 | }); |
|
65 | it("samples.length should be > 0", |
|
66 | function() { |
|
67 | assert.ok(wav.samples_.length > 0); |
|
68 | }); |
|
69 | }); |
|
70 |
@@ 6-69 (lines=64) @@ | ||
3 | * |
|
4 | */ |
|
5 | ||
6 | let assert = require("assert"); |
|
7 | ||
8 | describe("8-bit file (with bwf) reading", function() { |
|
9 | ||
10 | let fs = require("fs"); |
|
11 | let wavefile = require("../index.js"); |
|
12 | let path = "test/files/"; |
|
13 | ||
14 | let wBytes = fs.readFileSync(path + "8bit-16kHz-bext-mono.wav"); |
|
15 | let wav = new wavefile.WaveFile(wBytes); |
|
16 | ||
17 | it("chunkId should be 'RIFF'", |
|
18 | function() { |
|
19 | assert.equal(wav.chunkId, "RIFF"); |
|
20 | }); |
|
21 | it("subChunk1Id should be 'fmt '", |
|
22 | function() { |
|
23 | assert.equal(wav.subChunk1Id, "fmt "); |
|
24 | }); |
|
25 | it("format should be 'WAVE'", |
|
26 | function() { |
|
27 | assert.equal(wav.format, "WAVE"); |
|
28 | }); |
|
29 | it("subChunk1Size should be 16", |
|
30 | function() { |
|
31 | assert.equal(wav.subChunk1Size, 16); |
|
32 | }); |
|
33 | it("audioFormat should be 1 (PCM)", |
|
34 | function() { |
|
35 | assert.equal(wav.audioFormat, 1); |
|
36 | }); |
|
37 | it("numChannels should be 1", |
|
38 | function() { |
|
39 | assert.equal(wav.numChannels, 1); |
|
40 | }); |
|
41 | it("sampleRate should be 16000", |
|
42 | function() { |
|
43 | assert.equal(wav.sampleRate, 16000); |
|
44 | }); |
|
45 | it("byteRate should be 16000", |
|
46 | function() { |
|
47 | assert.equal(wav.byteRate, 16000); |
|
48 | }); |
|
49 | it("blockAlign should be 1", |
|
50 | function() { |
|
51 | assert.equal(wav.blockAlign, 1); |
|
52 | }); |
|
53 | it("bitsPerSample should be 8", |
|
54 | function() { |
|
55 | assert.equal(wav.bitsPerSample, 8); |
|
56 | }); |
|
57 | it("subChunk2Id should be 'data'", |
|
58 | function() { |
|
59 | assert.equal(wav.subChunk2Id, 'data'); |
|
60 | }); |
|
61 | it("subChunk2Size should be > 0", |
|
62 | function() { |
|
63 | assert.ok(wav.subChunk2Size > 0); |
|
64 | }); |
|
65 | it("samples.length should be > 0", |
|
66 | function() { |
|
67 | assert.ok(wav.samples_.length > 0); |
|
68 | }); |
|
69 | }); |
|
70 |
@@ 6-69 (lines=64) @@ | ||
3 | * |
|
4 | */ |
|
5 | ||
6 | let assert = require("assert"); |
|
7 | ||
8 | describe("24-bit (with bwf) reading", function() { |
|
9 | ||
10 | let fs = require("fs"); |
|
11 | let wavefile = require("../index.js"); |
|
12 | let path = "test/files/"; |
|
13 | ||
14 | let wBytes = fs.readFileSync(path + "24bit-16kHz-bext-mono.wav"); |
|
15 | let wav = new wavefile.WaveFile(wBytes); |
|
16 | ||
17 | it("chunkId should be 'RIFF'", |
|
18 | function() { |
|
19 | assert.equal(wav.chunkId, "RIFF"); |
|
20 | }); |
|
21 | it("subChunk1Id should be 'fmt '", |
|
22 | function() { |
|
23 | assert.equal(wav.subChunk1Id, "fmt "); |
|
24 | }); |
|
25 | it("format should be 'WAVE'", |
|
26 | function() { |
|
27 | assert.equal(wav.format, "WAVE"); |
|
28 | }); |
|
29 | it("subChunk1Size should be 16", |
|
30 | function() { |
|
31 | assert.equal(wav.subChunk1Size, 16); |
|
32 | }); |
|
33 | it("audioFormat should be 1 (PCM)", |
|
34 | function() { |
|
35 | assert.equal(wav.audioFormat, 1); |
|
36 | }); |
|
37 | it("numChannels should be 1", |
|
38 | function() { |
|
39 | assert.equal(wav.numChannels, 1); |
|
40 | }); |
|
41 | it("sampleRate should be 16000", |
|
42 | function() { |
|
43 | assert.equal(wav.sampleRate, 16000); |
|
44 | }); |
|
45 | it("byteRate should be 48000", |
|
46 | function() { |
|
47 | assert.equal(wav.byteRate, 48000); |
|
48 | }); |
|
49 | it("blockAlign should be 3", |
|
50 | function() { |
|
51 | assert.equal(wav.blockAlign, 3); |
|
52 | }); |
|
53 | it("bitsPerSample should be 24", |
|
54 | function() { |
|
55 | assert.equal(wav.bitsPerSample, 24); |
|
56 | }); |
|
57 | it("subChunk2Id should be 'data'", |
|
58 | function() { |
|
59 | assert.equal(wav.subChunk2Id, 'data'); |
|
60 | }); |
|
61 | it("subChunk2Size should be > 0", |
|
62 | function() { |
|
63 | assert.ok(wav.subChunk2Size > 0); |
|
64 | }); |
|
65 | it("samples.length should be > 0", |
|
66 | function() { |
|
67 | assert.ok(wav.samples_.length > 0); |
|
68 | }); |
|
69 | }); |
|
70 |
@@ 6-69 (lines=64) @@ | ||
3 | * |
|
4 | */ |
|
5 | ||
6 | let assert = require("assert"); |
|
7 | ||
8 | describe("32-bit PCM reading", function() { |
|
9 | ||
10 | let fs = require("fs"); |
|
11 | let wavefile = require("../index.js"); |
|
12 | let path = "test/files/"; |
|
13 | ||
14 | let wBytes = fs.readFileSync(path + "32bit-48kHz-noBext-mono.wav"); |
|
15 | let wav = new wavefile.WaveFile(wBytes); |
|
16 | ||
17 | it("chunkId should be 'RIFF'", |
|
18 | function() { |
|
19 | assert.equal(wav.chunkId, "RIFF"); |
|
20 | }); |
|
21 | it("subChunk1Id should be 'fmt '", |
|
22 | function() { |
|
23 | assert.equal(wav.subChunk1Id, "fmt "); |
|
24 | }); |
|
25 | it("format should be 'WAVE'", |
|
26 | function() { |
|
27 | assert.equal(wav.format, "WAVE"); |
|
28 | }); |
|
29 | it("subChunk1Size should be 16", |
|
30 | function() { |
|
31 | assert.equal(wav.subChunk1Size, 16); |
|
32 | }); |
|
33 | it("audioFormat should be 1 (PCM)", |
|
34 | function() { |
|
35 | assert.equal(wav.audioFormat, 1); |
|
36 | }); |
|
37 | it("numChannels should be 1", |
|
38 | function() { |
|
39 | assert.equal(wav.numChannels, 1); |
|
40 | }); |
|
41 | it("sampleRate should be 48000", |
|
42 | function() { |
|
43 | assert.equal(wav.sampleRate, 48000); |
|
44 | }); |
|
45 | it("byteRate should be 192000", |
|
46 | function() { |
|
47 | assert.equal(wav.byteRate, 192000); |
|
48 | }); |
|
49 | it("blockAlign should be 4", |
|
50 | function() { |
|
51 | assert.equal(wav.blockAlign, 4); |
|
52 | }); |
|
53 | it("bitsPerSample should be 32", |
|
54 | function() { |
|
55 | assert.equal(wav.bitsPerSample, 32); |
|
56 | }); |
|
57 | it("subChunk2Id should be 'data'", |
|
58 | function() { |
|
59 | assert.equal(wav.subChunk2Id, 'data'); |
|
60 | }); |
|
61 | it("subChunk2Size should be > 0", |
|
62 | function() { |
|
63 | assert.ok(wav.subChunk2Size > 0); |
|
64 | }); |
|
65 | it("samples.length should be > 0", |
|
66 | function() { |
|
67 | assert.ok(wav.samples_.length > 0); |
|
68 | }); |
|
69 | }); |
|
70 |
@@ 6-69 (lines=64) @@ | ||
3 | * |
|
4 | */ |
|
5 | ||
6 | let assert = require("assert"); |
|
7 | ||
8 | describe("16-bit reading", function() { |
|
9 | ||
10 | let fs = require("fs"); |
|
11 | let wavefile = require("../index.js"); |
|
12 | let path = "test/files/"; |
|
13 | ||
14 | let wBytes = fs.readFileSync(path + "16-bit-8kHz-noBext-mono.wav"); |
|
15 | let wav = new wavefile.WaveFile(wBytes); |
|
16 | ||
17 | it("chunkId should be 'RIFF'", |
|
18 | function() { |
|
19 | assert.equal(wav.chunkId, "RIFF"); |
|
20 | }); |
|
21 | it("subChunk1Id should be 'fmt '", |
|
22 | function() { |
|
23 | assert.equal(wav.subChunk1Id, "fmt "); |
|
24 | }); |
|
25 | it("format should be 'WAVE'", |
|
26 | function() { |
|
27 | assert.equal(wav.format, "WAVE"); |
|
28 | }); |
|
29 | it("subChunk1Size should be 16", |
|
30 | function() { |
|
31 | assert.equal(wav.subChunk1Size, 16); |
|
32 | }); |
|
33 | it("audioFormat should be 1 (PCM)", |
|
34 | function() { |
|
35 | assert.equal(wav.audioFormat, 1); |
|
36 | }); |
|
37 | it("numChannels should be 1", |
|
38 | function() { |
|
39 | assert.equal(wav.numChannels, 1); |
|
40 | }); |
|
41 | it("sampleRate should be 8000", |
|
42 | function() { |
|
43 | assert.equal(wav.sampleRate, 8000); |
|
44 | }); |
|
45 | it("byteRate be 16000", |
|
46 | function() { |
|
47 | assert.equal(wav.byteRate, 16000); |
|
48 | }); |
|
49 | it("blockAlign should be 2", |
|
50 | function() { |
|
51 | assert.equal(wav.blockAlign, 2); |
|
52 | }); |
|
53 | it("bitsPerSample should be 16", |
|
54 | function() { |
|
55 | assert.equal(wav.bitsPerSample, 16); |
|
56 | }); |
|
57 | it("subChunk2Id should be 'data'", |
|
58 | function() { |
|
59 | assert.equal(wav.subChunk2Id, 'data'); |
|
60 | }); |
|
61 | it("subChunk2Size should be > 0", |
|
62 | function() { |
|
63 | assert.ok(wav.subChunk2Size > 0); |
|
64 | }); |
|
65 | it("samples.length should be > 0", |
|
66 | function() { |
|
67 | assert.ok(wav.samples_.length > 0); |
|
68 | }); |
|
69 | }); |
|
70 |