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

◆ make_sound_file_container()

MAYAFLUX_API std::shared_ptr< SoundFileContainer > MayaFlux::Kakshya::make_sound_file_container ( std::vector< std::vector< double > >  channel_data,
uint32_t  num_channels,
uint32_t  sample_rate = 48000,
OrganizationStrategy  org = OrganizationStrategy::PLANAR 
)

Construct a fully populated SoundFileContainer from computed channel data.

Produces a fixed-capacity, non-circular container suitable for any workflow that requires a materialized, ready-to-play audio buffer: grain reconstruction, offline synthesis, file-derived transforms, or any other computed source.

The container is configured with org as its organization strategy, a ContiguousAccessProcessor as its default processor, and its processing state set to READY on return.

Parameters
channel_dataPer-channel sample vectors. Consumed by move; must be non-empty, each vector non-empty, and the outer size must equal num_channels.
num_channelsNumber of audio channels. Must match channel_data.size().
sample_rateSample rate in Hz used for temporal calculations. *defaults to 48000 Hz.
orgMemory organisation strategy for the container's data layout. Defaults to PLANAR.
Returns
Shared pointer to a fully initialised SoundFileContainer.
Exceptions
std::invalid_argumentif channel_data is empty, any channel vector is empty, or num_channels does not match channel_data.size().

Definition at line 49 of file SoundFileContainer.cpp.

54{
55 if (channel_data.empty() || channel_data[0].size() == 0 || num_channels != channel_data.size()) {
56 error<std::invalid_argument>(
57 Journal::Component::Kakshya, Journal::Context::Configuration,
58 std::source_location::current(),
59 "build_sound_file_container: channel_data must be non-empty and match num_channels");
60 }
61
62 auto sc = std::make_shared<SoundFileContainer>();
63 sc->setup(channel_data[0].size(), sample_rate, num_channels);
64 sc->get_structure().organization = org;
65
66 std::vector<DataVariant> variants;
67 variants.reserve(num_channels);
68 for (auto& ch : channel_data)
69 variants.emplace_back(std::move(ch));
70
71 sc->set_raw_data(variants);
72 sc->create_default_processor();
73 sc->mark_ready_for_processing(true);
74 return sc;
75}

References MayaFlux::Journal::Configuration, and MayaFlux::Journal::Kakshya.