]> git.sesse.net Git - nageru/blobdiff - nageru/midi_mapping_dialog.cpp
Turn off guessing if the source bus contains the pitch bend controller.
[nageru] / nageru / midi_mapping_dialog.cpp
index 05508e4e244224bc33f129d9f93a873931b88a99..0c7683c017ac953e7e60fd0b73c9eaaf32a97f52 100644 (file)
 #include <limits>
 #include <string>
 
+#include "controller_spin_box.h"
 #include "midi_mapper.h"
-#include "midi_mapping.pb.h"
-#include "post_to_main_thread.h"
+#include "nageru_midi_mapping.pb.h"
+#include "shared/post_to_main_thread.h"
 #include "ui_midi_mapping.h"
 
 class QObject;
@@ -419,8 +420,14 @@ void MIDIMappingDialog::add_controls(const string &heading,
                item->setText(0, QString::fromStdString(control.label + "   "));
 
                for (unsigned bus_idx = 0; bus_idx < num_buses; ++bus_idx) {
-                       QSpinBox *spinner = new QSpinBox(this);
-                       spinner->setRange(-1, 127);
+                       QSpinBox *spinner;
+                       if (control_type == ControlType::CONTROLLER) {
+                               spinner = new ControllerSpinBox(this);
+                               spinner->setRange(-1, 128);  // 128 for pitch bend.
+                       } else {
+                               spinner = new QSpinBox(this);
+                               spinner->setRange(-1, 127);
+                       }
                        spinner->setAutoFillBackground(true);
                        spinner->setSpecialValueText("\u200d");  // Zero-width joiner (ie., empty).
                        spinner->installEventFilter(this);  // So we know when the focus changes.
@@ -536,6 +543,10 @@ pair<int, int> MIDIMappingDialog::guess_offset(unsigned bus_idx, MIDIMappingDial
                        // The bus has a controller set that the source bus doesn't set.
                        return not_found;
                }
+               if (source_spinner->value() == MIDIReceiver::PITCH_BEND_CONTROLLER) {
+                       // It's impossible to interpolate across the pitch bend.
+                       return not_found;
+               }
 
                int candidate_offset = spinner->value() - source_spinner->value();
                if (!found_offset) {