MCPcopy Create free account
hub / github.com/FastLED/FastLED / mixPcm

Function mixPcm

tests/fl/audio/detector/vocal_real_audio.hpp:111–123  ·  view source on GitHub ↗

--- Utility: Mix two PCM streams ---

Source from the content-addressed store, hash-verified

109
110// --- Utility: Mix two PCM streams ---
111static fl::vector<fl::i16> mixPcm(fl::span<const fl::i16> a, fl::span<const fl::i16> b,
112 float ratioA, float ratioB) {
113 fl::size len = fl::min(a.size(), b.size());
114 fl::vector<fl::i16> out;
115 out.reserve(len);
116 for (fl::size i = 0; i < len; ++i) {
117 float mixed = static_cast<float>(a[i]) * ratioA + static_cast<float>(b[i]) * ratioB;
118 if (mixed > 32767.0f) mixed = 32767.0f;
119 if (mixed < -32768.0f) mixed = -32768.0f;
120 out.push_back(static_cast<fl::i16>(mixed));
121 }
122 return out;
123}
124
125// --- Utility: Run audio::detector::Vocal over PCM stream ---
126struct RealAudioResult {

Callers 1

Calls 3

sizeMethod · 0.45
reserveMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected