]> git.sesse.net Git - nageru/commitdiff
Mix all channels instead of just picking one (very rough, no volume control or anything).
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 29 Jul 2016 13:20:51 +0000 (15:20 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 19 Oct 2016 22:55:44 +0000 (00:55 +0200)
mixer.cpp

index 1a4b2cf141ab1562e9eae438a3bc458ded7af476..fc66cdefe43dc14d26871c6b6ff646b155d0991b 100644 (file)
--- a/mixer.cpp
+++ b/mixer.cpp
@@ -984,8 +984,9 @@ void Mixer::process_audio_one_frame(int64_t frame_pts_int, int num_samples, bool
 {
        vector<float> samples_card;
        vector<float> samples_out;
+       samples_out.resize(num_samples * 2);
 
-       // TODO: Allow mixing audio from several sources.
+       // TODO: Allow more flexible input mapping.
        unsigned selected_audio_card = theme->map_signal(audio_source_channel);
        assert(selected_audio_card < num_cards);
 
@@ -1001,8 +1002,14 @@ void Mixer::process_audio_one_frame(int64_t frame_pts_int, int num_samples, bool
                                num_samples,
                                rate_adjustment_policy);
                }
-               if (card_index == selected_audio_card) {
-                       samples_out = move(samples_card);
+               if (card_index == 0) {
+                       for (int i = 0; i < num_samples * 2; ++i) {
+                               samples_out[i] = samples_card[i];
+                       }
+               } else {
+                       for (int i = 0; i < num_samples * 2; ++i) {
+                               samples_out[i] += samples_card[i];
+                       }
                }
        }