MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
SoundFileContainer.cpp
Go to the documentation of this file.
2
3namespace MayaFlux::Kakshya {
4
6 : SoundStreamContainer(48000, 2, 0, false) // Default: 48kHz, stereo, no initial capacity, not circular
7{
8}
9
10SoundFileContainer::SoundFileContainer(uint32_t sample_rate, uint32_t num_channels, uint64_t initial_capacity)
11 : SoundStreamContainer(sample_rate, num_channels, initial_capacity, false) // Files are not circular
12{
13}
14
15void SoundFileContainer::setup(uint64_t num_frames, uint32_t sample_rate, uint32_t num_channels)
16{
17 std::unique_lock lock(m_data_mutex);
18
19 m_num_frames = num_frames;
20 m_sample_rate = sample_rate;
21 m_num_channels = num_channels;
22
25}
26
27void SoundFileContainer::set_raw_data(const std::vector<DataVariant>& data)
28{
29 std::unique_lock lock(m_data_mutex);
30
31 m_data.resize(data.size());
32 std::ranges::copy(data, m_data.begin());
33
34 if (!m_data.empty()) {
35 auto elements = std::visit([](const auto& vec) { return vec.size(); }, m_data[0]);
37 ? elements / m_num_channels
38 : elements;
39 }
40
42 m_double_extraction_dirty.store(true, std::memory_order_release);
43}
44
49
50} // namespace MayaFlux::Kakshya
void setup(uint64_t num_frames, uint32_t sample_rate, uint32_t num_channels)
Setup the container with file parameters.
SoundFileContainer()
Construct a SoundFileContainer with default parameters Uses reasonable defaults suitable for file con...
void set_raw_data(const std::vector< DataVariant > &data)
Set raw data from external source (e.g., file loading)
double get_duration_seconds() const
Enable debug output for this container.
double position_to_time(uint64_t position) const override
Convert from position units (e.g., frame/sample index) to time (seconds).
void update_processing_state(ProcessingState new_state) override
Update the processing state of the container.
void lock() override
Acquire a lock for thread-safe access.
Concrete base implementation for streaming audio containers.
@ IDLE
Container is inactive with no data or not ready for processing.
@ INTERLEAVED
Single DataVariant with interleaved data (LRLRLR for stereo)