Accounting for changing sample rate
Posted: Sun Mar 28, 2021 5:35 am
I'm trying to map out what can't be considered a "constant" in terms of time, tempo, and sample rate.
Good thread here about why "real time" functions won't work for calculating durations/tempo: viewtopic.php?f=9&t=287
The short of it is that because audio buffers are processed in batches, it's not possible to rely on reading the current timestamp, as you can't guarantee the buffer is being processed in real time. I've specifically noticed this is relevant when doing a DAW export while using VM embedded as a VST. The timing isn't real time.
I'm wondering if there are situations where the sample rate might change as well after a module has loaded e.g. during DAW export or if the host software changes audio interface?. Is it a good idea to always call Values.SampleRate or Values.SamplesPerMs instead of "caching" the value? Are either of those calls "costly"?
Good thread here about why "real time" functions won't work for calculating durations/tempo: viewtopic.php?f=9&t=287
The short of it is that because audio buffers are processed in batches, it's not possible to rely on reading the current timestamp, as you can't guarantee the buffer is being processed in real time. I've specifically noticed this is relevant when doing a DAW export while using VM embedded as a VST. The timing isn't real time.
I'm wondering if there are situations where the sample rate might change as well after a module has loaded e.g. during DAW export or if the host software changes audio interface?. Is it a good idea to always call Values.SampleRate or Values.SamplesPerMs instead of "caching" the value? Are either of those calls "costly"?