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

◆ open()

void MayaFlux::Core::RtAudioStream::open ( )
overridevirtual

Initializes the audio stream and allocates required resources.

Opens the RtAudio stream with the configured parameters, making it ready for data transfer. Does not start the actual data flow.

Implements MayaFlux::Core::AudioStream.

Definition at line 210 of file RtAudioBackend.cpp.

211{
212 if (is_open()) {
213 return;
214 }
215
216 try {
217 RtAudioFormat format = RTAUDIO_FLOAT64;
218
219 switch (m_stream_info.format) {
221 format = RTAUDIO_FLOAT32;
222 break;
224 format = RTAUDIO_FLOAT64;
225 break;
227 format = RTAUDIO_SINT16;
228 break;
230 format = RTAUDIO_SINT24;
231 break;
233 format = RTAUDIO_SINT32;
234 break;
235 }
236
237 RtAudio::StreamParameters* inputParamsPtr = nullptr;
238
240 // inputParams.deviceId = m_stream_info.input.device_id >= 0 ? m_stream_info.input.device_id : m_context->getDefaultInputDevice();
242 // inputParams.firstChannel = 0;
243 inputParamsPtr = &m_in_parameters;
244 }
245
247
248 m_context->openStream(
250 inputParamsPtr,
251 format,
255 this,
256 &m_options);
257
258 m_isOpen = true;
259 } catch (const RtAudioErrorType& e) {
261 m_isOpen = false;
262
266 std::source_location::current(),
267 "Failed to open RtAudio stream: {}",
268 m_context->getErrorText());
269 }
270}
static void mark_stream_closed()
Deregisters an active audio stream from the system.
static void mark_stream_open()
Registers an active audio stream in the system.
RtAudio::StreamOptions m_options
RtAudio-specific stream options.
GlobalStreamInfo m_stream_info
Copy of the stream configuration for reference.
bool m_isOpen
Flag indicating if the stream is currently open.
bool is_open() const override
Checks if the stream is initialized and ready for activation.
RtAudio::StreamParameters m_in_parameters
RtAudio-specific stream input configuration parameters.
RtAudio::StreamParameters m_out_parameters
RtAudio-specific stream output configuration parameters.
RtAudio * m_context
Pointer to the underlying RtAudio context.
static int rtAudioCallback(void *output_buffer, void *input_buffer, unsigned int num_frames, double stream_time, RtAudioStreamStatus status, void *user_data)
Static callback function for the RtAudio API.
@ AudioBackend
Audio processing backend (RtAudio, JACK, ASIO)
void error_rethrow(Component component, Context context, std::source_location location=std::source_location::current(), std::string_view additional_context="")
Catch and log an exception, then rethrow it.
std::string format(format_string< std::remove_cvref_t< Args >... > fmt_str, Args &&... args)
Definition Format.hpp:30
@ Core
Core engine, backend, subsystems.
uint32_t channels
Number of discrete channels in this set.
bool enabled
Whether this channel set is active in the stream.
uint32_t buffer_size
Number of samples per processing block.
ChannelConfig input
Configuration for input signal channels (disabled by default)
uint32_t sample_rate
Number of samples processed per second (Hz)
@ FLOAT64
64-bit floating point representation (-1.0 to 1.0)
@ INT16
16-bit integer representation (-32768 to 32767)
@ INT32
32-bit integer representation (-2147483648 to 2147483647)
@ INT24
24-bit integer representation (-8388608 to 8388607)
@ FLOAT32
32-bit floating point representation (-1.0 to 1.0)
AudioFormat format
Sample data format for stream processing.

References MayaFlux::Journal::AudioBackend, MayaFlux::Core::GlobalStreamInfo::buffer_size, MayaFlux::Core::GlobalStreamInfo::ChannelConfig::channels, MayaFlux::Journal::Core, MayaFlux::Core::GlobalStreamInfo::ChannelConfig::enabled, MayaFlux::Core::GlobalStreamInfo::FLOAT32, MayaFlux::Core::GlobalStreamInfo::FLOAT64, MayaFlux::Core::GlobalStreamInfo::format, MayaFlux::Core::GlobalStreamInfo::input, MayaFlux::Core::GlobalStreamInfo::INT16, MayaFlux::Core::GlobalStreamInfo::INT24, MayaFlux::Core::GlobalStreamInfo::INT32, is_open(), m_context, m_in_parameters, m_isOpen, m_options, m_out_parameters, m_stream_info, MayaFlux::Core::RtAudioSingleton::mark_stream_closed(), MayaFlux::Core::RtAudioSingleton::mark_stream_open(), rtAudioCallback(), and MayaFlux::Core::GlobalStreamInfo::sample_rate.

+ Here is the call graph for this function: