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

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

Referenced by mix_with_gains().

+ Here is the caller graph for this function: