1
|
|
|
/*! |
2
|
|
|
* Copyright (c) 2017 Rafael da Silva Rocha. |
3
|
|
|
* |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
View Code Duplication |
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
|
|
|
|