MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ seconds_to_samples()

MAYAFLUX_API uint64_t MayaFlux::seconds_to_samples ( double  seconds)

Converts a time duration in seconds to the equivalent number of audio samples.

Parameters
secondsTime duration in seconds
Returns
Equivalent number of audio samples based on the current sample rate

This function uses the sample rate from the default engine to calculate how many audio samples correspond to the given time duration in seconds. It's useful for scheduling tasks or processing buffers based on time intervals.

Definition at line 246 of file Chronie.cpp.

247{
248 uint64_t sample_rate = 48000;
249 if (get_context().is_running()) {
250 sample_rate = get_context().get_stream_info().sample_rate;
251 }
252 return static_cast<uint64_t>(seconds * (double)sample_rate);
253}
GlobalStreamInfo & get_stream_info()
Gets the current stream configuration.
Definition Engine.hpp:224
Core::Engine & get_context()
Gets the default engine instance.
Definition Core.cpp:68
uint32_t sample_rate
Number of samples processed per second (Hz)

References get_context(), MayaFlux::Core::Engine::get_stream_info(), and MayaFlux::Core::GlobalStreamInfo::sample_rate.

Referenced by route_network(), and route_node().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: