MayaFlux 0.4.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 299 of file IOManager.cpp.

303{
304 auto reader = std::make_shared<IO::SoundFileReader>();
305
306 if (!reader->can_read(filepath)) {
308 "IOManager::load_bounded: unsupported format '{}'", filepath);
309 return nullptr;
310 }
311
312 reader->set_target_sample_rate(m_stream_info.sample_rate);
313
314 auto stream = reader->load_bounded(filepath, max_frames, truncate);
315 if (!stream) {
317 "IOManager::load_bounded: failed for '{}'", filepath);
318 return nullptr;
319 }
320
321 stream->set_memory_layout(Kakshya::MemoryLayout::ROW_MAJOR);
322
323 m_audio_readers.push_back(std::move(reader));
324
325 return stream;
326}
#define MF_ERROR(comp, ctx,...)
Core::GlobalStreamInfo stream
Definition Config.cpp:34
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.