MayaFlux 0.4.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 50 of file SoundFileContainer.cpp.

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

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