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

◆ mix_with_gains() [1/2]

MAYAFLUX_API std::vector< double > MayaFlux::mix_with_gains ( const std::vector< Kakshya::DataVariant > &  streams,
const std::vector< double > &  gains 
)

Definition at line 1007 of file Yantra.cpp.

1008{
1009 if (streams.empty() || gains.size() != streams.size()) {
1010 error<std::invalid_argument>(Journal::Component::API, Journal::Context::API, std::source_location::current(),
1011 "Streams and gains vectors must have the same size");
1012 }
1013
1014 auto numeric_data = Yantra::OperationHelper::extract_numeric_data(streams);
1015
1016 if (is_same_size(numeric_data)) {
1017 std::vector<double> result(numeric_data[0].size(), 0.0);
1018 for (size_t s = 0; s < numeric_data.size(); ++s) {
1019 for (size_t i = 0; i < numeric_data[s].size(); ++i)
1020 result[i] += numeric_data[s][i] * gains[s];
1021 }
1022 return result;
1023 }
1024
1025 std::vector<std::vector<double>> double_streams;
1026 double_streams.reserve(streams.size());
1027 for (const auto& span : numeric_data)
1028 double_streams.emplace_back(span.begin(), span.end());
1029 return mix_with_gains(double_streams, gains);
1030}
Range size
std::vector< double > mix_with_gains(const std::vector< std::vector< double > > &streams, const std::vector< double > &gains)
Mix multiple data streams with specified gains.
Definition Yantra.cpp:988

References MayaFlux::Journal::API, MayaFlux::Yantra::OperationHelper::extract_numeric_data(), mix_with_gains(), and size.

+ Here is the call graph for this function: