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 278 of file IOManager.cpp.

282{
283 auto reader = std::make_shared<IO::SoundFileReader>();
284
285 if (!reader->can_read(filepath)) {
287 "IOManager::load_bounded: unsupported format '{}'", filepath);
288 return nullptr;
289 }
290
291 reader->set_target_sample_rate(m_sample_rate);
292
293 auto stream = reader->load_bounded(filepath, max_frames, truncate);
294 if (!stream) {
296 "IOManager::load_bounded: failed for '{}'", filepath);
297 return nullptr;
298 }
299
300 stream->set_memory_layout(Kakshya::MemoryLayout::ROW_MAJOR);
301
302 m_audio_readers.push_back(std::move(reader));
303
304 return stream;
305}
#define MF_ERROR(comp, ctx,...)
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)

References MayaFlux::Journal::API, MayaFlux::Journal::FileIO, m_audio_readers, m_sample_rate, MF_ERROR, and MayaFlux::Kakshya::ROW_MAJOR.