Comments (5)
Cool to re-open this discussion, I really think we have a lot of room for perf improvements in handling the audio graph more smartly (...but that's quite/really tricky for sure...)
an AudioBufferSourceNode has ended and does not loop
I don't really get that, if the AudioBufferSourceNode
is in a loop, it's not ended and the tail time should remain true
unless stop
is called explicitly (and if it is not the case, I would consider it an issue ...and my fault actually :)
a
ConstantSourceNode
has stopped
This is true for all AudioScheduledSourceNode
I think
Related note regarding #396 and AudioBufferSourceNode
, because I'm not really sure about what we do in the case:
- We have a buffer of 10mn long
- We start the source
- After 1sec, we
disconnect()
the node and drop it but without callingstop()
explicitly...
Do the renderer continue to hardly compute things that cannot be heard anymore? (I'm actually afraid this is the case, and maybe that could explain the issue)
...And we could just imagine the exact same setup with an OscillatorNode
or a ConstantSourceNode
, which would be actually worse because they would render forever (as tail_time == true
unless stop
is explicitly called on these nodes...)
If I'm not mistaking in the first place, maybe a new rule for AudioScheduledSourceNode
s could be: "if disconnected and dropped on main thread (so no possibility to reconnect anymore), tail time is false
whatever the renderer pretends"
And then (needs review) maybe this could be generalized to:
We drop the AudioProcessor also when both:
- the control thread has dropped the corresponding AudioNode
- the processor has no output
from web-audio-api-rs.
Yes, all valid points.
Do the renderer continue to hardly compute things that cannot be heard anymore?
Reading the spec literally, yes it should continue processing regardless if the output are used.
https://webaudio.github.io/web-audio-api/#rendering-loop - Step 4 requires to consider all nodes
Now common sense would make you think we don't need to render pieces of the audio graph that are not connected to the destination node, but this is only true when none of these nodes have observable side effects
Nodes with observable side effects include
- destination node, obviously
- analyser node
- media stream destination node
- user provided worket nodes (could ship audio over the network for example)
- delay node (e.g buffer signals for a long time, and then connect the node to the destination)
- ...
As you can see this becomes quite hairy easily. But maybe the browser implementation don't care and only traverse backwards from the destination node?
That said we could easily drop orphaned source nodes, it would be a nice start.
from web-audio-api-rs.
Hehe, ok, but can you actually observe any side effect if you don't have any handle to the node, and then no way to observe any side effect?
from web-audio-api-rs.
Ah true, disregard delay node and analyser node
from web-audio-api-rs.
[edited to remove noise :)]
As you can see this becomes quite hairy easily.
Yes, I agree this is kind of nightmare to think about
That said we could easily drop orphaned source nodes, it would be a nice start.
Yup sure!
I can already think of another problematic case I think, but probably best to clearly define what observable side effects means beforehand
from web-audio-api-rs.
Related Issues (20)
- Apply limits of compound AudioParam values
- Free audio processor resources when the node will never start processing HOT 2
- Should the AudioContext continue playing when it is dropped?
- Avoid O(nĀ²) graph ordering when adding nodes 'organically' HOT 2
- Issue with NodeCollection HOT 3
- Review AudioNode connect/disconnect methods
- Rename ChannelConfigOptions to AudioNodeOptions
- Fix `showcase/mic_playback` example - use Worklet instead of bare AudioNode trait
- Implement dynamic lifetime of AudioContext
- OS X Only: Looping Sounds Break Audio HOT 18
- ScriptProcessorNode: avoid (de)allocations of input/output AudioBuffer for realtime safety
- Implement onended events for more cases HOT 1
- disconnect -> connect does not work on PannerNode HOT 2
- ScriptProcessorNode: setting numberOfOutputs to more than 1 panics HOT 1
- Suspended + Sound put windows apps into "Not Responding" state HOT 6
- AudioContext::resume not `Send` anymore? HOT 1
- Difficulty Specifying Media Types and Streaming in Rust MediaRecorder Implementation HOT 5
- MediaRecorder spec compliance: add options and isTypeSupported
- MediaRecorder: support more mimeTypes than audio/wav
- Disable all dependencies for compilation-only test? HOT 2
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-rs.