MayaFlux 0.5.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 985 of file Yantra.cpp.

986{
987 if (streams.empty() || gains.size() != streams.size()) {
988 error<std::invalid_argument>(Journal::Component::API, Journal::Context::API, std::source_location::current(),
989 "Streams and gains vectors must have the same size");
990 }
991
992 size_t max_length = 0;
993 for (const auto& s : streams)
994 max_length = std::max(max_length, s.size());
995
996 std::vector<double> result(max_length, 0.0);
997 for (size_t s = 0; s < streams.size(); ++s) {
998 for (size_t i = 0; i < streams[s].size(); ++i)
999 result[i] += streams[s][i] * gains[s];
1000 }
1001 return result;
1002}

References MayaFlux::Journal::API.

Referenced by mix_with_gains().

+ Here is the caller graph for this function: