|
@@ -5,38 +5,40 @@ var tape = require("tape"),
|
5
|
5
|
|
6
|
6
|
require("mkdirp").sync(path.join(__dirname, "tmp"));
|
7
|
7
|
|
8
|
|
-var getDuration = require("../audiogram/duration.js"),
|
|
8
|
+var probe = require("../audiogram/probe.js"),
|
9
|
9
|
trimAudio = require("../audiogram/trim.js");
|
10
|
10
|
|
11
|
|
-tape("MP3 duration", function(test) {
|
|
11
|
+tape("MP3 probe", function(test) {
|
12
|
12
|
|
13
|
|
- getDuration(path.join(__dirname, "data/glazed-donut.mp3"), function(err, duration){
|
|
13
|
+ probe(path.join(__dirname, "data/glazed-donut.mp3"), function(err, data){
|
14
|
14
|
|
15
|
15
|
test.error(err);
|
16
|
|
- test.equal(typeof duration, "number");
|
17
|
|
- test.assert(Math.abs(duration - 26.67) < 0.1);
|
|
16
|
+ test.equal(typeof data.duration, "number");
|
|
17
|
+ test.equal(data.channels, 2);
|
|
18
|
+ test.assert(Math.abs(data.duration - 26.67) < 0.1);
|
18
|
19
|
test.end();
|
19
|
20
|
|
20
|
21
|
});
|
21
|
22
|
|
22
|
23
|
});
|
23
|
24
|
|
24
|
|
-tape("WAV duration", function(test) {
|
|
25
|
+tape("WAV probe", function(test) {
|
25
|
26
|
|
26
|
|
- getDuration(path.join(__dirname, "data/glazed-donut.wav"), function(err, duration){
|
|
27
|
+ probe(path.join(__dirname, "data/glazed-donut.wav"), function(err, data){
|
27
|
28
|
|
28
|
29
|
test.error(err);
|
29
|
|
- test.equal(typeof duration, "number");
|
30
|
|
- test.assert(Math.abs(duration - 1.83) < 0.1);
|
|
30
|
+ test.equal(typeof data.duration, "number");
|
|
31
|
+ test.equal(data.channels, 2);
|
|
32
|
+ test.assert(Math.abs(data.duration - 1.83) < 0.1);
|
31
|
33
|
test.end();
|
32
|
34
|
|
33
|
35
|
});
|
34
|
36
|
|
35
|
37
|
});
|
36
|
38
|
|
37
|
|
-tape("Duration error", function(test) {
|
|
39
|
+tape("Probe error", function(test) {
|
38
|
40
|
|
39
|
|
- getDuration(path.join(__dirname, "..", "README.md"), function(err){
|
|
41
|
+ probe(path.join(__dirname, "..", "README.md"), function(err){
|
40
|
42
|
|
41
|
43
|
test.ok(err);
|
42
|
44
|
test.end();
|
|
@@ -55,12 +57,12 @@ tape("Trim start", function(test) {
|
55
|
57
|
|
56
|
58
|
queue(1)
|
57
|
59
|
.defer(trimAudio, options)
|
58
|
|
- .defer(getDuration, options.destination)
|
59
|
|
- .await(function(err, _, duration){
|
|
60
|
+ .defer(probe, options.destination)
|
|
61
|
+ .await(function(err, _, data){
|
60
|
62
|
|
61
|
63
|
test.error(err);
|
62
|
|
- test.equal(typeof duration, "number");
|
63
|
|
- test.assert(Math.abs(duration - 20) < 0.1);
|
|
64
|
+ test.equal(typeof data.duration, "number");
|
|
65
|
+ test.assert(Math.abs(data.duration - 20) < 0.1);
|
64
|
66
|
test.end();
|
65
|
67
|
|
66
|
68
|
});
|
|
@@ -77,12 +79,12 @@ tape("Trim end", function(test) {
|
77
|
79
|
|
78
|
80
|
queue(1)
|
79
|
81
|
.defer(trimAudio, options)
|
80
|
|
- .defer(getDuration, options.destination)
|
81
|
|
- .await(function(err, _, duration){
|
|
82
|
+ .defer(probe, options.destination)
|
|
83
|
+ .await(function(err, _, data){
|
82
|
84
|
|
83
|
85
|
test.error(err);
|
84
|
|
- test.equal(typeof duration, "number");
|
85
|
|
- test.assert(Math.abs(duration - 20) < 0.1);
|
|
86
|
+ test.equal(typeof data.duration, "number");
|
|
87
|
+ test.assert(Math.abs(data.duration - 20) < 0.1);
|
86
|
88
|
test.end();
|
87
|
89
|
|
88
|
90
|
});
|
|
@@ -100,12 +102,12 @@ tape("Trim start & end", function(test) {
|
100
|
102
|
|
101
|
103
|
queue(1)
|
102
|
104
|
.defer(trimAudio, options)
|
103
|
|
- .defer(getDuration, options.destination)
|
104
|
|
- .await(function(err, _, duration){
|
|
105
|
+ .defer(probe, options.destination)
|
|
106
|
+ .await(function(err, _, data){
|
105
|
107
|
|
106
|
108
|
test.error(err);
|
107
|
|
- test.equal(typeof duration, "number");
|
108
|
|
- test.assert(Math.abs(duration - 5) < 0.1);
|
|
109
|
+ test.equal(typeof data.duration, "number");
|
|
110
|
+ test.assert(Math.abs(data.duration - 5) < 0.1);
|
109
|
111
|
test.end();
|
110
|
112
|
|
111
|
113
|
});
|
|
@@ -122,25 +124,11 @@ tape("Trim invalid", function(test) {
|
122
|
124
|
endTime: 4
|
123
|
125
|
};
|
124
|
126
|
|
125
|
|
- queue(1)
|
126
|
|
- .defer(trimAudio, options)
|
127
|
|
- .defer(getDuration, options.destination)
|
128
|
|
- .await(function(err, _, duration){
|
129
|
|
-
|
130
|
|
- test.ok(err);
|
131
|
|
- test.end();
|
132
|
|
-
|
133
|
|
- });
|
134
|
|
-
|
135
|
|
-});
|
136
|
|
-
|
137
|
|
-// Cleanup
|
138
|
|
-tape.onFinish(function(){
|
139
|
|
- require("rimraf")(path.join(__dirname, "tmp"), function(err){
|
140
|
|
- if (err) {
|
141
|
|
- throw err;
|
142
|
|
- }
|
|
127
|
+ trimAudio(options, function(err){
|
|
128
|
+ test.ok(err);
|
|
129
|
+ test.end();
|
143
|
130
|
});
|
|
131
|
+
|
144
|
132
|
});
|
145
|
133
|
|
146
|
134
|
// Cleanup
|