Comments (9)
We're thinking this could go in the direction of allowing an offline context to complete the filling of its buffer, but then be restarted (seamlessly) with a new buffer instead of becoming dead. Making these buffers relatively short allows the rendering to be chunked and/or easily terminated without holding onto a lot of memory.
from web-audio-api-v2.
F2F resolution, two things:
- Either have a new method (
abort()
?) or repurposeclose()
to terminate the rendering early. - Integrate with WHATWG Streams to be able to stream the rendering of PCM data to something else. This would work by outputting 128 frames buffers, and the final one potentially less than 128 frames (depending on the number of frames requested initially).
from web-audio-api-v2.
WG question: Would you want to access the data computed up to the point at which the context is closed?
from web-audio-api-v2.
FWIW, I would like the rendered audio. I think this complicates things a bit in figuring out what the startRendering
promise should do.
from web-audio-api-v2.
For our use case here, it's not immediately necessary at the moment to resolve with the already rendered data, we are just looking for the cancel portion of this functionality (for us the best approach would be streaming to a file through an encoder directly anyways, to avoid the memory impact, but to the best of my knowledge, we are currently way too undermanned to pull that off).
However, I believe returning a Promise<AudioBuffer>
that resolves with what's already been rendered would be a sound decision perhaps:
let partiallyRenderedResults: AudioBuffer = await audioContext.stopRendering();
Although I'm not sure if this would be efficient, as AFAIK (most?) implementations pre-allocate the full length AudioBuffer that is ultimately acquired at the end of startRendering
, which perhaps means a new allocation for the partial results would be required? (I'm not quite sure about this without digging into an implementation right now)
Edit
Of course we can always just resolve with an already allocated AudioBuffer, but this would then require a way to reliably access the exact sample point up to which rendering was done. Perhaps this could be done by speccing currentTime
to be the time-representation of this exact value? This would in theory allow computing the last valid sample point, e.g. by doing:
let partiallyRenderedResults = await audioContext.stopRendering();
let lastValidSampleIndex = Math.floor(audioContext.currentTime * audioContext.sampleRate);
Edit 2
Acquiring partial results through stopRendering
would pose a question about what happens to startRendering
. Perhaps it would be reasonable if it also resolved with the partial results?
from web-audio-api-v2.
perhaps running the rendering process in an
iframe`, which can be reloaded without reloading my entire app.
I tried implementing this, but in my tests, the iframe doesn't reload until after the OfflineAudioContext completes rendering. Have you gotten this to work?
from web-audio-api-v2.
I tried implementing this, but in my tests, the iframe doesn't reload until after the OfflineAudioContext completes rendering. Have you gotten this to work?
This sounds like an implementation issue, maybe open a bug on the relevant implementation bug tracker?
from web-audio-api-v2.
See also #66
from web-audio-api-v2.
Closing this. #66 should be able to handle early termination since we're incrementally delivering audio. Just need to add some kind of close
method to indicate that the offline context is done.
from web-audio-api-v2.
Related Issues (20)
- V2 documentation logistics HOT 2
- interaction between audio elements and the Web Audio API HOT 2
- Add ability to pause/resume AudioBufferSourceNode HOT 11
- AudioOutputContext HOT 21
- AnalyserNode: provide access to complex FFT result HOT 15
- AnalyserNode: efficiency improvements to FFT post-processing HOT 3
- Alternatives for module loading of AudioWorklet HOT 5
- Should 'Atomics.wait' be available in AudioWorklets associated with an OfflineAudioContext? HOT 8
- Request to Expose AudioBuffer to DedicatedWorker HOT 29
- Rename master branch to main HOT 2
- Set up to display the spec. HOT 10
- AudioWorklet should have a 'oversample' and a 'bufferSize' property HOT 5
- cancelScheduledValues and cancelAndHoldAtTime throws RangeError for non-finite
- Switching between 2 Microphones HOT 1
- No way to convert data from WebCodecs AudioData to AudioBuffer HOT 7
- Add frequency of one oscillator to be based on another HOT 1
- Define TextEncoderStream(), and TextDecoderStream() in AudioWorkletGlobalScope HOT 1
- Add Travis CI HOT 1
- RawPCMStreamNode (StreamNode, or InputStreamNode) HOT 8
- Set up PR review HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from web-audio-api-v2.