-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FreeQueue + WASM example #255
base: main
Are you sure you want to change the base?
Changes from 1 commit
d20a9e8
82f5489
a7e8c6d
d762369
4371644
b076335
9c6da20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"version":"3.0.2","revision":"a7e8c6d","lastUpdated":"2022-09-10","copyrightYear":2022} | ||
{"version":"3.0.2","revision":"d762369","lastUpdated":"2022-09-11","copyrightYear":2022} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,27 +12,20 @@ const RENDER_QUANTUM = 128 | |
class SinkProcessor extends AudioWorkletProcessor { | ||
constructor(options) { | ||
super(); | ||
// Initialize the Queue. | ||
// We have to set prototype of queue, because queue object is passed | ||
// using structured cloning algorithm. | ||
// See - | ||
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm | ||
// Initializes a FreeQueue object with the option passed from the | ||
// AudioWorkletNode constructor on the main thread. | ||
this.queue = options.processorOptions.queue; | ||
Object.setPrototypeOf(this.queue, FreeQueue.prototype); | ||
} | ||
|
||
process(inputs, outputs) { | ||
const output = outputs[0]; | ||
|
||
// Pull out render quantum frame from the queue into output. | ||
// If failed, print "failed" to console. | ||
const didPull = this.queue.pull(output, RENDER_QUANTUM); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we can Then I think audio worklet will just stop 🤔 https://webaudio.github.io/web-audio-api/#callback-audioworketprocess-callback So I think we should always return true, to keep worklet alive |
||
didPull ? null : console.log("failed"); | ||
|
||
return true; | ||
} | ||
|
||
} | ||
DivyamAhuja marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
registerProcessor('sink-processor', SinkProcessor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this means it only fills up a single channel (mono). Why can't we do the stereo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This library just acts as queue to share data between 2 threads.
So, I think it's up to user how they use it.
inputs and outputs are array of arrays of arrays (3 dimensional arrays)
So, we are technically pushing data into 2 channels of 0th output in this case