]> git.sesse.net Git - nageru/commitdiff
Rename InputMapping::Input to InputMapping::Bus; it's less ambiguous.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 31 Jul 2016 23:03:33 +0000 (01:03 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 19 Oct 2016 22:55:44 +0000 (00:55 +0200)
audio_mixer.cpp
audio_mixer.h
input_mapping_dialog.cpp
input_mapping_dialog.h
mainwindow.cpp
ui_audio_miniview.ui

index 7a36b0de255e53daeeb96e0fcc2de5521b411364..7baa218cd403589c8452e60a65871f78a75dce87 100644 (file)
@@ -63,7 +63,7 @@ AudioMixer::AudioMixer(unsigned num_cards)
        set_final_makeup_gain_auto(global_flags.final_makeup_gain_auto);
 
        // Generate a very simple, default input mapping.
-       InputMapping::Input input;
+       InputMapping::Bus input;
        input.name = "Main";
        input.input_source_type = InputSourceType::CAPTURE_CARD;
        input.input_source_index = 0;
@@ -71,7 +71,7 @@ AudioMixer::AudioMixer(unsigned num_cards)
        input.source_channel[1] = 1;
 
        InputMapping new_input_mapping;
-       new_input_mapping.inputs.push_back(input);
+       new_input_mapping.buses.push_back(input);
        set_input_mapping(new_input_mapping);
 }
 
@@ -98,7 +98,7 @@ void AudioMixer::add_audio(unsigned card_index, const uint8_t *data, unsigned nu
        CaptureCard *card = &cards[card_index];
 
        if (card->resampling_queue == nullptr) {
-               // No inputs use this card; throw it away.
+               // No buses use this card; throw it away.
                return;
        }
 
@@ -136,7 +136,7 @@ void AudioMixer::add_silence(unsigned card_index, unsigned samples_per_frame, un
        lock_guard<mutex> lock(audio_mutex);
 
        if (card->resampling_queue == nullptr) {
-               // No inputs use this card; throw it away.
+               // No buses use this card; throw it away.
                return;
        }
 
@@ -191,8 +191,8 @@ vector<float> AudioMixer::get_output(double pts, unsigned num_samples, Resamplin
        vector<float> samples_out;
        samples_out.resize(num_samples * 2);
        samples_bus.resize(num_samples * 2);
-       for (unsigned input_index = 0; input_index < input_mapping.inputs.size(); ++input_index) {
-               const InputMapping::Input &input = input_mapping.inputs[input_index];
+       for (unsigned bus_index = 0; bus_index < input_mapping.buses.size(); ++bus_index) {
+               const InputMapping::Bus &input = input_mapping.buses[bus_index];
                if (input.input_source_type == InputSourceType::SILENCE) {
                        memset(&samples_bus[0], 0, samples_bus.size() * sizeof(samples_bus[0]));
                } else {
@@ -211,8 +211,8 @@ vector<float> AudioMixer::get_output(double pts, unsigned num_samples, Resamplin
                        }
                }
 
-               float volume = from_db(fader_volume_db[input_index]);
-               if (input_index == 0) {
+               float volume = from_db(fader_volume_db[bus_index]);
+               if (bus_index == 0) {
                        for (unsigned i = 0; i < num_samples * 2; ++i) {
                                samples_out[i] = samples_bus[i] * volume;
                        }
@@ -359,11 +359,11 @@ void AudioMixer::set_input_mapping(const InputMapping &new_input_mapping)
        lock_guard<mutex> lock(audio_mutex);
 
        map<unsigned, set<unsigned>> interesting_channels;
-       for (const InputMapping::Input &input : new_input_mapping.inputs) {
-               if (input.input_source_type == InputSourceType::CAPTURE_CARD) {
+       for (const InputMapping::Bus &bus : new_input_mapping.buses) {
+               if (bus.input_source_type == InputSourceType::CAPTURE_CARD) {
                        for (unsigned channel = 0; channel < 2; ++channel) {
-                               if (input.source_channel[channel] != -1) {
-                                       interesting_channels[input.input_source_index].insert(input.source_channel[channel]);
+                               if (bus.source_channel[channel] != -1) {
+                                       interesting_channels[bus.input_source_index].insert(bus.source_channel[channel]);
                                }
                        }
                }
index 0c7a0a3ab64af48cff1625b0bb1ea74aee660b05..5a36475b6c1d9122ffd1b4b6725b2db275bea6e7 100644 (file)
@@ -34,14 +34,14 @@ struct AudioFormat;
 enum class InputSourceType { SILENCE, CAPTURE_CARD };
 
 struct InputMapping {
-       struct Input {  // TODO: rename to Bus?
+       struct Bus {
                std::string name;
                InputSourceType input_source_type;
                unsigned input_source_index;
                int source_channel[2] { -1, -1 };  // Left and right. -1 = none.
        };
 
-       std::vector<Input> inputs;
+       std::vector<Bus> buses;
 };
 
 class AudioMixer {
@@ -57,7 +57,7 @@ public:
        // See comments inside get_output().
        void set_current_loudness(double level_lufs) { loudness_lufs = level_lufs; }
 
-       void set_fader_volume(unsigned input_index, float level_db) { fader_volume_db[input_index] = level_db; }
+       void set_fader_volume(unsigned bus_index, float level_db) { fader_volume_db[bus_index] = level_db; }
        std::vector<std::string> get_names() const;
        void set_name(unsigned card_index, const std::string &name);
 
index 424e32049431b8dea7cbd8798bb842397d120f60..f56ab62e2d0939a67bb96c69a18d831c40cc6b48 100644 (file)
@@ -31,15 +31,15 @@ void InputMappingDialog::fill_ui_from_mapping(const InputMapping &mapping)
        ui->table->horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
        ui->table->horizontalHeader()->setSectionsClickable(false);
 
-       ui->table->setRowCount(mapping.inputs.size());
-       for (unsigned row = 0; row < mapping.inputs.size(); ++row) {
-               fill_row_from_input(row, mapping.inputs[row]);
+       ui->table->setRowCount(mapping.buses.size());
+       for (unsigned row = 0; row < mapping.buses.size(); ++row) {
+               fill_row_from_bus(row, mapping.buses[row]);
        }
 }
 
-void InputMappingDialog::fill_row_from_input(unsigned row, const InputMapping::Input &input)
+void InputMappingDialog::fill_row_from_bus(unsigned row, const InputMapping::Bus &bus)
 {
-       QString name(QString::fromStdString(input.name));
+       QString name(QString::fromStdString(bus.name));
        ui->table->setItem(row, 0, new QTableWidgetItem(name));
 
        // Card choices.
@@ -48,12 +48,12 @@ void InputMappingDialog::fill_row_from_input(unsigned row, const InputMapping::I
        for (const string &name : card_names) {
                card_combo->addItem(QString::fromStdString(name + "   "));
        }
-       switch (input.input_source_type) {
+       switch (bus.input_source_type) {
        case InputSourceType::SILENCE:
                card_combo->setCurrentIndex(0);
                break;
        case InputSourceType::CAPTURE_CARD:
-               card_combo->setCurrentIndex(mapping.inputs[row].input_source_index + 1);
+               card_combo->setCurrentIndex(mapping.buses[row].input_source_index + 1);
                break;
        default:
                assert(false);
@@ -62,22 +62,22 @@ void InputMappingDialog::fill_row_from_input(unsigned row, const InputMapping::I
                bind(&InputMappingDialog::card_selected, this, row, _1));
        ui->table->setCellWidget(row, 1, card_combo);
 
-       setup_channel_choices_from_input(row, input);
+       setup_channel_choices_from_bus(row, bus);
 }
 
-void InputMappingDialog::setup_channel_choices_from_input(unsigned row, const InputMapping::Input &input)
+void InputMappingDialog::setup_channel_choices_from_bus(unsigned row, const InputMapping::Bus &bus)
 {
        // Left and right channel.
        for (unsigned channel = 0; channel < 2; ++channel) {
                QComboBox *channel_combo = new QComboBox;
                channel_combo->addItem(QString("(none)"));
-               if (input.input_source_type == InputSourceType::CAPTURE_CARD) {
+               if (bus.input_source_type == InputSourceType::CAPTURE_CARD) {
                        for (unsigned source = 0; source < 8; ++source) {  // TODO: Ask the card about number of channels, and names.
                                char buf[256];
                                snprintf(buf, sizeof(buf), "Channel %u   ", source + 1);
                                channel_combo->addItem(QString(buf));
                        }
-                       channel_combo->setCurrentIndex(input.source_channel[channel] + 1);
+                       channel_combo->setCurrentIndex(bus.source_channel[channel] + 1);
                } else {
                        channel_combo->setCurrentIndex(0);
                }
@@ -105,34 +105,34 @@ void InputMappingDialog::cell_changed(int row, int column)
                // Spurious; only really the name column should fire these.
                return;
        }
-       mapping.inputs[row].name = ui->table->item(row, column)->text().toStdString();
+       mapping.buses[row].name = ui->table->item(row, column)->text().toStdString();
 }
 
 void InputMappingDialog::card_selected(unsigned row, int index)
 {
        if (index == 0) {
-               mapping.inputs[row].input_source_type = InputSourceType::SILENCE;
+               mapping.buses[row].input_source_type = InputSourceType::SILENCE;
        } else {
-               mapping.inputs[row].input_source_type = InputSourceType::CAPTURE_CARD;
-               mapping.inputs[row].input_source_index = index - 1;
+               mapping.buses[row].input_source_type = InputSourceType::CAPTURE_CARD;
+               mapping.buses[row].input_source_index = index - 1;
        }
-       setup_channel_choices_from_input(row, mapping.inputs[row]);
+       setup_channel_choices_from_bus(row, mapping.buses[row]);
 }
 
 void InputMappingDialog::channel_selected(unsigned row, unsigned channel, int index)
 {
-       mapping.inputs[row].source_channel[channel] = index - 1;
+       mapping.buses[row].source_channel[channel] = index - 1;
 }
 
 void InputMappingDialog::add_clicked()
 {
-       InputMapping::Input new_input;
-       new_input.name = "New input";
-       new_input.input_source_type = InputSourceType::SILENCE;
-       mapping.inputs.push_back(new_input);
-       ui->table->setRowCount(mapping.inputs.size());
-
-       unsigned row = mapping.inputs.size() - 1;
-       fill_row_from_input(row, new_input);
+       InputMapping::Bus new_bus;
+       new_bus.name = "New input";
+       new_bus.input_source_type = InputSourceType::SILENCE;
+       mapping.buses.push_back(new_bus);
+       ui->table->setRowCount(mapping.buses.size());
+
+       unsigned row = mapping.buses.size() - 1;
+       fill_row_from_bus(row, new_bus);
        ui->table->editItem(ui->table->item(row, 0));  // Start editing the name.
 }
index 91246f563f05cddb5212f5737244297295d9959a..05bc223ee03efc991fbbdd275b5433e6341ccc25 100644 (file)
@@ -21,8 +21,8 @@ public:
 
 private:
        void fill_ui_from_mapping(const InputMapping &mapping);
-       void fill_row_from_input(unsigned row, const InputMapping::Input &input);
-       void setup_channel_choices_from_input(unsigned row, const InputMapping::Input &input);
+       void fill_row_from_bus(unsigned row, const InputMapping::Bus &bus);
+       void setup_channel_choices_from_bus(unsigned row, const InputMapping::Bus &bus);
        void cell_changed(int row, int column);
        void card_selected(unsigned row, int index);
        void channel_selected(unsigned row, unsigned channel, int index);
index a523be9230ca7ca7d58126dd1ec89f04453b538b..5eb631a8890efa2ba9131c5c298657821671a3e0 100644 (file)
@@ -243,17 +243,17 @@ void MainWindow::setup_audio_miniview()
 
        // Set up brand new ones from the input mapping.
        InputMapping mapping = global_mixer->get_audio_mixer()->get_input_mapping();
-       for (unsigned i = 0; i < mapping.inputs.size(); ++i) {
+       for (unsigned bus_index = 0; bus_index < mapping.buses.size(); ++bus_index) {
                QWidget *channel = new QWidget(this);
                Ui::AudioMiniView *ui_audio_miniview = new Ui::AudioMiniView;
                ui_audio_miniview->setupUi(channel);
-               ui_audio_miniview->channel_desc_label->setFullText(
-                       QString::fromStdString(mapping.inputs[i].name));
+               ui_audio_miniview->bus_desc_label->setFullText(
+                       QString::fromStdString(mapping.buses[bus_index].name));
                // TODO: Set the fader position.
                ui->faders->addWidget(channel);
 
                connect(ui_audio_miniview->fader, &QAbstractSlider::valueChanged,
-                       bind(&MainWindow::mini_fader_changed, this, ui_audio_miniview, i, _1));
+                       bind(&MainWindow::mini_fader_changed, this, ui_audio_miniview, bus_index, _1));
        }
 }
 
index 25e458ca48ba4e3152e6bc0d13deb1ddb2f5e2bd..d7149c912c81a513875d3fc2dbfd85f95bf408a5 100644 (file)
@@ -91,7 +91,7 @@
            <number>6</number>
           </property>
           <item>
-           <widget class="EllipsisLabel" name="channel_desc_label">
+           <widget class="EllipsisLabel" name="bus_desc_label">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
               <horstretch>1</horstretch>