Skip to content
This repository was archived by the owner on Mar 14, 2024. It is now read-only.

Add microphone process pattern#9198

Merged
beaufortfrancois merged 4 commits intomainfrom
web-audio-pattern
Jan 19, 2023
Merged

Add microphone process pattern#9198
beaufortfrancois merged 4 commits intomainfrom
web-audio-pattern

Conversation

@beaufortfrancois
Copy link
Copy Markdown
Member

@beaufortfrancois beaufortfrancois commented Dec 8, 2022

@netlify
Copy link
Copy Markdown

netlify bot commented Dec 8, 2022

Deploy Preview for web-dev-staging ready!

Name Link
🔨 Latest commit 1cad71e
🔍 Latest deploy log https://app.netlify.com/sites/web-dev-staging/deploys/63c902852780eb00082ffb9a
😎 Deploy Preview https://deploy-preview-9198--web-dev-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@rachelandrew rachelandrew marked this pull request as draft December 8, 2022 10:43
@beaufortfrancois beaufortfrancois marked this pull request as ready for review January 5, 2023 08:36
@MichealThabbet

This comment was marked as off-topic.

class WorkletProcessor extends AudioWorkletProcessor {
process([input], [output]) {
// Copy inputs to outputs.
input[0].forEach((sample, i) => output[0][i] = sample);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Float32Array.set() is much faster than this iteration - which is sort of the best practice for audio. What do you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also noticed that this doesn't store/copy the audio stream into something else. (e.g. recording) Is this pattern only to demonstrate access to raw audio data via AudioWorklet?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Float32Array.set() is much faster than this iteration - which is sort of the best practice for audio. What do you think?

Much better indeed. It is fixed in ecabb69. Thanks!

I also noticed that this doesn't store/copy the audio stream into something else. (e.g. recording) Is this pattern only to demonstrate access to raw audio data via AudioWorklet?

This pattern is specifically about processing yes. We do https://web.dev/patterns/media/microphone-record/ for recording. I wonder now if we should have another pattern for processing & recording via AudioWorklet.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for confirmation. LGTM!

@beaufortfrancois beaufortfrancois merged commit cf8c405 into main Jan 19, 2023
@beaufortfrancois beaufortfrancois deleted the web-audio-pattern branch January 19, 2023 09:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants