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,185 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>JSDoc: Source: tasks/volume/volume.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: tasks/volume/volume.js</h1>
19
+
20
+ <section>
21
+ <article>
22
+ <pre
23
+ class="prettyprint source linenums"
24
+ ><code>import AudioCalibrator from '../audioCalibrator';
25
+
26
+ import {sleep} from '../../utils';
27
+
28
+ /**
29
+ *
30
+ */
31
+ class Volume extends AudioCalibrator {
32
+ /**
33
+ *
34
+ */
35
+ constructor({download = false, numCalibrationRounds = 1, numCalibrationNodes = 1}) {
36
+ super(numCalibrationRounds, numCalibrationNodes);
37
+ }
38
+
39
+ /** @private */
40
+ #CALIBRATION_TONE_FREQUENCY = 1000; // Hz
41
+
42
+ /** @private */
43
+ #CALIBRATION_TONE_TYPE = 'sine';
44
+
45
+ /** @private */
46
+ #CALIBRATION_TONE_DURATION = 5; // seconds
47
+
48
+ /** @private */
49
+ soundGainDBSPL = null;
50
+
51
+ handleIncomingData = data => {
52
+ console.log('Received data: ', data);
53
+ if (data.type === 'soundGainDBSPL') {
54
+ this.soundGainDBSPL = data.value;
55
+ } else {
56
+ throw new Error(`Unknown data type: ${data.type}`);
57
+ }
58
+ };
59
+
60
+ #getTruncatedSignal = (left = 3.5, right = 4.5) => {
61
+ const start = Math.floor(left * this.sourceSamplingRate);
62
+ const end = Math.floor(right * this.sourceSamplingRate);
63
+ const result = Array.from(this.getLastRecordedSignal().slice(start, end));
64
+ const checkResult = list => {
65
+ const setItem = new Set(list);
66
+ if (setItem.size === 1 &amp;&amp; setItem.has(0)) {
67
+ console.warn(
68
+ 'The last capture failed, all recorded signal is zero',
69
+ this.getAllRecordedSignals()
70
+ );
71
+ }
72
+ if (setItem.size === 0) {
73
+ console.warn('The last capture failed, no recorded signal');
74
+ }
75
+ };
76
+ checkResult(result);
77
+ return result;
78
+ };
79
+
80
+ /**
81
+ * Construct a Calibration Node with the calibration parameters.
82
+ * @private
83
+ */
84
+ #createCalibrationNode = () => {
85
+ const audioContext = this.makeNewSourceAudioContext();
86
+ const oscilator = audioContext.createOscillator();
87
+ const gainNode = audioContext.createGain();
88
+
89
+ oscilator.frequency.value = this.#CALIBRATION_TONE_FREQUENCY;
90
+ oscilator.type = this.#CALIBRATION_TONE_TYPE;
91
+ gainNode.gain.value = 0.04;
92
+
93
+ oscilator.connect(gainNode);
94
+ gainNode.connect(audioContext.destination);
95
+
96
+ this.addCalibrationNode(oscilator);
97
+ };
98
+
99
+ #playCalibrationAudio = async () => {
100
+ const actualDuration = this.#CALIBRATION_TONE_DURATION * this.numCalibrationNodes;
101
+ const totalDuration = actualDuration * 1.2;
102
+ for (let i = 0; i &lt; this.calibrationNodes.length; i += 1) {
103
+ this.calibrationNodes[i].start(i * this.#CALIBRATION_TONE_DURATION);
104
+ this.calibrationNodes[i].stop(
105
+ i * this.#CALIBRATION_TONE_DURATION + this.#CALIBRATION_TONE_DURATION
106
+ );
107
+ }
108
+ console.log(`Playing a buffer of ${actualDuration} seconds of audio`);
109
+ console.log(`Waiting a total of ${totalDuration} seconds`);
110
+ await sleep(totalDuration);
111
+ };
112
+
113
+ #sendToServerForProcessing = () => {
114
+ console.log('Sending data to server');
115
+ this.pyServerAPI
116
+ .getVolumeCalibration({
117
+ sampleRate: this.sourceSamplingRate,
118
+ payload: this.#getTruncatedSignal(),
119
+ })
120
+ .then(res => {
121
+ if (this.soundGainDBSPL === null) {
122
+ this.soundGainDBSPL = res;
123
+ }
124
+ })
125
+ .catch(err => {
126
+ console.warn(err);
127
+ });
128
+ };
129
+
130
+ startCalibration = async stream => {
131
+ do {
132
+ await this.calibrationSteps(
133
+ stream,
134
+ this.#playCalibrationAudio,
135
+ this.#createCalibrationNode,
136
+ this.#sendToServerForProcessing
137
+ );
138
+ } while (this.soundGainDBSPL === null);
139
+
140
+ return this.soundGainDBSPL;
141
+ };
142
+ }
143
+
144
+ export default Volume;
145
+ </code></pre>
146
+ </article>
147
+ </section>
148
+ </div>
149
+
150
+ <nav>
151
+ <h2><a href="index.html">Home</a></h2>
152
+ <h3>Classes</h3>
153
+ <ul>
154
+ <li><a href="AudioCalibrator.html">AudioCalibrator</a></li>
155
+ <li><a href="AudioPeer.html">AudioPeer</a></li>
156
+ <li><a href="AudioRecorder.html">AudioRecorder</a></li>
157
+ <li><a href="ImpulseResponse.html">ImpulseResponse</a></li>
158
+ <li><a href="Listener.html">Listener</a></li>
159
+ <li><a href="MlsGenInterface.html">MlsGenInterface</a></li>
160
+ <li><a href="MyEventEmitter.html">MyEventEmitter</a></li>
161
+ <li><a href="PythonServerAPI.html">PythonServerAPI</a></li>
162
+ <li><a href="Speaker.html">Speaker</a></li>
163
+ <li><a href="Volume.html">Volume</a></li>
164
+ </ul>
165
+ <h3>Global</h3>
166
+ <ul>
167
+ <li><a href="global.html#csvToArray">csvToArray</a></li>
168
+ <li><a href="global.html#saveToCSV">saveToCSV</a></li>
169
+ <li><a href="global.html#sleep">sleep</a></li>
170
+ </ul>
171
+ </nav>
172
+
173
+ <br class="clear" />
174
+
175
+ <footer>
176
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Fri
177
+ Jul 29 2022 15:09:48 GMT-0400 (Eastern Daylight Time)
178
+ </footer>
179
+
180
+ <script>
181
+ prettyPrint();
182
+ </script>
183
+ <script src="scripts/linenumber.js"></script>
184
+ </body>
185
+ </html>
@@ -0,0 +1,105 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>JSDoc: Source: utils.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: utils.js</h1>
19
+
20
+ <section>
21
+ <article>
22
+ <pre class="prettyprint source linenums"><code>/**
23
+ * Utlity function to pause execution for a given time
24
+ * @param {number} seconds
25
+ * @returns {Promise}
26
+ */
27
+ const sleep = seconds =>
28
+ new Promise(resolve => {
29
+ setTimeout(resolve, seconds * 1000);
30
+ });
31
+
32
+ /**
33
+ * Uiltity function to create and save a CSV file from a buffer
34
+ * @param {*} data
35
+ * @param {*} filename
36
+ */
37
+ const saveToCSV = (data, filename = 'recordedMLSignal.csv') => {
38
+ // console.log(data)
39
+ let csvContent = 'data:text/csv;charset=utf-8,';
40
+
41
+ data.forEach((val, idx) => {
42
+ csvContent += `${idx},${val}\r\n`;
43
+ });
44
+ const encodedUri = encodeURI(csvContent);
45
+ const link = document.createElement('a');
46
+ link.setAttribute('href', encodedUri);
47
+ link.setAttribute('download', filename);
48
+ document.body.appendChild(link);
49
+ link.click();
50
+ };
51
+
52
+ /**
53
+ * Utility function to create a buffer from a CSV file
54
+ * @param {*} csvString
55
+ * @param {*} delimiter
56
+ * @returns
57
+ */
58
+ const csvToArray = (csvString, delimiter = ',') =>
59
+ csvString
60
+ .trim()
61
+ .split('\n')
62
+ .map(row => parseFloat(row.trim().split(delimiter)[1]));
63
+
64
+ export {sleep, saveToCSV, csvToArray};
65
+ </code></pre>
66
+ </article>
67
+ </section>
68
+ </div>
69
+
70
+ <nav>
71
+ <h2><a href="index.html">Home</a></h2>
72
+ <h3>Classes</h3>
73
+ <ul>
74
+ <li><a href="AudioCalibrator.html">AudioCalibrator</a></li>
75
+ <li><a href="AudioPeer.html">AudioPeer</a></li>
76
+ <li><a href="AudioRecorder.html">AudioRecorder</a></li>
77
+ <li><a href="ImpulseResponse.html">ImpulseResponse</a></li>
78
+ <li><a href="Listener.html">Listener</a></li>
79
+ <li><a href="MlsGenInterface.html">MlsGenInterface</a></li>
80
+ <li><a href="MyEventEmitter.html">MyEventEmitter</a></li>
81
+ <li><a href="PythonServerAPI.html">PythonServerAPI</a></li>
82
+ <li><a href="Speaker.html">Speaker</a></li>
83
+ <li><a href="Volume.html">Volume</a></li>
84
+ </ul>
85
+ <h3>Global</h3>
86
+ <ul>
87
+ <li><a href="global.html#csvToArray">csvToArray</a></li>
88
+ <li><a href="global.html#saveToCSV">saveToCSV</a></li>
89
+ <li><a href="global.html#sleep">sleep</a></li>
90
+ </ul>
91
+ </nav>
92
+
93
+ <br class="clear" />
94
+
95
+ <footer>
96
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Fri
97
+ Jul 29 2022 15:09:48 GMT-0400 (Eastern Daylight Time)
98
+ </footer>
99
+
100
+ <script>
101
+ prettyPrint();
102
+ </script>
103
+ <script src="scripts/linenumber.js"></script>
104
+ </body>
105
+ </html>
package/jest.config.js ADDED
@@ -0,0 +1,173 @@
1
+ /*
2
+ * For a detailed explanation regarding each configuration property, visit:
3
+ * https://jestjs.io/docs/configuration
4
+ */
5
+
6
+ module.exports = {
7
+ // All imported modules in your tests should be mocked automatically
8
+ // automock: false,
9
+
10
+ // Stop running tests after `n` failures
11
+ // bail: 0,
12
+
13
+ // The directory where Jest should store its cached dependency information
14
+ // cacheDirectory: "/private/var/folders/cs/1rk8dkgn7y5421407xn0z3200000gn/T/jest_dx",
15
+
16
+ // Automatically clear mock calls, instances and results before every test
17
+ clearMocks: true,
18
+
19
+ // Indicates whether the coverage information should be collected while executing the test
20
+ collectCoverage: true,
21
+
22
+ // An array of glob patterns indicating a set of files for which coverage information should be collected
23
+ // collectCoverageFrom: undefined,
24
+
25
+ // The directory where Jest should output its coverage files
26
+ coverageDirectory: 'coverage',
27
+
28
+ // An array of regexp pattern strings used to skip coverage collection
29
+ coveragePathIgnorePatterns: ['/node_modules/'],
30
+
31
+ // Indicates which provider should be used to instrument code for coverage
32
+ coverageProvider: 'v8',
33
+
34
+ // A list of reporter names that Jest uses when writing coverage reports
35
+ // coverageReporters: [
36
+ // "json",
37
+ // "text",
38
+ // "lcov",
39
+ // "clover"
40
+ // ],
41
+
42
+ // An object that configures minimum threshold enforcement for coverage results
43
+ // coverageThreshold: undefined,
44
+
45
+ // A path to a custom dependency extractor
46
+ // dependencyExtractor: undefined,
47
+
48
+ // Make calling deprecated APIs throw helpful error messages
49
+ // errorOnDeprecated: false,
50
+
51
+ // Force coverage collection from ignored files using an array of glob patterns
52
+ // forceCoverageMatch: [],
53
+
54
+ // A path to a module which exports an async function that is triggered once before all test suites
55
+ // globalSetup: undefined,
56
+
57
+ // A path to a module which exports an async function that is triggered once after all test suites
58
+ // globalTeardown: undefined,
59
+
60
+ // A set of global variables that need to be available in all test environments
61
+ // globals: {},
62
+
63
+ // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
64
+ // maxWorkers: "50%",
65
+
66
+ // An array of directory names to be searched recursively up from the requiring module's location
67
+ moduleDirectories: ['node_modules'],
68
+
69
+ // An array of file extensions your modules use
70
+ moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'node'],
71
+
72
+ // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
73
+ // moduleNameMapper: {},
74
+
75
+ // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
76
+ // modulePathIgnorePatterns: [],
77
+
78
+ // Activates notifications for test results
79
+ // notify: false,
80
+
81
+ // An enum that specifies notification mode. Requires { notify: true }
82
+ // notifyMode: "failure-change",
83
+
84
+ // A preset that is used as a base for Jest's configuration
85
+ // preset: undefined,
86
+
87
+ // Run tests from one or more projects
88
+ // projects: undefined,
89
+
90
+ // Use this configuration option to add custom reporters to Jest
91
+ // reporters: undefined,
92
+
93
+ // Automatically reset mock state before every test
94
+ // resetMocks: false,
95
+
96
+ // Reset the module registry before running each individual test
97
+ // resetModules: false,
98
+
99
+ // A path to a custom resolver
100
+ // resolver: undefined,
101
+
102
+ // Automatically restore mock state and implementation before every test
103
+ // restoreMocks: false,
104
+
105
+ // The root directory that Jest should scan for tests and modules within
106
+ // rootDir: undefined,
107
+
108
+ // A list of paths to directories that Jest should use to search for files in
109
+ roots: ['<rootDir>'],
110
+
111
+ // Allows you to use a custom runner instead of Jest's default test runner
112
+ // runner: "jest-runner",
113
+
114
+ // The paths to modules that run some code to configure or set up the testing environment before each test
115
+ // setupFiles: [],
116
+
117
+ // A list of paths to modules that run some code to configure or set up the testing framework before each test
118
+ // setupFilesAfterEnv: [],
119
+
120
+ // The number of seconds after which a test is considered as slow and reported as such in the results.
121
+ // slowTestThreshold: 5,
122
+
123
+ // A list of paths to snapshot serializer modules Jest should use for snapshot testing
124
+ // snapshotSerializers: [],
125
+
126
+ // The test environment that will be used for testing
127
+ testEnvironment: 'jsdom',
128
+
129
+ // Options that will be passed to the testEnvironment
130
+ // testEnvironmentOptions: {},
131
+
132
+ // Adds a location field to test results
133
+ // testLocationInResults: false,
134
+
135
+ // The glob patterns Jest uses to detect test files
136
+ testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)'],
137
+
138
+ // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
139
+ testPathIgnorePatterns: ['/node_modules/'],
140
+
141
+ // The regexp pattern or array of patterns that Jest uses to detect test files
142
+ // testRegex: [],
143
+
144
+ // This option allows the use of a custom results processor
145
+ // testResultsProcessor: undefined,
146
+
147
+ // This option allows use of a custom test runner
148
+ // testRunner: "jest-circus/runner",
149
+
150
+ // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
151
+ // testURL: "http://localhost",
152
+
153
+ // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
154
+ // timers: "real",
155
+
156
+ // A map from regular expressions to paths to transformers
157
+ transform: {'\\.[jt]sx?$': 'babel-jest'},
158
+
159
+ // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
160
+ transformIgnorePatterns: ['/node_modules/', '\\.pnp\\.[^\\/]+$'],
161
+
162
+ // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
163
+ // unmockedModulePathPatterns: undefined,
164
+
165
+ // Indicates whether each individual test should be reported during the run
166
+ // verbose: undefined,
167
+
168
+ // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
169
+ // watchPathIgnorePatterns: [],
170
+
171
+ // Whether to use watchman for file crawling
172
+ // watchman: true,
173
+ };
package/netlify.toml ADDED
@@ -0,0 +1,27 @@
1
+ # Settings in the [build] context are global and are applied to
2
+ # all contexts unless otherwise overridden by more specific contexts.
3
+ [build]
4
+ # Directory to change to before starting a build.
5
+ # This is where we will look for package.json/.nvmrc/etc.
6
+ # If not set, defaults to the root directory.
7
+ base = ""
8
+
9
+ # Directory that contains the deploy-ready HTML files and
10
+ # assets generated by the build. This is relative to the base
11
+ # directory if one has been set, or the root directory if
12
+ # a base has not been set.
13
+
14
+ publish = "dist/"
15
+
16
+ # Default build command.
17
+ command = "npm run build:prod"
18
+
19
+ # Redirects and headers are GLOBAL for all builds – they do not
20
+ # get scoped to contexts no matter where you define them in the file.
21
+ # For context-specific rules, use _headers or _redirects files,
22
+ # which are PER-DEPLOY.
23
+
24
+ # A basic redirect rule
25
+ [[redirects]]
26
+ from = "/*"
27
+ to = "/example"
package/package.json CHANGED
@@ -1,66 +1,67 @@
1
- {
2
- "name": "speaker-calibration",
3
- "version": "2.0.0",
4
- "description": "Speaker calibration library for auditory testing",
5
- "main": "dist/main.js",
6
- "directories": {
7
- "bin": "dist"
8
- },
9
- "scripts": {
10
- "build:prod": "webpack --mode production --progress",
11
- "build:dev": "webpack --watch --mode development --progress",
12
- "build:dev:analyze": "webpack --watch --mode development --progress --analyze",
13
- "serve:dev": "nodemon ./dist/example/server.js",
14
- "build:wasm": "make rebuild",
15
- "lint": "eslint src --ext .js",
16
- "lint:fix": "npm run lint -- --fix",
17
- "format": "prettier --write \"**/*.{js,json,md,html,css}\"",
18
- "build:doc": "jsdoc src -r -d ./doc",
19
- "test": "jest",
20
- "test:watch": "jest --watchAll --coverage"
21
- },
22
- "keywords": [],
23
- "constributors": [
24
- {
25
- "name": "Hugo De Moraes",
26
- "email": "demoraeshugo@gmail.com",
27
- "url": "https://github.com/demoraeshugo"
28
- }
29
- ],
30
- "license": "MIT",
31
- "repository": "git://github.com/EasyEyes/speaker-calibration.git",
32
- "dependencies": {
33
- "axios": "^0.27.2",
34
- "fftw-js": "^0.1.4",
35
- "path-browserify": "^1.0.1",
36
- "peerjs": "^1.3.2",
37
- "qrcode": "^1.4.4",
38
- "socket.io-client": "^4.4.1",
39
- "uuid": "^8.3.2"
40
- },
41
- "devDependencies": {
42
- "@babel/core": "^7.17.9",
43
- "@babel/preset-env": "^7.16.11",
44
- "babel-jest": "^27.5.1",
45
- "css-loader": "^5.2.6",
46
- "eslint": "^8.10.0",
47
- "eslint-config-airbnb-base": "^15.0.0",
48
- "eslint-config-prettier": "^8.4.0",
49
- "eslint-plugin-compat": "^4.0.2",
50
- "eslint-plugin-import": "^2.25.4",
51
- "eslint-plugin-jsdoc": "^39.3.4",
52
- "eslint-plugin-no-floating-promise": "^1.0.2",
53
- "express": "^4.17.1",
54
- "jest": "^27.5.1",
55
- "jsdoc": "^3.6.10",
56
- "nodemon": "^2.0.15",
57
- "prettier": "^2.5.1",
58
- "style-loader": "^2.0.0",
59
- "webpack": "~5.69.1",
60
- "webpack-bundle-analyzer": "^4.5.0",
61
- "webpack-cli": "^4.9.2"
62
- },
63
- "browserslist": [
64
- "defaults"
65
- ]
66
- }
1
+ {
2
+ "name": "speaker-calibration",
3
+ "version": "2.1.0",
4
+ "description": "Speaker calibration library for auditory testing",
5
+ "main": "dist/main.js",
6
+ "directories": {
7
+ "bin": "dist"
8
+ },
9
+ "scripts": {
10
+ "build:prod": "webpack --mode production --progress",
11
+ "build:dev": "webpack --watch --mode development --progress",
12
+ "build:dev:analyze": "webpack --watch --mode development --progress --analyze",
13
+ "serve:dev": "nodemon ./dist/example/server.js",
14
+ "build:wasm": "make rebuild",
15
+ "lint": "eslint src --ext .js",
16
+ "lint:fix": "npm run lint -- --fix",
17
+ "format": "prettier --write \"**/*.{js,json,md,html,css}\"",
18
+ "build:doc": "jsdoc src -r -d ./doc",
19
+ "test": "jest",
20
+ "test:watch": "jest --watchAll --coverage"
21
+ },
22
+ "keywords": [],
23
+ "constributors": [
24
+ {
25
+ "name": "Hugo De Moraes",
26
+ "email": "demoraeshugo@gmail.com",
27
+ "url": "https://github.com/demoraeshugo"
28
+ }
29
+ ],
30
+ "license": "MIT",
31
+ "repository": "git://github.com/EasyEyes/speaker-calibration.git",
32
+ "dependencies": {
33
+ "axios": "^0.27.2",
34
+ "fftw-js": "^0.1.4",
35
+ "np": "^7.6.2",
36
+ "path-browserify": "^1.0.1",
37
+ "peerjs": "^1.3.2",
38
+ "qrcode": "^1.4.4",
39
+ "socket.io-client": "^4.4.1",
40
+ "uuid": "^8.3.2"
41
+ },
42
+ "devDependencies": {
43
+ "@babel/core": "^7.17.9",
44
+ "@babel/preset-env": "^7.16.11",
45
+ "babel-jest": "^27.5.1",
46
+ "css-loader": "^5.2.6",
47
+ "eslint": "^8.10.0",
48
+ "eslint-config-airbnb-base": "^15.0.0",
49
+ "eslint-config-prettier": "^8.4.0",
50
+ "eslint-plugin-compat": "^4.0.2",
51
+ "eslint-plugin-import": "^2.25.4",
52
+ "eslint-plugin-jsdoc": "^39.3.4",
53
+ "eslint-plugin-no-floating-promise": "^1.0.2",
54
+ "express": "^4.17.1",
55
+ "jest": "^27.5.1",
56
+ "jsdoc": "^3.6.10",
57
+ "nodemon": "^2.0.15",
58
+ "prettier": "^2.5.1",
59
+ "style-loader": "^2.0.0",
60
+ "webpack": "~5.69.1",
61
+ "webpack-bundle-analyzer": "^4.5.0",
62
+ "webpack-cli": "^4.9.2"
63
+ },
64
+ "browserslist": [
65
+ "defaults"
66
+ ]
67
+ }
package/src/index.html ADDED
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <html class="no-js" lang="">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta http-equiv="x-ua-compatible" content="ie=edge" />
6
+ <title>Sound Check</title>
7
+ <meta name="description" content="" />
8
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
9
+
10
+ <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
11
+ <!-- Place favicon.ico in the root directory -->
12
+ </head>
13
+ <body>
14
+ <!--[if lt IE 8]>
15
+ <p class="browserupgrade">
16
+ You are using an <strong>outdated</strong> browser. Please
17
+ <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.
18
+ </p>
19
+ <![endif]-->
20
+ </body>
21
+ </html>
package/src/main.js ADDED
@@ -0,0 +1,21 @@
1
+ import Listener from './peer-connection/listener';
2
+ import Speaker from './peer-connection/speaker';
3
+
4
+ import VolumeCalibration from './tasks/volume/volume';
5
+ import ImpulseResponseCalibration from './tasks/impulse-response/impulseResponse';
6
+
7
+ import {
8
+ UnsupportedDeviceError,
9
+ MissingSpeakerIdError,
10
+ CalibrationTimedOutError,
11
+ } from './peer-connection/peerErrors';
12
+
13
+ export {
14
+ Listener,
15
+ Speaker,
16
+ VolumeCalibration,
17
+ ImpulseResponseCalibration,
18
+ UnsupportedDeviceError,
19
+ MissingSpeakerIdError,
20
+ CalibrationTimedOutError,
21
+ };