-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,506 additions
and
1,129 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,14 @@ | ||
declare module "*.wasm" { | ||
const content: string; | ||
export default content; | ||
} | ||
|
||
declare module "*.js" { | ||
const content: string; | ||
export default content; | ||
} | ||
|
||
declare module 'web-worker:*' { | ||
const WorkerFactory: new () => Worker; | ||
export default WorkerFactory; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,43 @@ | ||
class RecorderProcessor extends AudioWorkletProcessor { | ||
constructor(options) { | ||
super(); | ||
|
||
const { numberOfChannels = 1, frameLength = 512 } = options?.processorOptions; | ||
|
||
this._numberOfChannels = numberOfChannels; | ||
this._frameLength = frameLength; | ||
|
||
this._copied = 0; | ||
this._recorderBuffer = new Array(numberOfChannels).fill(new Float32Array(frameLength)); | ||
} | ||
|
||
process(inputs, outputs, parameters) { | ||
let input = inputs[0]; // get first input | ||
if (input.length === 0) { | ||
return true; | ||
} | ||
|
||
let remaining = input[0].length; | ||
while (remaining > 0) { | ||
const toCopy = Math.min(remaining, this._frameLength - this._copied); | ||
|
||
for (let ch = 0; ch < this._numberOfChannels; ch ) { | ||
this._recorderBuffer[ch].set(input[ch].slice(0, toCopy), this._copied); | ||
} | ||
|
||
remaining -= toCopy; | ||
this._copied = toCopy; | ||
|
||
if (this._copied >= this._frameLength) { | ||
this.port.postMessage({ | ||
buffer: this._recorderBuffer | ||
}); | ||
this._copied = 0; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
|
||
registerProcessor('recorder-processor', RecorderProcessor); |
Oops, something went wrong.