-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmaster.js
43 lines (34 loc) · 887 Bytes
/
master.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const Track = require('./track')
class Premaster extends Track {
constructor(source, opts={}) {
super(source, opts)
if (opts.version) {
this.version = opts.version
}
}
}
class Master extends Track {
constructor(source, opts={}) {
super(source, opts)
this.revision = null
this.parent = null
if (opts.parent) {
if (opts.parent instanceof Track) {
this.parent = opts.parent
} else {
throw new Error(`Invalid opts.parent: must be an instance of bap.Track`)
}
}
if (this.revision) {
this.revision = revision
}
}
compare (cb) {
if (!this.parent) cb(new Error(`No parent, add one to the Master first.`))
return {
peak: this.stats.peak.db - this.parent.stats.peak.db,
rms: this.stats.rms.db - this.parent.stats.rms.db,
}
}
}
module.exports = { Master, Premaster }