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

◆ activate_buffer()

void MayaFlux::Kriya::TemporalActivation::activate_buffer ( const std::shared_ptr< Buffers::Buffer > &  buffer,
double  duration_seconds,
Buffers::ProcessingToken  token = Buffers::ProcessingToken::AUDIO_BACKEND,
uint32_t  channel = 0 
)

Activates a buffer for a specified duration.

Parameters
bufferThe buffer to activate
tokenThe processing token associated with the buffer
duration_secondsThe duration to keep the buffer active (in seconds)
channelOptional output channel to connect the buffer to (default is 0) This method activates the specified buffer by connecting it to the output channel, and starts a timer for the specified duration. When the timer expires, the buffer is automatically disconnected from the output channel, effectively deactivating it.

If another node, network, or buffer is already active, it will be cancelled before activating the new one.

Definition at line 145 of file Timers.cpp.

149{
150 cancel();
151
152 m_current_buffer = buffer;
153 m_buffer_token = token;
154 m_channels = { channel };
156
157 m_buffer_manager.add_buffer(buffer, token, channel);
158
159 m_timer.schedule(duration_seconds, [this]() {
161 });
162}
void add_buffer(const std::shared_ptr< Buffer > &buffer, ProcessingToken token, uint32_t channel=0)
Adds a buffer to a token and channel.
Buffers::ProcessingToken m_buffer_token
The processing token associated with the currently active buffer.
Definition Timers.hpp:420
std::vector< uint32_t > m_channels
The output channels the current node is connected to.
Definition Timers.hpp:438
void cleanup_current_operation()
Cleans up the current operation, disconnecting the entity and resetting state.
Definition Timers.cpp:164
std::shared_ptr< Buffers::Buffer > m_current_buffer
The currently active buffer being played.
Definition Timers.hpp:402
void cancel()
Cancels any currently active node.
Definition Timers.cpp:209
Buffers::BufferManager & m_buffer_manager
Reference to the buffer manager that manages processing buffers.
Definition Timers.hpp:367
Timer m_timer
The timer used to schedule processing duration.
Definition Timers.hpp:375
void schedule(double delay_seconds, std::function< void()> callback)
Schedules a callback to execute after a delay.
Definition Timers.cpp:19

References MayaFlux::Buffers::BufferManager::add_buffer(), BUFFER, cancel(), cleanup_current_operation(), m_active_type, m_buffer_manager, m_buffer_token, m_channels, m_current_buffer, m_timer, and MayaFlux::Kriya::Timer::schedule().

+ Here is the call graph for this function: