Ralith / oddio

Lightweight game audio
Apache License 2.0
150 stars 9 forks source link

SpatialScene::play_buffered optimizations #95

Closed OlegOAndreev closed 2 years ago

OlegOAndreev commented 2 years ago

Replacing #92

This is mostly the continuation of https://github.com/Ralith/oddio/pull/89

Four changes:

  1. The most important one: do not call Ring::sample for every sample, process in chunks like the Spatial::play already does. Easily gives 50-60% perf improvement.
  2. Specialize FramesSignal::sample for cases when the the delta is integer (i.e. interval / rate == 1.0), 10% perf improvement.
  3. Do not re-initialize scratch buffer for every signal, perf improvement depends on the number of mixed signals.
  4. (Not particularly related to the current PR, but I did not want to open a tiny PR just for it): fast-path for Gain::sample when the gain is constant.