Skip to content

Build up in ring buffer #270

@jmcker

Description

@jmcker

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions