}
connect(ui->locut_cutoff_knob, &QDial::valueChanged, this, &MainWindow::cutoff_knob_changed);
+ connect(ui->limiter_threshold_knob, &QDial::valueChanged, this, &MainWindow::limiter_threshold_knob_changed);
+ connect(ui->compressor_threshold_knob, &QDial::valueChanged, this, &MainWindow::compressor_threshold_knob_changed);
+ connect(ui->limiter_enabled, &QCheckBox::stateChanged, [this](int state){
+ global_mixer->set_limiter_enabled(state == Qt::Checked);
+ });
+ connect(ui->compressor_enabled, &QCheckBox::stateChanged, [this](int state){
+ global_mixer->set_compressor_enabled(state == Qt::Checked);
+ });
connect(ui->reset_meters_button, &QPushButton::clicked, this, &MainWindow::reset_meters_button_clicked);
mixer->set_audio_level_callback(bind(&MainWindow::audio_level_callback, this, _1, _2, _3, _4, _5, _6));
}
ui->locut_cutoff_display->setText(buf);
}
+void MainWindow::limiter_threshold_knob_changed(int value)
+{
+ float threshold_dbfs = value * 0.1f;
+ global_mixer->set_limiter_threshold_dbfs(threshold_dbfs);
+
+ char buf[256];
+ snprintf(buf, sizeof(buf), "%.1f dB", threshold_dbfs);
+ ui->limiter_threshold_db_display->setText(buf);
+}
+
+void MainWindow::compressor_threshold_knob_changed(int value)
+{
+ float threshold_dbfs = value * 0.1f;
+ global_mixer->set_compressor_threshold_dbfs(threshold_dbfs);
+
+ char buf[256];
+ snprintf(buf, sizeof(buf), "%.1f dB", threshold_dbfs);
+ ui->compressor_threshold_db_display->setText(buf);
+}
+
void MainWindow::reset_meters_button_clicked()
{
global_mixer->reset_meters();
void wb_button_clicked(int channel_number);
void set_transition_names(std::vector<std::string> transition_names);
void cutoff_knob_changed(int value);
+ void limiter_threshold_knob_changed(int value);
+ void compressor_threshold_knob_changed(int value);
void reset_meters_button_clicked();
void relayout();
// Then a limiter at +0 dB (so, -14 dBFS) to take out the worst peaks only.
// Note that since ratio is not infinite, we could go slightly higher than this.
// Probably more tuning is warranted here.
- {
- float threshold = pow(10.0f, (ref_level_dbfs + 0.0f) / 20.0f); // +0 dB.
+ if (limiter_enabled) {
+ float threshold = pow(10.0f, limiter_threshold_dbfs / 20.0f);
float ratio = 30.0f;
float attack_time = 0.0f; // Instant.
float release_time = 0.005f;
}
// Finally, the real compressor.
- {
- float threshold = pow(10.0f, (ref_level_dbfs - 12.0f) / 20.0f); // -12 dB.
+ if (compressor_enabled) {
+ float threshold = pow(10.0f, compressor_threshold_dbfs / 20.0f);
float ratio = 20.0f;
float attack_time = 0.005f;
float release_time = 0.040f;
locut_cutoff_hz = cutoff_hz;
}
+ void set_limiter_threshold_dbfs(float threshold_dbfs)
+ {
+ limiter_threshold_dbfs = threshold_dbfs;
+ }
+
+ void set_compressor_threshold_dbfs(float threshold_dbfs)
+ {
+ compressor_threshold_dbfs = threshold_dbfs;
+ }
+
+ void set_limiter_enabled(bool enabled)
+ {
+ limiter_enabled = enabled;
+ }
+
+ void set_compressor_enabled(bool enabled)
+ {
+ compressor_enabled = enabled;
+ }
+
void reset_meters();
private:
StereoCompressor level_compressor;
float last_gain_staging_db = 0.0f;
+ static constexpr float ref_level_dbfs = -14.0f;
+
StereoCompressor limiter;
+ std::atomic<float> limiter_threshold_dbfs{ref_level_dbfs + 0.0f}; // 0 dB.
+ std::atomic<bool> limiter_enabled{true};
StereoCompressor compressor;
+ std::atomic<float> compressor_threshold_dbfs{ref_level_dbfs - 12.0f}; // -12 dB.
+ std::atomic<bool> compressor_enabled{true};
};
extern Mixer *global_mixer;
</property>
<property name="maximumSize">
<size>
- <width>65536</width>
+ <width>16777215</width>
<height>64</height>
</size>
</property>
</property>
</widget>
</item>
- <item row="1" column="2">
+ <item row="1" column="4">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<property name="text">
<string>Auto</string>
</property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
</widget>
</item>
<item row="1" column="0">
</property>
<property name="maximumSize">
<size>
- <width>65536</width>
+ <width>16777215</width>
<height>64</height>
</size>
</property>
</property>
</widget>
</item>
+ <item row="3" column="0">
+ <widget class="QComboBox" name="comboBox">
+ <property name="currentText">
+ <string/>
+ </property>
+ </widget>
+ </item>
<item row="0" column="0">
- <widget class="QLabel" name="label_3">
+ <widget class="QLabel" name="locut_cutoff_label">
<property name="text">
<string>Lo-cut (24dB/oct)</string>
</property>
</property>
</widget>
</item>
- <item row="3" column="0">
- <widget class="QComboBox" name="comboBox">
- <property name="currentText">
- <string/>
+ <item row="3" column="2">
+ <widget class="QCheckBox" name="limiter_enabled">
+ <property name="text">
+ <string>Enabled</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QDial" name="limiter_threshold_knob">
+ <property name="minimumSize">
+ <size>
+ <width>64</width>
+ <height>64</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>64</height>
+ </size>
+ </property>
+ <property name="minimum">
+ <number>-400</number>
+ </property>
+ <property name="maximum">
+ <number>0</number>
+ </property>
+ <property name="value">
+ <number>-140</number>
+ </property>
+ <property name="notchTarget">
+ <double>30.000000000000000</double>
+ </property>
+ <property name="notchesVisible">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QLabel" name="limiter_threshold_label">
+ <property name="text">
+ <string>Limiter threshold</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QLabel" name="limiter_threshold_db_display">
+ <property name="text">
+ <string>-14.0 dB</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QDial" name="compressor_threshold_knob">
+ <property name="minimumSize">
+ <size>
+ <width>64</width>
+ <height>64</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>64</height>
+ </size>
+ </property>
+ <property name="minimum">
+ <number>-400</number>
+ </property>
+ <property name="maximum">
+ <number>0</number>
+ </property>
+ <property name="value">
+ <number>-260</number>
+ </property>
+ <property name="notchTarget">
+ <double>30.000000000000000</double>
+ </property>
+ <property name="notchesVisible">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QLabel" name="compressor_threshold_label">
+ <property name="text">
+ <string>Compr. threshold</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="QLabel" name="compressor_threshold_db_display">
+ <property name="text">
+ <string>-26.0 dB</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="3">
+ <widget class="QCheckBox" name="compressor_enabled">
+ <property name="text">
+ <string>Enabled</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
</property>
</widget>
</item>