iqm.pulse.playlist.channel.round_duration_to_granularity_samples

iqm.pulse.playlist.channel.round_duration_to_granularity_samples#

iqm.pulse.playlist.channel.round_duration_to_granularity_samples(channels, duration, round_up=False, force_min_duration=False)#

Round a time duration to the least common multiple of the granularities of the given channels.

Note

Assumes that all the given control channels have the same sample rate.

Parameters:
  • channels (Iterable[ChannelProperties]) – all these channels must be able to handle the rounded duration

  • duration (float) – time duration in s

  • round_up (bool) – whether to round the duration up, or to the closest granularity

  • force_min_duration (bool) – whether to force the duration to be at least the largest instruction_duration_min of channels

Returns:

duration rounded to common channel granularity, in samples

Return type:

int