num_samples
- ketos.audio.utils.misc.num_samples(time, rate, even=False)[source]
Convert time interval to number of samples.
If the time corresponds to a non-integer number of samples, round to the nearest larger integer value.
- Args:
- time: float
Timer interval in seconds
- rate: float
Sampling rate in Hz
- even: bool
Convert to nearest larger even integer.
- Returns:
- n: int
Number of samples
- Example:
>>> from ketos.audio.utils.misc import num_samples >>> print(num_samples(rate=1000., time=0.0)) 0 >>> print(num_samples(rate=1000., time=2.0)) 2000 >>> print(num_samples(rate=1000., time=2.001)) 2001 >>> print(num_samples(rate=1000., time=2.001, even=True)) 2002