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

◆ create_sampler_from_stream()

MAYAFLUX_API std::shared_ptr< Kriya::SamplingPipeline > MayaFlux::create_sampler_from_stream ( std::shared_ptr< Kakshya::DynamicSoundStream stream,
uint32_t  channel = 0,
uint64_t  max_dur_ms = 0 
)

Construct a built SamplingPipeline from an existing DynamicSoundStream.

Allows multiple SamplingPipeline instances to share a single loaded stream, one per output channel, without re-reading the file. The stream is typically obtained from a previously created sampler via get_stream(), or loaded directly via get_io_manager()->load_audio_bounded().

auto ch0 = MayaFlux::create_sampler("res/audio.wav", 48000 * 5);
auto ch1 = MayaFlux::create_sampler_from_stream(ch0->get_stream(), 1);
auto ch2 = MayaFlux::create_sampler_from_stream(ch0->get_stream(), 2);
std::shared_ptr< Kriya::SamplingPipeline > create_sampler(const std::string &filepath, uint32_t num_samples, bool truncate, uint32_t channel, uint64_t max_dur_ms)
Construct a built SamplingPipeline from an audio file.
Definition Rigs.cpp:15
std::shared_ptr< Kriya::SamplingPipeline > create_sampler_from_stream(std::shared_ptr< Kakshya::DynamicSoundStream > stream, uint32_t channel, uint64_t max_dur_ms)
Construct a built SamplingPipeline from an existing DynamicSoundStream.
Definition Rigs.cpp:43
Parameters
streamLoaded DynamicSoundStream to share.
channelOutput channel index (default: 0).
max_dur_msOptional maximum duration in milliseconds. 0 for infinite.
Returns
Built SamplingPipeline, or nullptr if stream is null.

Definition at line 43 of file Rigs.cpp.

46{
47 if (!stream)
48 return nullptr;
49
50 auto& mgr = *get_buffer_manager();
51 auto& sched = *get_scheduler();
52 const uint32_t buf_size = Config::get_buffer_size();
53
54 auto sampler = std::make_shared<Kriya::SamplingPipeline>(
55 std::move(stream), mgr, sched, channel, buf_size);
56
57 if (max_dur_ms > 0) {
58 sampler->build_for(max_dur_ms);
59 } else {
60 sampler->build();
61 }
62
63 return sampler;
64}
uint32_t channel
std::shared_ptr< Buffers::BufferManager > get_buffer_manager()
Gets the buffer manager from the default engine.
Definition Graph.cpp:133
std::shared_ptr< Vruta::TaskScheduler > get_scheduler()
Gets the task scheduler from the default engine.
Definition Chronie.cpp:22

References channel, get_buffer_manager(), MayaFlux::Config::get_buffer_size(), and get_scheduler().

Referenced by create_samplers().

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