tone-stream 1.4.4 → 1.5.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.
@@ -1,51 +1,28 @@
1
1
  const { ToneStream } = require('../index.js')
2
- const goertzel = require('goertzel-stream')
3
-
4
- const {PassThrough} = require('stream')
5
-
6
- const sampleRate = 8000
2
+ const DtmfDetectionStream = require('dtmf-detection-stream')
7
3
 
8
4
  const format = {
9
- sampleRate: sampleRate,
10
- bitDepth: 16,
11
- channels: 1,
5
+ sampleRate: 8000,
6
+ bitDepth: 16,
7
+ channels: 1,
12
8
  }
13
9
 
14
10
  const ts = new ToneStream(format)
15
-
16
- var notes = [
17
- //[2000, 'DTMF:#'],
18
- [2000, 697],
19
- [1000, 's'],
20
- /*
21
- [2000, 770],
22
- [1000, 's'],
23
- [2000, 852],
24
- [1000, 's'],
25
- */
26
- ]
27
-
28
- ts.concat(notes)
29
-
30
- var detector = goertzel([697, 770, 852, 941, 1209, 1336, 1477, 1633], {
31
- sampleRate: sampleRate,
32
- })
33
-
34
- // adding PassThrough stream to check data in the pipe
35
- const pt = new PassThrough()
36
-
37
- pt.on('data', data => {
38
- console.log(data.length, data)
39
- })
40
-
41
- ts.pipe(pt)
42
- pt.pipe(detector)
43
-
44
- detector.on('toneStart', function (tones) {
45
- console.log('start', tones)
11
+ ts.add([800, 's']) // silence
12
+ ts.add([800, 'DTMF:1'])
13
+ ts.add([800, 's']) // silence
14
+ ts.add([800, 'DTMF:2'])
15
+ ts.add([800, 's']) // silence
16
+ ts.add([800, 'DTMF:3'])
17
+ ts.add([800, 's']) // silence
18
+
19
+ const dds = new DtmfDetectionStream(format)
20
+
21
+ dds.on('dtmf', data => {
22
+ console.log('Got', data)
46
23
  })
47
24
 
48
- detector.on('toneEnd', function (tones) {
49
- console.log('end', tones)
25
+ ts.on('data', data => {
26
+ dds.write(data)
50
27
  })
51
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tone-stream",
3
- "version": "1.4.4",
3
+ "version": "1.5.0",
4
4
  "description": "A simple audio tone stream library",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -21,11 +21,11 @@
21
21
  "author": "MayamaTakeshi",
22
22
  "license": "MIT",
23
23
  "devDependencies": {
24
- "goertzel-stream": "git+https://github.com/MayamaTakeshi/goertzel-stream.git",
25
24
  "lodash": "^4.17.21",
26
25
  "speaker": "^0.5.1"
27
26
  },
28
27
  "dependencies": {
28
+ "dtmf-detection-stream": "^1.10.0",
29
29
  "morse-node": "^0.1.1",
30
30
  "note-to-frequency": "^1.4.1",
31
31
  "spec-read-stream": "^1.2.0",