speaker-calibration 2.0.0 → 2.1.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.
Files changed (126) hide show
  1. package/.eslintignore +72 -0
  2. package/.eslintrc.json +40 -0
  3. package/.gitignore +78 -0
  4. package/.prettierignore +70 -0
  5. package/.prettierrc +15 -0
  6. package/LICENSE +20 -20
  7. package/README.md +133 -133
  8. package/__mocks__/fileMock.js +1 -0
  9. package/__mocks__/styleMock.js +1 -0
  10. package/babel.config.js +3 -0
  11. package/coverage/clover.xml +71 -0
  12. package/coverage/coverage-final.json +224 -0
  13. package/coverage/lcov-report/PythonServerInterface.js.html +265 -0
  14. package/coverage/lcov-report/base.css +354 -0
  15. package/coverage/lcov-report/block-navigation.js +82 -0
  16. package/coverage/lcov-report/favicon.png +0 -0
  17. package/coverage/lcov-report/index.html +123 -0
  18. package/coverage/lcov-report/prettify.css +101 -0
  19. package/coverage/lcov-report/prettify.js +937 -0
  20. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  21. package/coverage/lcov-report/sorter.js +189 -0
  22. package/coverage/lcov-report/src/index.html +121 -0
  23. package/coverage/lcov-report/src/server/PythonServerInterface.js.html +268 -0
  24. package/coverage/lcov-report/src/server/index.html +123 -0
  25. package/coverage/lcov-report/src/tasks/audioCalibrator.js.html +499 -0
  26. package/coverage/lcov-report/src/tasks/audioRecorder.js.html +412 -0
  27. package/coverage/lcov-report/src/tasks/index.html +143 -0
  28. package/coverage/lcov-report/src/tasks/volume/index.html +123 -0
  29. package/coverage/lcov-report/src/tasks/volume/volume.js.html +409 -0
  30. package/coverage/lcov-report/src/utils.js.html +172 -0
  31. package/coverage/lcov.info +91 -0
  32. package/dist/example/Queen-Bohemian_Rhapsody.wav +0 -0
  33. package/dist/example/Queen-Bohemian_Rhapsody_g_filtered.wav +0 -0
  34. package/dist/example/index.html +47 -0
  35. package/dist/example/listener.html +89 -0
  36. package/dist/example/server.js +49 -0
  37. package/dist/example/speaker.html +126 -0
  38. package/dist/example/speakerUI.js +217 -0
  39. package/dist/example/styles.css +40 -0
  40. package/dist/main.js +1 -1
  41. package/dist/mlsGen.js +6814 -6814
  42. package/dist/mlsGen.wasm +0 -0
  43. package/doc/AudioCalibrator.html +417 -0
  44. package/doc/AudioPeer.html +251 -0
  45. package/doc/AudioRecorder.html +195 -0
  46. package/doc/ImpulseResponse.html +215 -0
  47. package/doc/Listener.html +308 -0
  48. package/doc/MlsGenInterface.html +226 -0
  49. package/doc/MyEventEmitter.html +274 -0
  50. package/doc/PythonServerAPI.html +109 -0
  51. package/doc/Speaker-Calibration-UML-Diagram.png +0 -0
  52. package/doc/Speaker.html +276 -0
  53. package/doc/Takes%20a%20target%20element%20where%20html%20elements%20will%20be%20appended..html +128 -0
  54. package/doc/Takes%20the%20url%20of%20the%20current%20site%0Aand%20a%20target%20element%20where%20html%20elements%20will%20be%20appended..html +138 -0
  55. package/doc/Takes%20the%20url%20of%20the%20current%20site%20and%20a%20target%20element%20where%20html%20elements%20will%20be%20appended..html +137 -0
  56. package/doc/Volume.html +88 -0
  57. package/doc/audioCalibrator.js.html +179 -0
  58. package/doc/audioPeer.js.html +175 -0
  59. package/doc/audioRecorder.js.html +163 -0
  60. package/doc/creates%20a%20new%20AudioRecorder%20instance.%20%0ASets%20up%20the%20audio%20context%20and%20file%20reader..html +114 -0
  61. package/doc/fonts/OpenSans-Bold-webfont.eot +0 -0
  62. package/doc/fonts/OpenSans-Bold-webfont.svg +1830 -0
  63. package/doc/fonts/OpenSans-Bold-webfont.woff +0 -0
  64. package/doc/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  65. package/doc/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
  66. package/doc/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  67. package/doc/fonts/OpenSans-Italic-webfont.eot +0 -0
  68. package/doc/fonts/OpenSans-Italic-webfont.svg +1830 -0
  69. package/doc/fonts/OpenSans-Italic-webfont.woff +0 -0
  70. package/doc/fonts/OpenSans-Light-webfont.eot +0 -0
  71. package/doc/fonts/OpenSans-Light-webfont.svg +1831 -0
  72. package/doc/fonts/OpenSans-Light-webfont.woff +0 -0
  73. package/doc/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  74. package/doc/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
  75. package/doc/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  76. package/doc/fonts/OpenSans-Regular-webfont.eot +0 -0
  77. package/doc/fonts/OpenSans-Regular-webfont.svg +1831 -0
  78. package/doc/fonts/OpenSans-Regular-webfont.woff +0 -0
  79. package/doc/global.html +308 -0
  80. package/doc/index.html +58 -0
  81. package/doc/listener.js.html +170 -0
  82. package/doc/mlsGen_mlsGenInterface.js.html +117 -0
  83. package/doc/myEventEmitter.js.html +124 -0
  84. package/doc/peer-connection_audioPeer.js.html +188 -0
  85. package/doc/peer-connection_listener.js.html +311 -0
  86. package/doc/peer-connection_speaker.js.html +381 -0
  87. package/doc/sc-activity-diagram.png +0 -0
  88. package/doc/scripts/linenumber.js +25 -0
  89. package/doc/scripts/prettify/Apache-License-2.0.txt +202 -0
  90. package/doc/scripts/prettify/lang-css.js +24 -0
  91. package/doc/scripts/prettify/prettify.js +640 -0
  92. package/doc/server_PythonServerAPI.js.html +160 -0
  93. package/doc/speaker.js.html +248 -0
  94. package/doc/styles/jsdoc-default.css +371 -0
  95. package/doc/styles/prettify-jsdoc.css +111 -0
  96. package/doc/styles/prettify-tomorrow.css +163 -0
  97. package/doc/tasks_audioCalibrator.js.html +207 -0
  98. package/doc/tasks_audioRecorder.js.html +190 -0
  99. package/doc/tasks_impulse-response_impulseResponse.js.html +442 -0
  100. package/doc/tasks_impulse-response_mlsGen_mlsGenInterface.js.html +175 -0
  101. package/doc/tasks_volume_volume.js.html +185 -0
  102. package/doc/utils.js.html +105 -0
  103. package/jest.config.js +173 -0
  104. package/netlify.toml +27 -0
  105. package/package.json +67 -66
  106. package/src/index.html +21 -0
  107. package/src/main.js +21 -0
  108. package/src/myEventEmitter.js +83 -0
  109. package/src/peer-connection/audioPeer.js +151 -0
  110. package/src/peer-connection/listener.js +251 -0
  111. package/src/peer-connection/peerErrors.js +25 -0
  112. package/src/peer-connection/speaker.js +346 -0
  113. package/src/server/PythonServerAPI.js +117 -0
  114. package/src/tasks/audioCalibrator.js +218 -0
  115. package/src/tasks/audioRecorder.js +148 -0
  116. package/src/tasks/impulse-response/impulseResponse.js +436 -0
  117. package/src/tasks/impulse-response/mlsGen/mlsGen.cpp +99 -0
  118. package/src/tasks/impulse-response/mlsGen/mlsGen.hpp +304 -0
  119. package/src/tasks/impulse-response/mlsGen/mlsGenInterface.js +131 -0
  120. package/src/tasks/impulse-response/mlsGen/mlsGenTest.cpp +181 -0
  121. package/src/tasks/volume/volume.cpp +3 -0
  122. package/src/tasks/volume/volume.hpp +23 -0
  123. package/src/tasks/volume/volume.js +157 -0
  124. package/src/utils.js +55 -0
  125. package/webpack.config.js +37 -0
  126. package/README +0 -3
@@ -0,0 +1,308 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>JSDoc: Global</title>
6
+
7
+ <script src="scripts/prettify/prettify.js"></script>
8
+ <script src="scripts/prettify/lang-css.js"></script>
9
+ <!--[if lt IE 9]>
10
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
+ <![endif]-->
12
+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css" />
13
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css" />
14
+ </head>
15
+
16
+ <body>
17
+ <div id="main">
18
+ <h1 class="page-title">Global</h1>
19
+
20
+ <section>
21
+ <header>
22
+ <h2></h2>
23
+ </header>
24
+
25
+ <article>
26
+ <div class="container-overview">
27
+ <dl class="details"></dl>
28
+ </div>
29
+
30
+ <h3 class="subsection-title">Methods</h3>
31
+
32
+ <h4 class="name" id="csvToArray">
33
+ <span class="type-signature"></span>csvToArray<span class="signature"
34
+ >(csvString, delimiter)</span
35
+ ><span class="type-signature"></span>
36
+ </h4>
37
+
38
+ <div class="description">Utility function to create a buffer from a CSV file</div>
39
+
40
+ <h5>Parameters:</h5>
41
+
42
+ <table class="params">
43
+ <thead>
44
+ <tr>
45
+ <th>Name</th>
46
+
47
+ <th>Type</th>
48
+
49
+ <th>Default</th>
50
+
51
+ <th class="last">Description</th>
52
+ </tr>
53
+ </thead>
54
+
55
+ <tbody>
56
+ <tr>
57
+ <td class="name"><code>csvString</code></td>
58
+
59
+ <td class="type">
60
+ <span class="param-type">*</span>
61
+ </td>
62
+
63
+ <td class="default"></td>
64
+
65
+ <td class="description last"></td>
66
+ </tr>
67
+
68
+ <tr>
69
+ <td class="name"><code>delimiter</code></td>
70
+
71
+ <td class="type">
72
+ <span class="param-type">*</span>
73
+ </td>
74
+
75
+ <td class="default">,</td>
76
+
77
+ <td class="description last"></td>
78
+ </tr>
79
+ </tbody>
80
+ </table>
81
+
82
+ <dl class="details">
83
+ <dt class="tag-source">Source:</dt>
84
+ <dd class="tag-source">
85
+ <ul class="dummy">
86
+ <li>
87
+ <a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line37">line 37</a>
88
+ </li>
89
+ </ul>
90
+ </dd>
91
+ </dl>
92
+
93
+ <h5>Returns:</h5>
94
+
95
+ <h4 class="name" id="saveToCSV">
96
+ <span class="type-signature"></span>saveToCSV<span class="signature"
97
+ >(data, filename)</span
98
+ ><span class="type-signature"></span>
99
+ </h4>
100
+
101
+ <div class="description">
102
+ Uiltity function to create and save a CSV file from a buffer
103
+ </div>
104
+
105
+ <h5>Parameters:</h5>
106
+
107
+ <table class="params">
108
+ <thead>
109
+ <tr>
110
+ <th>Name</th>
111
+
112
+ <th>Type</th>
113
+
114
+ <th>Default</th>
115
+
116
+ <th class="last">Description</th>
117
+ </tr>
118
+ </thead>
119
+
120
+ <tbody>
121
+ <tr>
122
+ <td class="name"><code>data</code></td>
123
+
124
+ <td class="type">
125
+ <span class="param-type">*</span>
126
+ </td>
127
+
128
+ <td class="default"></td>
129
+
130
+ <td class="description last"></td>
131
+ </tr>
132
+
133
+ <tr>
134
+ <td class="name"><code>filename</code></td>
135
+
136
+ <td class="type">
137
+ <span class="param-type">*</span>
138
+ </td>
139
+
140
+ <td class="default">recordedMLSignal.csv</td>
141
+
142
+ <td class="description last"></td>
143
+ </tr>
144
+ </tbody>
145
+ </table>
146
+
147
+ <dl class="details">
148
+ <dt class="tag-source">Source:</dt>
149
+ <dd class="tag-source">
150
+ <ul class="dummy">
151
+ <li>
152
+ <a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line16">line 16</a>
153
+ </li>
154
+ </ul>
155
+ </dd>
156
+ </dl>
157
+
158
+ <h4 class="name" id="sleep">
159
+ <span class="type-signature"></span>sleep<span class="signature">(seconds)</span
160
+ ><span class="type-signature"> &rarr; {Promise}</span>
161
+ </h4>
162
+
163
+ <div class="description">Utlity function to pause execution for a given time</div>
164
+
165
+ <h5>Parameters:</h5>
166
+
167
+ <table class="params">
168
+ <thead>
169
+ <tr>
170
+ <th>Name</th>
171
+
172
+ <th>Type</th>
173
+
174
+ <th class="last">Description</th>
175
+ </tr>
176
+ </thead>
177
+
178
+ <tbody>
179
+ <tr>
180
+ <td class="name"><code>seconds</code></td>
181
+
182
+ <td class="type">
183
+ <span class="param-type">number</span>
184
+ </td>
185
+
186
+ <td class="description last"></td>
187
+ </tr>
188
+ </tbody>
189
+ </table>
190
+
191
+ <dl class="details">
192
+ <dt class="tag-source">Source:</dt>
193
+ <dd class="tag-source">
194
+ <ul class="dummy">
195
+ <li>
196
+ <a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line6">line 6</a>
197
+ </li>
198
+ </ul>
199
+ </dd>
200
+ </dl>
201
+
202
+ <h5>Returns:</h5>
203
+
204
+ <dl>
205
+ <dt>Type</dt>
206
+ <dd>
207
+ <span class="param-type">Promise</span>
208
+ </dd>
209
+ </dl>
210
+
211
+ <h3 class="subsection-title">Type Definitions</h3>
212
+
213
+ <h4 class="name" id="initParameters">initParameters</h4>
214
+
215
+ <h5>Type:</h5>
216
+ <ul>
217
+ <li>
218
+ <span class="param-type">object</span>
219
+ </li>
220
+ </ul>
221
+
222
+ <h5 class="subsection-title">Properties:</h5>
223
+
224
+ <table class="props">
225
+ <thead>
226
+ <tr>
227
+ <th>Name</th>
228
+
229
+ <th>Type</th>
230
+
231
+ <th class="last">Description</th>
232
+ </tr>
233
+ </thead>
234
+
235
+ <tbody>
236
+ <tr>
237
+ <td class="name"><code>targetElementId</code></td>
238
+
239
+ <td class="type">
240
+ <span class="param-type">string</span>
241
+ </td>
242
+
243
+ <td class="description last">target element where new elements will be appended</td>
244
+ </tr>
245
+
246
+ <tr>
247
+ <td class="name"><code>siteUrl:</code></td>
248
+
249
+ <td class="type">
250
+ <span class="param-type">string</span>
251
+ </td>
252
+
253
+ <td class="description last">the url of the current site</td>
254
+ </tr>
255
+ </tbody>
256
+ </table>
257
+
258
+ <dl class="details">
259
+ <dt class="tag-source">Source:</dt>
260
+ <dd class="tag-source">
261
+ <ul class="dummy">
262
+ <li>
263
+ <a href="peer-connection_audioPeer.js.html">peer-connection/audioPeer.js</a>,
264
+ <a href="peer-connection_audioPeer.js.html#line7">line 7</a>
265
+ </li>
266
+ </ul>
267
+ </dd>
268
+ </dl>
269
+ </article>
270
+ </section>
271
+ </div>
272
+
273
+ <nav>
274
+ <h2><a href="index.html">Home</a></h2>
275
+ <h3>Classes</h3>
276
+ <ul>
277
+ <li><a href="AudioCalibrator.html">AudioCalibrator</a></li>
278
+ <li><a href="AudioPeer.html">AudioPeer</a></li>
279
+ <li><a href="AudioRecorder.html">AudioRecorder</a></li>
280
+ <li><a href="ImpulseResponse.html">ImpulseResponse</a></li>
281
+ <li><a href="Listener.html">Listener</a></li>
282
+ <li><a href="MlsGenInterface.html">MlsGenInterface</a></li>
283
+ <li><a href="MyEventEmitter.html">MyEventEmitter</a></li>
284
+ <li><a href="PythonServerAPI.html">PythonServerAPI</a></li>
285
+ <li><a href="Speaker.html">Speaker</a></li>
286
+ <li><a href="Volume.html">Volume</a></li>
287
+ </ul>
288
+ <h3>Global</h3>
289
+ <ul>
290
+ <li><a href="global.html#csvToArray">csvToArray</a></li>
291
+ <li><a href="global.html#saveToCSV">saveToCSV</a></li>
292
+ <li><a href="global.html#sleep">sleep</a></li>
293
+ </ul>
294
+ </nav>
295
+
296
+ <br class="clear" />
297
+
298
+ <footer>
299
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Fri
300
+ Jul 29 2022 15:09:48 GMT-0400 (Eastern Daylight Time)
301
+ </footer>
302
+
303
+ <script>
304
+ prettyPrint();
305
+ </script>
306
+ <script src="scripts/linenumber.js"></script>
307
+ </body>
308
+ </html>
package/doc/index.html ADDED
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>JSDoc: Home</title>
6
+
7
+ <script src="scripts/prettify/prettify.js"></script>
8
+ <script src="scripts/prettify/lang-css.js"></script>
9
+ <!--[if lt IE 9]>
10
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
+ <![endif]-->
12
+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css" />
13
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css" />
14
+ </head>
15
+
16
+ <body>
17
+ <div id="main">
18
+ <h1 class="page-title">Home</h1>
19
+
20
+ <h3></h3>
21
+ </div>
22
+
23
+ <nav>
24
+ <h2><a href="index.html">Home</a></h2>
25
+ <h3>Classes</h3>
26
+ <ul>
27
+ <li><a href="AudioCalibrator.html">AudioCalibrator</a></li>
28
+ <li><a href="AudioPeer.html">AudioPeer</a></li>
29
+ <li><a href="AudioRecorder.html">AudioRecorder</a></li>
30
+ <li><a href="ImpulseResponse.html">ImpulseResponse</a></li>
31
+ <li><a href="Listener.html">Listener</a></li>
32
+ <li><a href="MlsGenInterface.html">MlsGenInterface</a></li>
33
+ <li><a href="MyEventEmitter.html">MyEventEmitter</a></li>
34
+ <li><a href="PythonServerAPI.html">PythonServerAPI</a></li>
35
+ <li><a href="Speaker.html">Speaker</a></li>
36
+ <li><a href="Volume.html">Volume</a></li>
37
+ </ul>
38
+ <h3>Global</h3>
39
+ <ul>
40
+ <li><a href="global.html#csvToArray">csvToArray</a></li>
41
+ <li><a href="global.html#saveToCSV">saveToCSV</a></li>
42
+ <li><a href="global.html#sleep">sleep</a></li>
43
+ </ul>
44
+ </nav>
45
+
46
+ <br class="clear" />
47
+
48
+ <footer>
49
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Fri
50
+ Jul 29 2022 15:09:48 GMT-0400 (Eastern Daylight Time)
51
+ </footer>
52
+
53
+ <script>
54
+ prettyPrint();
55
+ </script>
56
+ <script src="scripts/linenumber.js"></script>
57
+ </body>
58
+ </html>
@@ -0,0 +1,170 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>JSDoc: Source: listener.js</title>
6
+
7
+ <script src="scripts/prettify/prettify.js"></script>
8
+ <script src="scripts/prettify/lang-css.js"></script>
9
+ <!--[if lt IE 9]>
10
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
+ <![endif]-->
12
+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css" />
13
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css" />
14
+ </head>
15
+
16
+ <body>
17
+ <div id="main">
18
+ <h1 class="page-title">Source: listener.js</h1>
19
+
20
+ <section>
21
+ <article>
22
+ <pre class="prettyprint source linenums"><code>import './listener.css';
23
+ import AudioPeer from './audioPeer';
24
+
25
+ /**
26
+ * @class Handles the listener's side of the connection. Responsible for getting access to user's microphone,
27
+ * and initiating a call to the Speaker.
28
+ * @extends AudioPeer
29
+ */
30
+ class Listener extends AudioPeer {
31
+ /**
32
+ * Takes a target element where html elements will be appended.
33
+ * @param {initParameters} params - see type definition for initParameters
34
+ */
35
+ constructor(params) {
36
+ super(params);
37
+
38
+ this.startTime = Date.now();
39
+ this.receiverPeerId = null;
40
+
41
+ const urlParameters = this.parseURLSearchParams();
42
+ this.speakerPeerId = urlParameters.speakerPeerId;
43
+
44
+ this.peer.on('open', this.onPeerOpen);
45
+ this.peer.on('connection', this.onPeerConnection);
46
+ this.peer.on('disconnected', this.onPeerDisconnected);
47
+ this.peer.on('close', this.onPeerClose);
48
+ this.peer.on('error', this.onPeerError);
49
+ }
50
+
51
+ onPeerOpen = id => {
52
+ console.log('Listener - onPeerOpen');
53
+ // Workaround for peer.reconnect deleting previous id
54
+ if (id === null) {
55
+ console.log('Received null id from peer open');
56
+ this.peer.id = this.lastPeerId;
57
+ } else {
58
+ this.lastPeerId = this.peer.id;
59
+ }
60
+ this.join();
61
+ };
62
+
63
+ onPeerConnection = connection => {
64
+ console.log('Listener - onPeerConnection');
65
+ // Disallow incoming connections
66
+ connection.on('open', () => {
67
+ connection.send('Sender does not accept incoming connections');
68
+ setTimeout(() => {
69
+ connection.close();
70
+ }, 500);
71
+ });
72
+ };
73
+
74
+ onConnData = data => {
75
+ console.log('Listener - onConnData');
76
+ // Keypad has received data, namely instructions to update the keypad
77
+ // TODO generalize to a list of properies
78
+ const hasSpeakerID = Object.prototype.hasOwnProperty.call(data, 'speakerPeerId');
79
+ if (!hasSpeakerID) {
80
+ console.error('Error in parsing data received! Must set "speakerPeerId" properties');
81
+ } else {
82
+ // this.conn.close();
83
+ console.log(this.speakerPeerId);
84
+ this.speakerPeerId = data.speakerPeerId;
85
+ const newParams = {
86
+ speakerPeerId: this.speakerPeerId,
87
+ };
88
+ /*
89
+ FUTURE does this limit usable environments?
90
+ ie does this work if internet is lost after initial page load?
91
+ */
92
+ window.location.search = this.queryStringFromObject(newParams); // Redirect to correctly constructed keypad page
93
+ }
94
+ };
95
+
96
+ join = () => {
97
+ console.log('Listener - join');
98
+ /**
99
+ * Create the connection between the two Peers.
100
+ *
101
+ * Sets up callbacks that handle any events related to the
102
+ * connection and data received on it.
103
+ */
104
+ // Close old connection
105
+ if (this.conn) {
106
+ this.conn.close();
107
+ }
108
+ // Create connection to destination peer specified by the query param
109
+ this.conn = this.peer.connect(this.speakerPeerId, {
110
+ reliable: true,
111
+ });
112
+
113
+ this.conn.on('open', () => {
114
+ // console.log("TODO Implement real on connection fn");
115
+ this.openAudioStream();
116
+ });
117
+
118
+ // Handle incoming data (messages only since this is the signal sender)
119
+ this.conn.on('data', this.onConnData);
120
+ this.conn.on('close', () => {
121
+ console.log('Connection closed');
122
+ });
123
+ };
124
+
125
+ openAudioStream = async () => {
126
+ navigator.mediaDevices
127
+ .getUserMedia({video: false, audio: true})
128
+ .then(stream => {
129
+ this.peer.call(this.speakerPeerId, stream); // one-way call
130
+ console.log('Listener - openAudioStream');
131
+ })
132
+ .catch(err => {
133
+ console.log(`u got an error:${err}`);
134
+ });
135
+ };
136
+ }
137
+
138
+ export default Listener;
139
+ </code></pre>
140
+ </article>
141
+ </section>
142
+ </div>
143
+
144
+ <nav>
145
+ <h2><a href="index.html">Home</a></h2>
146
+ <h3>Classes</h3>
147
+ <ul>
148
+ <li><a href="AudioCalibrator.html">AudioCalibrator</a></li>
149
+ <li><a href="AudioPeer.html">AudioPeer</a></li>
150
+ <li><a href="AudioRecorder.html">AudioRecorder</a></li>
151
+ <li><a href="Listener.html">Listener</a></li>
152
+ <li><a href="MlsGenInterface.html">MlsGenInterface</a></li>
153
+ <li><a href="Speaker.html">Speaker</a></li>
154
+ </ul>
155
+ <h3><a href="global.html">Global</a></h3>
156
+ </nav>
157
+
158
+ <br class="clear" />
159
+
160
+ <footer>
161
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Tue
162
+ Mar 01 2022 12:39:42 GMT-0500 (Eastern Standard Time)
163
+ </footer>
164
+
165
+ <script>
166
+ prettyPrint();
167
+ </script>
168
+ <script src="scripts/linenumber.js"></script>
169
+ </body>
170
+ </html>
@@ -0,0 +1,117 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>JSDoc: Source: mlsGen/mlsGenInterface.js</title>
6
+
7
+ <script src="scripts/prettify/prettify.js"></script>
8
+ <script src="scripts/prettify/lang-css.js"></script>
9
+ <!--[if lt IE 9]>
10
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
+ <![endif]-->
12
+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css" />
13
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css" />
14
+ </head>
15
+
16
+ <body>
17
+ <div id="main">
18
+ <h1 class="page-title">Source: mlsGen/mlsGenInterface.js</h1>
19
+
20
+ <section>
21
+ <article>
22
+ <pre
23
+ class="prettyprint source linenums"
24
+ ><code>// eslint-disable-next-line import/extensions
25
+ const createMLSGenModule = require('../../dist/mlsGen.js');
26
+
27
+ /**
28
+ * MLSGenInterface provides a class for interfacing with the MLSGen WASM module.
29
+ */
30
+ class MlsGenInterface {
31
+ /** @private */
32
+ #N = 18;
33
+
34
+ /** @private */
35
+ // eslint-disable-next-line no-bitwise
36
+ #P = (1 &lt;&lt; 18) - 1;
37
+
38
+ /** @private */
39
+ #MLSGen;
40
+
41
+ /** @private */
42
+ #WASMInstance;
43
+
44
+ /**
45
+ * Creates an instance of MlsGenInterface.
46
+ * Makes a call to the WASM glue code to load the WASM module.
47
+ */
48
+ constructor() {
49
+ // load the WASM module and save the instance.
50
+ createMLSGenModule().then((instance) => {
51
+ this.#WASMInstance = instance;
52
+ this.#MLSGen = new instance.MLSGen(this.N);
53
+ console.log(this.#MLSGen);
54
+ });
55
+ }
56
+
57
+ /*
58
+ TODO: Figure out the best way to interact with this module.
59
+ 1. Return the MLS signal (as an array), appears problematic with the pointer bindings
60
+ 2. Pass a buffer to the function to be filled with the MLS, I did this before but need
61
+ to go back and look at how it was done. Currently throwing an error.
62
+ 3. Circumvent this all together by calling the webAudio API in the CPP code directly.
63
+ */
64
+ getMls = () => {
65
+ /**
66
+ * Calculate the Maximum Length Sequence (MLS) with period P = 2^N - 1
67
+ * using the MLSGen WASM module.
68
+ * @param {Number} N
69
+ */
70
+ // Get function.
71
+ const { HEAPU8 } = this.#WASMInstance;
72
+
73
+ // Create the arrays.
74
+ // eslint-disable-next-line no-bitwise
75
+ const offset = 0;
76
+ const result = new Uint8Array(HEAPU8.buffer, offset, this.#P);
77
+
78
+ // Call the function.
79
+ this.#MLSGen.getMls(result.byteOffset, this.#N, this.#P);
80
+
81
+ console.log(result);
82
+ }
83
+ }
84
+
85
+ export default MlsGenInterface;
86
+ </code></pre>
87
+ </article>
88
+ </section>
89
+ </div>
90
+
91
+ <nav>
92
+ <h2><a href="index.html">Home</a></h2>
93
+ <h3>Classes</h3>
94
+ <ul>
95
+ <li><a href="AudioCalibrator.html">AudioCalibrator</a></li>
96
+ <li><a href="AudioPeer.html">AudioPeer</a></li>
97
+ <li><a href="AudioRecorder.html">AudioRecorder</a></li>
98
+ <li><a href="Listener.html">Listener</a></li>
99
+ <li><a href="MlsGenInterface.html">MlsGenInterface</a></li>
100
+ <li><a href="Speaker.html">Speaker</a></li>
101
+ </ul>
102
+ <h3><a href="global.html">Global</a></h3>
103
+ </nav>
104
+
105
+ <br class="clear" />
106
+
107
+ <footer>
108
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Tue
109
+ Mar 01 2022 12:39:42 GMT-0500 (Eastern Standard Time)
110
+ </footer>
111
+
112
+ <script>
113
+ prettyPrint();
114
+ </script>
115
+ <script src="scripts/linenumber.js"></script>
116
+ </body>
117
+ </html>