]> git.sesse.net Git - nageru/commitdiff
Add some more command-line flags for initial audio settings. (Still not complete.)
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 22 Jul 2016 19:43:40 +0000 (21:43 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 22 Jul 2016 19:43:40 +0000 (21:43 +0200)
flags.cpp
flags.h
mainwindow.cpp
mixer.cpp
mixer.h

index 580b42123e4f08d568f7f33bd12a003eef92ceb7..f0d2b2b8868d98bfcae254c026f85745ef17a6ea 100644 (file)
--- a/flags.cpp
+++ b/flags.cpp
@@ -44,6 +44,14 @@ void usage()
        fprintf(stderr, "      --http-coarse-timebase      use less timebase for HTTP (recommended for muxers\n");
        fprintf(stderr, "                                  that handle large pts poorly, like e.g. MP4)\n");
        fprintf(stderr, "      --flat-audio                start with most audio processing turned off\n");
+       fprintf(stderr, "                                    (can be overridden by e.g. --enable-limiter)\n");
+       fprintf(stderr, "      --gain-staging=DB           set initial gain staging to the given value\n");
+       fprintf(stderr, "                                    (--disable-gain-staging-auto)\n");
+       fprintf(stderr, "      --disable-locut             turn off locut filter (also --enable)\n");
+       fprintf(stderr, "      --disable-gain-staging-auto  turn off automatic gain staging (also --enable)\n");
+       fprintf(stderr, "      --disable-compressor        turn off regular compressor (also --enable)\n");
+       fprintf(stderr, "      --disable-limiter           turn off limiter (also --enable)\n");
+       fprintf(stderr, "      --disable-makeup-gain-auto  turn off auto-adjustment of final makeup gain (also --enable)\n");
        fprintf(stderr, "      --disable-alsa-output       disable audio monitoring via ALSA\n");
        fprintf(stderr, "      --no-flush-pbos             do not explicitly signal texture data uploads\n");
        fprintf(stderr, "                                    (will give display corruption, but makes it\n");
@@ -74,6 +82,17 @@ void parse_flags(int argc, char * const argv[])
                { "http-audio-codec", required_argument, 0, 1006 },
                { "http-audio-bitrate", required_argument, 0, 1007 },
                { "flat-audio", no_argument, 0, 1002 },
+               { "gain-staging", required_argument, 0, 1018 },
+               { "disable-locut", no_argument, 0, 1019 },
+               { "enable-locut", no_argument, 0, 1020 },
+               { "disable-gain-staging-auto", no_argument, 0, 1021 },
+               { "enable-gain-staging-auto", no_argument, 0, 1022 },
+               { "disable-compressor", no_argument, 0, 1023 },
+               { "enable-compressor", no_argument, 0, 1024 },
+               { "disable-limiter", no_argument, 0, 1025 },
+               { "enable-limiter", no_argument, 0, 1026 },
+               { "disable-makeup-gain-auto", no_argument, 0, 1027 },
+               { "enable-makeup-gain-auto", no_argument, 0, 1028 },
                { "disable-alsa-output", no_argument, 0, 1014 },
                { "no-flush-pbos", no_argument, 0, 1003 },
                { 0, 0, 0, 0 }
@@ -158,7 +177,46 @@ void parse_flags(int argc, char * const argv[])
                        global_flags.x264_extra_param.push_back(optarg);
                        break;
                case 1002:
-                       global_flags.flat_audio = true;
+                       // If --flat-audio is given, turn off everything that messes with the sound,
+                       // except the final makeup gain.
+                       global_flags.locut_enabled = false;
+                       global_flags.gain_staging_auto = false;
+                       global_flags.compressor_enabled = false;
+                       global_flags.limiter_enabled = false;
+                       break;
+               case 1018:
+                       global_flags.initial_gain_staging_db = atof(optarg);
+                       global_flags.gain_staging_auto = false;
+                       break;
+               case 1019:
+                       global_flags.locut_enabled = false;
+                       break;
+               case 1020:
+                       global_flags.locut_enabled = true;
+                       break;
+               case 1021:
+                       global_flags.gain_staging_auto = false;
+                       break;
+               case 1022:
+                       global_flags.gain_staging_auto = true;
+                       break;
+               case 1023:
+                       global_flags.compressor_enabled = false;
+                       break;
+               case 1024:
+                       global_flags.compressor_enabled = true;
+                       break;
+               case 1025:
+                       global_flags.limiter_enabled = false;
+                       break;
+               case 1026:
+                       global_flags.limiter_enabled = true;
+                       break;
+               case 1027:
+                       global_flags.final_makeup_gain_auto = false;
+                       break;
+               case 1028:
+                       global_flags.final_makeup_gain_auto = true;
                        break;
                case 1014:
                        global_flags.enable_alsa_output = false;
diff --git a/flags.h b/flags.h
index a73a48e94a4807a6f085b85e96cb371c0177d442..7d4abd2e436c9789fd7e33771d8275ef42903d70 100644 (file)
--- a/flags.h
+++ b/flags.h
@@ -14,7 +14,12 @@ struct Flags {
        bool uncompressed_video_to_http = false;
        bool x264_video_to_http = false;
        std::string theme_filename = "theme.lua";
-       bool flat_audio = false;
+       bool locut_enabled = true;
+       bool gain_staging_auto = true;
+       float initial_gain_staging_db = 0.0f;
+       bool compressor_enabled = true;
+       bool limiter_enabled = true;
+       bool final_makeup_gain_auto = true;
        bool flush_pbos = true;
        std::string stream_mux_name = DEFAULT_STREAM_MUX_NAME;
        bool stream_coarse_timebase = false;
index 4b8eb51482543b01549a36d02a19c286f14abcc4..e4f52f4d874d2729409a9d0a60b7d7fbee504427 100644 (file)
@@ -129,11 +129,13 @@ void MainWindow::mixer_created(Mixer *mixer)
        }
 
        // TODO: Fetch all of the values these for completeness,
-       // not just the enable knobs implied by --flat-audio.
+       // not just the enable knobs implied by flags.
        ui->locut_enabled->setChecked(global_mixer->get_locut_enabled());
+       ui->gainstaging_knob->setValue(global_mixer->get_gain_staging_db());
        ui->gainstaging_auto_checkbox->setChecked(global_mixer->get_gain_staging_auto());
-       ui->limiter_enabled->setChecked(global_mixer->get_limiter_enabled());
        ui->compressor_enabled->setChecked(global_mixer->get_compressor_enabled());
+       ui->limiter_enabled->setChecked(global_mixer->get_limiter_enabled());
+       ui->makeup_gain_auto_checkbox->setChecked(global_mixer->get_final_makeup_gain_auto());
 
        char buf[256];
        snprintf(buf, sizeof(buf), "%.1f dB", mixer->get_limiter_threshold_dbfs());
index 4035ea67351ec5abafd10337e538951910d26363..e24d0bb9f0ef14acd05e738b28179d373bbd1e5f 100644 (file)
--- a/mixer.cpp
+++ b/mixer.cpp
@@ -268,14 +268,12 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards)
 
        locut.init(FILTER_HPF, 2);
 
-       // If --flat-audio is given, turn off everything that messes with the sound,
-       // except the final makeup gain.
-       if (global_flags.flat_audio) {
-               set_locut_enabled(false);
-               set_gain_staging_auto(false);
-               set_limiter_enabled(false);
-               set_compressor_enabled(false);
-       }
+       set_locut_enabled(global_flags.locut_enabled);
+       set_gain_staging_db(global_flags.initial_gain_staging_db);
+       set_gain_staging_auto(global_flags.gain_staging_auto);
+       set_compressor_enabled(global_flags.compressor_enabled);
+       set_limiter_enabled(global_flags.limiter_enabled);
+       set_final_makeup_gain_auto(global_flags.final_makeup_gain_auto);
 
        // hlen=16 is pretty low quality, but we use quite a bit of CPU otherwise,
        // and there's a limit to how important the peak meter is.
diff --git a/mixer.h b/mixer.h
index 21b22552049d78c7ec9e7438648fccfcb7ed987e..a09268996688918de9533c6a0e6a1ee82f15c043 100644 (file)
--- a/mixer.h
+++ b/mixer.h
@@ -301,6 +301,12 @@ public:
                gain_staging_db = gain_db;
        }
 
+       float get_gain_staging_db() const
+       {
+               std::unique_lock<std::mutex> lock(compressor_mutex);
+               return gain_staging_db;
+       }
+
        void set_gain_staging_auto(bool enabled)
        {
                std::unique_lock<std::mutex> lock(compressor_mutex);
@@ -326,6 +332,12 @@ public:
                final_makeup_gain_auto = enabled;
        }
 
+       bool get_final_makeup_gain_auto() const
+       {
+               std::unique_lock<std::mutex> lock(compressor_mutex);
+               return final_makeup_gain_auto;
+       }
+
        void schedule_cut()
        {
                should_cut = true;