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

◆ create_ring()

MAYAFLUX_API std::shared_ptr< Kakshya::DynamicSoundStream > MayaFlux::create_ring ( double  seconds,
uint32_t  channels = 1 
)

Make a circular stream that keeps the most recent seconds of a signal.

The stream runs at the engine sample rate. Fill it with record_into and read it with taps that use lag, or copy its recent past with snapshot.

Parameters
secondsHow much of the past to keep.
channelsNumber of channels.
Returns
The ring, or nullptr if it would be empty.

Definition at line 199 of file Rigs.cpp.

200{
201 const uint32_t rate = Config::get_sample_rate();
202 const auto capacity = static_cast<uint64_t>(seconds * static_cast<double>(rate));
203
204 if (capacity == 0 || channels == 0) {
205 MF_ERROR(Journal::Component::API, Journal::Context::Configuration,
206 "create_ring: {} seconds on {} channels is empty", seconds, channels);
207 return nullptr;
208 }
209
210 auto ring = std::make_shared<Kakshya::DynamicSoundStream>(rate, channels);
211 ring->enable_circular_buffer(capacity);
212 return ring;
213}
#define MF_ERROR(comp, ctx,...)
float rate
uint32_t channels

References MayaFlux::Journal::API, channels, MayaFlux::Journal::Configuration, MayaFlux::Config::get_sample_rate(), MF_ERROR, and rate.

+ Here is the call graph for this function: