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

◆ mix_with_gains() [2/2]

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

Mix multiple data streams with specified gains.

Parameters
streamsVector of data streams to mix
gainsVector of gain factors (must match streams.size())
Returns
Mixed output data
Exceptions
std::invalid_argumentif gains.size() != streams.size()

Definition at line 1076 of file Yantra.cpp.

1078{
1079 if (streams.empty() || gains.size() != streams.size()) {
1080 throw std::invalid_argument("Streams and gains vectors must have the same size");
1081 }
1082
1083 size_t max_length = 0;
1084 for (const auto& stream : streams) {
1085 max_length = std::max(max_length, stream.size());
1086 }
1087
1088 std::vector<double> result(max_length, 0.0);
1089
1090 for (size_t s = 0; s < streams.size(); ++s) {
1091 const auto& stream = streams[s];
1092 double gain = gains[s];
1093
1094 for (size_t i = 0; i < stream.size(); ++i) {
1095 result[i] += stream[i] * gain;
1096 }
1097 }
1098
1099 return result;
1100}

Referenced by mix_with_gains().

+ Here is the caller graph for this function: