MayaFlux 0.3.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 1104 of file Yantra.cpp.

1106{
1107 if (streams.empty() || gains.size() != streams.size()) {
1108 throw std::invalid_argument("Streams and gains vectors must have the same size");
1109 }
1110
1111 auto numeric_data = Yantra::OperationHelper::extract_numeric_data(streams);
1112
1113 if (is_same_size(numeric_data)) {
1114 size_t channel_length = numeric_data[0].size();
1115 std::vector<double> result(channel_length, 0.0);
1116
1117 for (size_t s = 0; s < numeric_data.size(); ++s) {
1118 const auto& span = numeric_data[s];
1119 double gain = gains[s];
1120
1121 for (size_t i = 0; i < span.size(); ++i) {
1122 result[i] += span[i] * gain;
1123 }
1124 }
1125
1126 return result;
1127 }
1128
1129 std::vector<std::vector<double>> double_streams;
1130 double_streams.reserve(streams.size());
1131
1132 for (const auto& span : numeric_data) {
1133 double_streams.emplace_back(span.begin(), span.end());
1134 }
1135
1136 return mix_with_gains(double_streams, gains);
1137}
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:1078

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

+ Here is the call graph for this function: