Skip to content
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

Build up in ring buffer #270

Open
4 tasks
jmcker opened this issue Apr 25, 2019 · 0 comments
Open
4 tasks

Build up in ring buffer #270

jmcker opened this issue Apr 25, 2019 · 0 comments
Labels

Comments

@jmcker
Copy link
Member

jmcker commented Apr 25, 2019

With the way that the node addon is currently setup in symboxtra/SplitSound, the WebAudio ScriptProcessor node clocks its reads at a perfect rate as HulaLoop ring buffer is filled. This is desirable because we never get underflow or overflow or have to sleep, but it creates a problem if we ever miss a read or slow down, which inevitably happens.

Once the ring buffer fills during that hiccup, the reader will never catch back up to real time. Right now, this can introduce up to ~.8s of latency into the stream which will remain until the ring buffer is drained.

This would apply to other clients as well and would prevent their buffers from getting stale.

TODO

  • Add a setting to HulaAudioSettings that sets the aggressiveness of this feature
  • Default to the least aggressive mode
  • Add a getReadAvailable() method to HulaRingBuffer that returns the number of available samples
  • Add a check in NodeAddon::readBuffer that watches for build up that exceeds the threshold determined by the aggressiveness setting

Possible thresholds

  • Percentage of buffer that should be allowed to be full. Range: [.1, 1.0]
    if readAvailable >= thresh * bufferSize: drainBuffer

Related to: symboxtra/SplitSound#1

@jmcker jmcker added the feature label Apr 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant