~breakfastquay/rubberband#3: 
Provide a function to get output playback position

(Formerly Bitbucket issue 14, filed by wintersnow)

This is a problem for video players and other things which need to sync events to audio playback position exactly. I suppose this affects realtime mode only.

Consider that each input sample has a playback time associated. Then the API user wants to know what playback time each output sample has. Because the output audio is actually stretched, the user can't just use the input samplerate to estimate the position.

Even worse, librubberband could buffer an arbitrary amount of audio, about which the user doesn't know about. getLatency() is mostly constant (depending on stretch ratio), so it doesn't tell you about how much audio is buffered momentarily. rubberband_available() isn't enough.

So what I suggest that each input sample has an associated uint64_t timestamp (the sample number starting from 0). Then add a function which returns the timestamp of the first output sample that can be read with rubberband_retrieve(), and also returns the current stretch ratio of this piece of audio as an integer fraction or as a double.

Status
REPORTED
Submitter
~breakfastquay
Assigned to
No-one
Submitted
9 months ago
Updated
9 months ago
Labels
No labels applied.

~breakfastquay 9 months ago

This is an excellent idea, but structurally hard in the current library. One for any putative v2.0.