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

◆ mix() [1/2]

MAYAFLUX_API std::vector< double > MayaFlux::mix ( const std::vector< Kakshya::DataVariant > &  streams)

Definition at line 1045 of file Yantra.cpp.

1046{
1047 if (streams.empty())
1048 return {};
1049
1050 auto numeric_data = Yantra::OperationHelper::extract_numeric_data(streams);
1051
1052 if (is_same_size(numeric_data)) {
1053 size_t channel_length = numeric_data[0].size();
1054 std::vector<double> result(channel_length, 0.0);
1055
1056 for (const auto& span : numeric_data) {
1057 for (size_t i = 0; i < span.size(); ++i) {
1058 result[i] += span[i];
1059 }
1060 }
1061
1062 double gain = 1.0 / static_cast<double>(numeric_data.size());
1063 apply_gain(result, gain);
1064
1065 return result;
1066 } else {
1067 std::vector<std::vector<double>> double_streams;
1068 double_streams.reserve(streams.size());
1069
1070 for (const auto& span : numeric_data) {
1071 double_streams.emplace_back(span.begin(), span.end());
1072 }
1073
1074 return mix(double_streams);
1075 }
1076}
void apply_gain(std::vector< double > &data, double gain_factor)
Apply gain to single-channel data (in-place)
Definition Yantra.cpp:491
std::vector< double > mix(const std::vector< std::vector< double > > &streams)
Mix multiple data streams with equal weighting.
Definition Yantra.cpp:1021

References apply_gain(), MayaFlux::Yantra::OperationHelper::extract_numeric_data(), is_same_size(), and mix().

+ Here is the call graph for this function: