tone-stream 1.11.1 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/index.js +1 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -116,7 +116,7 @@ const ts = new ToneStream(format)
|
|
|
116
116
|
const s = new Speaker(format)
|
|
117
117
|
|
|
118
118
|
const tones = _.flatten([
|
|
119
|
-
utils.gen_dtmf_tones("1234567890abcdef", 100,
|
|
119
|
+
utils.gen_dtmf_tones("1234567890abcdef", 100, 100, SAMPLE_RATE),
|
|
120
120
|
utils.gen_morse_tones("Be yourself; everyone else is already taken", 880, 70, SAMPLE_RATE),
|
|
121
121
|
utils.gen_music_scale("C5 D5 E5 F5 G5 A5 B5 C6", 100, 0, SAMPLE_RATE),
|
|
122
122
|
])
|
package/index.js
CHANGED
|
@@ -27,14 +27,11 @@ class ToneStream extends Readable {
|
|
|
27
27
|
|
|
28
28
|
this.currentSample = 0;
|
|
29
29
|
|
|
30
|
-
this.pending_ended = false;
|
|
31
|
-
|
|
32
30
|
this.eventEmitter = new EventEmitter();
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
add(spec) {
|
|
36
34
|
this.specReadStream.add(spec);
|
|
37
|
-
this.pending_ended = true
|
|
38
35
|
var num_samples = spec[0]
|
|
39
36
|
return num_samples
|
|
40
37
|
}
|
|
@@ -45,7 +42,6 @@ class ToneStream extends Readable {
|
|
|
45
42
|
this.specReadStream.add(spec);
|
|
46
43
|
num_samples += spec[0]
|
|
47
44
|
});
|
|
48
|
-
this.pending_ended = true
|
|
49
45
|
return num_samples
|
|
50
46
|
}
|
|
51
47
|
|
|
@@ -54,7 +50,7 @@ class ToneStream extends Readable {
|
|
|
54
50
|
|
|
55
51
|
if (evt == "empty") {
|
|
56
52
|
this.specReadStream.on(evt, cb);
|
|
57
|
-
} else
|
|
53
|
+
} else {
|
|
58
54
|
this.eventEmitter.on(evt, cb);
|
|
59
55
|
}
|
|
60
56
|
}
|
|
@@ -79,11 +75,6 @@ class ToneStream extends Readable {
|
|
|
79
75
|
var buf_idx = 0;
|
|
80
76
|
|
|
81
77
|
if (!specs) {
|
|
82
|
-
if(this.pending_ended) {
|
|
83
|
-
this.pending_ended = false
|
|
84
|
-
this.eventEmitter.emit("ended")
|
|
85
|
-
}
|
|
86
|
-
|
|
87
78
|
for (var j = 0; j < numSamples * this.channels; j++) {
|
|
88
79
|
let offset = j * sampleSize * this.channels;
|
|
89
80
|
setter(0, offset);
|