mirror of
https://github.com/0015/ThatProject.git
synced 2026-01-12 17:27:43 +03:00
Broadcasting Your Voice with ESP32-S3 & INMP441
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
// worker.js
|
||||
self.addEventListener('message', function (e) {
|
||||
var mean = 0;
|
||||
var samples_read = e.data.byteLength / 8;
|
||||
if (samples_read > 0) {
|
||||
|
||||
var byteArray = new Int16Array(e.data);
|
||||
|
||||
for (var i = 0; i < samples_read; ++i) {
|
||||
mean += (byteArray[i]);
|
||||
}
|
||||
|
||||
mean /= samples_read;
|
||||
self.postMessage(mean);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user