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

◆ load_audio_bounded()

std::shared_ptr< Kakshya::DynamicSoundStream > MayaFlux::IO::IOManager::load_audio_bounded ( const std::string &  filepath,
uint64_t  max_frames = 0,
bool  truncate = false 
)

Load an audio file into a fully resident, size-bounded DynamicSoundStream.

Applies the engine sample rate, ROW_MAJOR layout, and the engine buffer size as the CursorAccessProcessor block size. The result is ready for use with StreamSliceProcessor without any further configuration.

Parameters
filepathPath to the audio file.
max_framesUpper bound on frame count. 0 defaults to 5 s at the engine sample rate inside SoundFileReader::load_bounded.
truncateIf true, silently truncate files exceeding max_frames.
Returns
Configured DynamicSoundStream, or nullptr on failure.

Definition at line 456 of file IOManager.cpp.

460{
461 auto reader = std::make_shared<IO::SoundFileReader>();
462
463 if (!reader->can_read(filepath)) {
465 "IOManager::load_bounded: unsupported format '{}'", filepath);
466 return nullptr;
467 }
468
469 reader->set_target_sample_rate(m_stream_info.sample_rate);
470
471 auto stream = reader->load_bounded(filepath, max_frames, truncate);
472 if (!stream) {
474 "IOManager::load_bounded: failed for '{}'", filepath);
475 return nullptr;
476 }
477
478 stream->set_memory_layout(Kakshya::MemoryLayout::ROW_MAJOR);
479
480 m_audio_readers.push_back(std::move(reader));
481
482 return stream;
483}
#define MF_ERROR(comp, ctx,...)
Core::GlobalStreamInfo stream
Definition Config.cpp:40
Core::GlobalStreamInfo & m_stream_info
std::vector< std::shared_ptr< SoundFileReader > > m_audio_readers
@ FileIO
Filesystem I/O operations.
@ API
MayaFlux/API Wrapper and convenience functions.
@ ROW_MAJOR
C/C++ style (last dimension varies fastest)
uint32_t sample_rate
Number of samples processed per second (Hz)

References MayaFlux::Journal::API, MayaFlux::Journal::FileIO, m_audio_readers, m_stream_info, MF_ERROR, MayaFlux::Kakshya::ROW_MAJOR, MayaFlux::Core::GlobalStreamInfo::sample_rate, and stream.