for (unsigned bus_index = 0; bus_index < MAX_BUSES; ++bus_index) {
locut[bus_index].init(FILTER_HPF, 2);
- locut_enabled[bus_index] = global_flags.locut_enabled;
eq[bus_index][EQ_BAND_BASS].init(FILTER_LOW_SHELF, 1);
// Note: EQ_BAND_MID isn't used (see comments in apply_eq()).
eq[bus_index][EQ_BAND_TREBLE].init(FILTER_HIGH_SHELF, 1);
-
- gain_staging_db[bus_index] = global_flags.initial_gain_staging_db;
compressor[bus_index].reset(new StereoCompressor(OUTPUT_FREQUENCY));
- compressor_threshold_dbfs[bus_index] = ref_level_dbfs - 12.0f; // -12 dB.
- compressor_enabled[bus_index] = global_flags.compressor_enabled;
level_compressor[bus_index].reset(new StereoCompressor(OUTPUT_FREQUENCY));
- level_compressor_enabled[bus_index] = global_flags.gain_staging_auto;
+
+ set_bus_settings(bus_index, get_default_bus_settings());
}
set_limiter_enabled(global_flags.limiter_enabled);
set_final_makeup_gain_auto(global_flags.final_makeup_gain_auto);
return true;
}
+AudioMixer::BusSettings AudioMixer::get_default_bus_settings()
+{
+ BusSettings settings;
+ settings.fader_volume_db = 0.0f;
+ settings.locut_enabled = global_flags.locut_enabled;
+ for (unsigned band_index = 0; band_index < NUM_EQ_BANDS; ++band_index) {
+ settings.eq_level_db[band_index] = 0.0f;
+ }
+ settings.gain_staging_db = global_flags.initial_gain_staging_db;
+ settings.level_compressor_enabled = global_flags.gain_staging_auto;
+ settings.compressor_threshold_dbfs = ref_level_dbfs - 12.0f; // -12 dB.
+ settings.compressor_enabled = global_flags.compressor_enabled;
+ return settings;
+}
+
+AudioMixer::BusSettings AudioMixer::get_bus_settings(unsigned bus_index) const
+{
+ lock_guard<timed_mutex> lock(audio_mutex);
+ BusSettings settings;
+ settings.fader_volume_db = fader_volume_db[bus_index];
+ settings.locut_enabled = locut_enabled[bus_index];
+ for (unsigned band_index = 0; band_index < NUM_EQ_BANDS; ++band_index) {
+ settings.eq_level_db[band_index] = eq_level_db[bus_index][band_index];
+ }
+ settings.gain_staging_db = gain_staging_db[bus_index];
+ settings.level_compressor_enabled = level_compressor_enabled[bus_index];
+ settings.compressor_threshold_dbfs = compressor_threshold_dbfs[bus_index];
+ settings.compressor_enabled = compressor_enabled[bus_index];
+ return settings;
+}
+
+void AudioMixer::set_bus_settings(unsigned bus_index, const AudioMixer::BusSettings &settings)
+{
+ lock_guard<timed_mutex> lock(audio_mutex);
+ fader_volume_db[bus_index] = settings.fader_volume_db;
+ locut_enabled[bus_index] = settings.locut_enabled;
+ for (unsigned band_index = 0; band_index < NUM_EQ_BANDS; ++band_index) {
+ eq_level_db[bus_index][band_index] = settings.eq_level_db[band_index];
+ }
+ gain_staging_db[bus_index] = settings.gain_staging_db;
+ level_compressor_enabled[bus_index] = settings.level_compressor_enabled;
+ compressor_threshold_dbfs[bus_index] = settings.compressor_threshold_dbfs;
+ compressor_enabled[bus_index] = settings.compressor_enabled;
+}
+
AudioMixer::AudioDevice *AudioMixer::find_audio_device(DeviceSpec device)
{
switch (device.type) {
}
}
+ // A combination of all settings for a bus. Useful if you want to get
+ // or store them as a whole without bothering to call all of the get_*
+ // or set_* functions for that bus.
+ struct BusSettings {
+ float fader_volume_db;
+ bool locut_enabled;
+ float eq_level_db[NUM_EQ_BANDS];
+ float gain_staging_db;
+ bool level_compressor_enabled;
+ float compressor_threshold_dbfs;
+ bool compressor_enabled;
+ };
+ static BusSettings get_default_bus_settings();
+ BusSettings get_bus_settings(unsigned bus_index) const;
+ void set_bus_settings(unsigned bus_index, const BusSettings &settings);
+
private:
struct AudioDevice {
std::unique_ptr<ResamplingQueue> resampling_queue;
old_mapping(mapping),
devices(global_audio_mixer->get_devices())
{
+ for (unsigned bus_index = 0; bus_index < mapping.buses.size(); ++bus_index) {
+ bus_settings.push_back(global_audio_mixer->get_bus_settings(bus_index));
+ }
+
ui->setupUi(this);
ui->table->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->table->setSelectionMode(QAbstractItemView::SingleSelection); // Makes implementing moving easier for now.
{
global_audio_mixer->set_state_changed_callback(saved_callback);
global_audio_mixer->set_input_mapping(mapping);
+ for (unsigned bus_index = 0; bus_index < mapping.buses.size(); ++bus_index) {
+ global_audio_mixer->set_bus_settings(bus_index, bus_settings[bus_index]);
+ global_audio_mixer->reset_peak(bus_index);
+ }
accept();
}
new_bus.name = "New input";
new_bus.device.type = InputSourceType::SILENCE;
mapping.buses.push_back(new_bus);
+ bus_settings.push_back(AudioMixer::get_default_bus_settings());
ui->table->setRowCount(mapping.buses.size());
unsigned row = mapping.buses.size() - 1;
for (int row : rows_to_delete) {
ui->table->removeRow(row);
mapping.buses.erase(mapping.buses.begin() + row);
+ bus_settings.erase(bus_settings.begin() + row);
}
update_button_state();
}
int b_row = range.bottomRow() + direction;
swap(mapping.buses[a_row], mapping.buses[b_row]);
+ swap(bus_settings[a_row], bus_settings[b_row]);
fill_row_from_bus(a_row, mapping.buses[a_row]);
fill_row_from_bus(b_row, mapping.buses[b_row]);
}
mapping = new_mapping;
+ bus_settings.clear();
+ for (unsigned bus_index = 0; bus_index < mapping.buses.size(); ++bus_index) {
+ bus_settings.push_back(global_audio_mixer->get_bus_settings(bus_index));
+ }
devices = global_audio_mixer->get_devices(); // New dead cards may have been made.
fill_ui_from_mapping(mapping);
}