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

◆ create_samplers() [1/2]

MAYAFLUX_API std::vector< std::shared_ptr< Kriya::SamplingPipeline > > MayaFlux::create_samplers ( const std::string &  filepath,
uint32_t  num_samples = 48000 *5,
bool  truncate = true,
uint64_t  max_dur_ms = 0,
uint32_t  max_channels = 0 
)

Construct one built SamplingPipeline per channel from an audio file.

Loads the file once into a shared DynamicSoundStream, then constructs one SamplingPipeline per channel. All pipelines share the same stream with no redundant IO. max_channels = 0 uses all channels available in the file.

auto ch = MayaFlux::create_samplers("res/stereo.wav", 48000 * 5);
ch[0]->play(0, ch[0]->slice_from_stream());
ch[1]->play(0, ch[1]->slice_from_stream());
std::vector< std::shared_ptr< Kriya::SamplingPipeline > > create_samplers(const std::string &filepath, uint32_t num_samples, bool truncate, uint64_t max_dur_ms, uint32_t max_channels)
Construct one built SamplingPipeline per channel from an audio file.
Definition Rigs.cpp:106
Parameters
filepathPath to the audio file (any FFmpeg-supported format).
num_samplesNumber of samples to load (default: 48000 * 5).
truncateTruncate stream to num_samples if true (default: true).
max_dur_msOptional maximum duration in milliseconds. 0 for infinite.
max_channelsMaximum channels to create pipelines for. 0 = all available.
Returns
Vector of built SamplingPipelines, one per channel. Empty on load failure.

Definition at line 106 of file Rigs.cpp.

109{
110 auto stream = get_io_manager()->load_audio_bounded(filepath, num_samples, truncate);
111
112 if (!stream) {
113 MF_ERROR(Journal::Component::API, Journal::Context::FileIO,
114 "create_samplers: failed to load '{}'", filepath);
115 return {};
116 }
117
118 return samplers_from_stream(stream, max_dur_ms, max_channels);
119}
#define MF_ERROR(comp, ctx,...)
Core::GlobalStreamInfo stream
Definition Config.cpp:40
std::shared_ptr< IO::IOManager > get_io_manager()
Retrieves the global IOManager instance for file loading and buffer management.
Definition Depot.cpp:575

References MayaFlux::Journal::API, MayaFlux::Journal::FileIO, get_io_manager(), MF_ERROR, and stream.

+ Here is the call graph for this function: