audio device client
play

Audio Device Client Better and Faster Audio I/O on Web Hongchan - PowerPoint PPT Presentation

Audio Device Client Better and Faster Audio I/O on Web Hongchan Choi Google Chrome Web Audio API Spec Editor (Audio WG) Proposal: Audio Device Client Work-in-progress! (in Audio CG) Proposal: Audio Device Client Low-level audio I/O


  1. Audio Device Client Better and Faster Audio I/O on Web Hongchan Choi Google Chrome Web Audio API Spec Editor (Audio WG)

  2. Proposal: Audio Device Client • Work-in-progress! (in Audio CG)

  3. Proposal: Audio Device Client • Low-level audio I/O • Better access to hardware • A dedicated scope runs on RT thread

  4. "But... why?"

  5. "To close the App Gap for audio."

  6. Mac OS Linux Windows Web Platform PulseAudio ? WASAPI Core Audio or Jack or ASIO (ALSA)

  7. "Web Audio API?"

  8. Issues: Web Audio API (around 2013) • Extensibility (W3C TAG review, 1st round) - No AudioNode subclassing - ScriptProcessorNode unfit for purpose

  9. Audio Worklet

  10. index.js processor.js (main thread) (audio thread) Audio Worklet Processor User code Audio Worklet Node audio callback

  11. "How do I port X with it?"

  12. Case study 1: Audio Worklet + WASM

  13. Problems: Audio Worklet + WASM • Web Audio API render quantum == 128 sample frames (less than 3ms at 44.1Khz) • Not suitable for large-scale audio application

  14. Case study 2: AW + SAB + WASM Worker

  15. SharedArrayBuffer (Audio Data) Input Buffer AudioWorklet Worker Processor Output Buffer SharedArrayBuffer (States) Wait/Wake, Buffer indexes

  16. Problems: AW + SAB + WASM Worker • Low thread priority of Worker • Overly complex setup for a basic task

  17. Proposal: Audio Device Client • Low-level audio I/O - Isochronous callback-based audio I/O - Suitable for WASM-powered audio processing

  18. Proposal: Audio Device Client • Better access to hardware - Configurable render block size, sample rate, and I/O channels - Constraints-based hardware configuration

  19. Proposal: Audio Device Client • A dedicated scope runs on RT thread (if permitted) - No more complex plumbing and thread hops - For optimum WASM-powered audio processing

  20. Potential Use Cases • Game audio engine • Pro-audio applications (music production) • Client-side spatialization (AR/VR) • Teleconference

  21. Code Examples

  22. /* async scope: main global scope */ const devices = await navigator.mediaDevices.enumerateDevices(); // Scenario: device #0 and #2 are audio input and // output devices respectively. const constraints = { inputDeviceId: devices[0].deviceId, outputDeviceId: devices[2].deviceId, sampleRate: 32000, callbackBufferSize: 512, inputChannelCount: 2, outputChannelCount: 6, }; Setting up device constraints

  23. /* async scope: main global scope */ const client = await navigator.mediaDevices.getAudioDeviceClient(constraints); await client.addModule('my-client.js'); client.start(); // when the application ended client.stop(); AudioDeviceClient

  24. /* my-client.js: AudioDeviceClientGlobalScope */ import Engine from './my-audio-engine.js'; /** * @params {Array<Float32Array>} input * @params {Array<Float32Array>} output */ const process = (input, output) => { Engine.process(input, output); }; setDeviceCallback(process); AudioDeviceClientGlobalScope

  25. Design issues: Integration • WASM • AudioContext • WebRTC

  26. Security/Privacy Concerns • Real-time priority thread - Mitigation: ADC only can be spawned by "top-level document". • Autoplay policy and secure context by default

  27. github.com/WebAudio/web-audio-cg (explainer, IDL, code examples, and issue tracker)

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend