Load file data into an existing SignalSourceContainer.
816{
817 if (!container) {
819 return false;
820 }
821
822 auto sound_container = std::dynamic_pointer_cast<Kakshya::SoundFileContainer>(container);
823 if (!sound_container) {
824 set_error(
"Container is not a SoundFileContainer");
825 return false;
826 }
827
829 if (!metadata) {
831 return false;
832 }
833
834 auto total_frames = metadata->get_attribute<uint64_t>("total_frames").value_or(0);
835 auto sample_rate = metadata->get_attribute<uint32_t>("sample_rate").value_or(48000);
836 auto channels = metadata->get_attribute<uint32_t>("channels").value_or(2);
837
838 sound_container->setup(total_frames, sample_rate, channels);
839
842 } else {
844 }
845
846 std::vector<Kakshya::DataVariant> audio_data =
read_all();
847
848 if (audio_data.empty()) {
850 return false;
851 }
852
853 sound_container->set_raw_data(audio_data);
854
857 for (const auto& [name, group] : region_groups) {
858 sound_container->add_region_group(group);
859 }
860
861 sound_container->create_default_processor();
862 sound_container->mark_ready_for_processing(true);
863
864 return true;
865}
static std::unordered_map< std::string, Kakshya::RegionGroup > regions_to_groups(const std::vector< FileRegion > ®ions)
Convert file regions to region groups.
std::vector< Kakshya::DataVariant > read_all() override
Read the entire audio file into memory.
void set_error(const std::string &error) const
Set the last error message.
AudioReadOptions m_audio_options
Audio-specific read options.
std::optional< FileMetadata > get_metadata() const override
Get metadata for the currently open file.
std::vector< FileRegion > get_regions() const override
Get all regions (markers, loops, etc.) from the file.
@ PLANAR
Separate DataVariant per logical unit (LLL...RRR for stereo)
@ INTERLEAVED
Single DataVariant with interleaved data (LRLRLR for stereo)