MayaFlux 0.4.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 988 of file Yantra.cpp.

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

References MayaFlux::Journal::API.

Referenced by mix_with_gains().

+ Here is the caller graph for this function: