From be1005a6031861b91e1a2df33f62e1c5a0a2aeb6 Mon Sep 17 00:00:00 2001 From: "Tim E. Real" Date: Mon, 12 Nov 2012 04:49:31 +0000 Subject: Finished Aftertouch controllers Feature: Piano KB / drum list show coloured dots when per-pitch controllers exist / have data. --- muse2/muse/widgets/arrangercolumns.cpp | 26 ++- muse2/muse/widgets/arrangercolumnsbase.ui | 40 ---- muse2/muse/widgets/midi_audio_control.cpp | 269 +++++++++++++++----------- muse2/muse/widgets/midi_audio_control_base.ui | 46 +---- 4 files changed, 181 insertions(+), 200 deletions(-) (limited to 'muse2/muse/widgets') diff --git a/muse2/muse/widgets/arrangercolumns.cpp b/muse2/muse/widgets/arrangercolumns.cpp index 08a9580e..9e8137e6 100644 --- a/muse2/muse/widgets/arrangercolumns.cpp +++ b/muse2/muse/widgets/arrangercolumns.cpp @@ -32,6 +32,18 @@ ArrangerColumns::ArrangerColumns(QWidget* parent) : QDialog(parent) ignoreSomethingChanged=true; setupUi(this); + + ctrlType->addItem(tr("Control7"), MusECore::MidiController::Controller7); + ctrlType->addItem(tr("Control14"), MusECore::MidiController::Controller14); + ctrlType->addItem(tr("RPN"), MusECore::MidiController::RPN); + ctrlType->addItem(tr("NPRN"), MusECore::MidiController::NRPN); + ctrlType->addItem(tr("RPN14"), MusECore::MidiController::RPN14); + ctrlType->addItem(tr("NRPN14"), MusECore::MidiController::NRPN14); + ctrlType->addItem(tr("Pitch"), MusECore::MidiController::Pitch); + ctrlType->addItem(tr("Program"), MusECore::MidiController::Program); + //ctrlType->addItem(tr("PolyAftertouch"), MusECore::MidiController::PolyAftertouch); // Not supported yet. Need a way to select pitch. + ctrlType->addItem(tr("Aftertouch"), MusECore::MidiController::Aftertouch); + ctrlType->setCurrentIndex(0); initList(); @@ -58,7 +70,9 @@ ArrangerColumns::ArrangerColumns(QWidget* parent) : QDialog(parent) void ArrangerColumns::ctrlTypeChanged(int idx) { - MusECore::MidiController::ControllerType t = (MusECore::MidiController::ControllerType)idx; + if(idx == -1) + return; + MusECore::MidiController::ControllerType t = (MusECore::MidiController::ControllerType)ctrlType->itemData(idx).toInt(); switch (t) { @@ -90,17 +104,17 @@ void ArrangerColumns::somethingChanged() if (ignoreSomethingChanged) return; int row=listWidget->currentRow(); - if (row!=-1) + if (row!=-1 && ctrlType->currentIndex() != -1) { + MusECore::MidiController::ControllerType t = (MusECore::MidiController::ControllerType)ctrlType->itemData(ctrlType->currentIndex()).toInt(); int hnum = spinBoxHCtrlNo->value(); int lnum = spinBoxLCtrlNo->value(); - MusECore::MidiController::ControllerType t = (MusECore::MidiController::ControllerType)ctrlType->currentIndex(); int ctrl_number = MusECore::MidiController::genNum(t, hnum, lnum); Arranger::new_custom_columns[row].name=nameEdit->text(); Arranger::new_custom_columns[row].ctrl=ctrl_number; Arranger::new_custom_columns[row].affected_pos=(affectBeginButton->isChecked() ? Arranger::custom_col_t::AFFECT_BEGIN : Arranger::custom_col_t::AFFECT_CPOS); - + listWidget->currentItem()->setText(getListEntryString(row)); } } @@ -134,7 +148,9 @@ void ArrangerColumns::itemSelected(int i) nameEdit->setText(Arranger::new_custom_columns[i].name); int num=Arranger::new_custom_columns[i].ctrl; - ctrlType->setCurrentIndex(MusECore::midiControllerType(num)); + int idx = ctrlType->findData(MusECore::midiControllerType(num)); + if(idx != -1) + ctrlType->setCurrentIndex(idx); if (spinBoxHCtrlNo->isEnabled()) spinBoxHCtrlNo->setValue((num & 0xFF00)>>8); else diff --git a/muse2/muse/widgets/arrangercolumnsbase.ui b/muse2/muse/widgets/arrangercolumnsbase.ui index eda9e923..8568f9f5 100644 --- a/muse2/muse/widgets/arrangercolumnsbase.ui +++ b/muse2/muse/widgets/arrangercolumnsbase.ui @@ -69,46 +69,6 @@ Midi controller type - - - Control7 - - - - - Control14 - - - - - RPN - - - - - NRPN - - - - - RPN14 - - - - - NRPN14 - - - - - Pitch - - - - - Program - - diff --git a/muse2/muse/widgets/midi_audio_control.cpp b/muse2/muse/widgets/midi_audio_control.cpp index 17d724ac..7e2d5091 100644 --- a/muse2/muse/widgets/midi_audio_control.cpp +++ b/muse2/muse/widgets/midi_audio_control.cpp @@ -45,6 +45,18 @@ MidiAudioControl::MidiAudioControl(int port, int chan, int ctrl, QWidget* parent { setupUi(this); + controlTypeComboBox->addItem(tr("Control7"), MusECore::MidiController::Controller7); + controlTypeComboBox->addItem(tr("Control14"), MusECore::MidiController::Controller14); + controlTypeComboBox->addItem(tr("RPN"), MusECore::MidiController::RPN); + controlTypeComboBox->addItem(tr("NPRN"), MusECore::MidiController::NRPN); + controlTypeComboBox->addItem(tr("RPN14"), MusECore::MidiController::RPN14); + controlTypeComboBox->addItem(tr("NRPN14"), MusECore::MidiController::NRPN14); + controlTypeComboBox->addItem(tr("Pitch"), MusECore::MidiController::Pitch); + controlTypeComboBox->addItem(tr("Program"), MusECore::MidiController::Program); + //controlTypeComboBox->addItem(tr("PolyAftertouch"), MusECore::MidiController::PolyAftertouch); // Not supported yet. Need a way to select pitch. + controlTypeComboBox->addItem(tr("Aftertouch"), MusECore::MidiController::Aftertouch); + controlTypeComboBox->setCurrentIndex(0); + _port = port; _chan = chan; _ctrl = ctrl; @@ -89,59 +101,71 @@ void MidiAudioControl::heartbeat() if(MusEGlobal::midiLearnCtrl != -1) { MusECore::MidiController::ControllerType type = MusECore::midiControllerType(MusEGlobal::midiLearnCtrl); - if(type < controlTypeComboBox->count() && type != controlTypeComboBox->currentIndex()) + int idx = controlTypeComboBox->findData(type); + if(idx != -1 && idx != controlTypeComboBox->currentIndex()) { controlTypeComboBox->blockSignals(true); - controlTypeComboBox->setCurrentIndex(type); + controlTypeComboBox->setCurrentIndex(idx); controlTypeComboBox->blockSignals(false); } int hv = (MusEGlobal::midiLearnCtrl >> 8) & 0xff; int lv = MusEGlobal::midiLearnCtrl & 0xff; - if(type == MusECore::MidiController::Program || type == MusECore::MidiController::Pitch) - { - ctrlHiSpinBox->setEnabled(false); - ctrlLoSpinBox->setEnabled(false); - ctrlHiSpinBox->blockSignals(true); - ctrlLoSpinBox->blockSignals(true); - ctrlHiSpinBox->setValue(0); - ctrlLoSpinBox->setValue(0); - ctrlHiSpinBox->blockSignals(false); - ctrlLoSpinBox->blockSignals(false); - } - else if(type == MusECore::MidiController::Controller7) - { - ctrlHiSpinBox->setEnabled(false); - ctrlLoSpinBox->setEnabled(true); - ctrlHiSpinBox->blockSignals(true); - ctrlHiSpinBox->setValue(0); - ctrlHiSpinBox->blockSignals(false); - - if(lv != ctrlLoSpinBox->value()) - { - ctrlLoSpinBox->blockSignals(true); - ctrlLoSpinBox->setValue(lv); - ctrlLoSpinBox->blockSignals(false); - } - } - else + switch(type) { - ctrlHiSpinBox->setEnabled(true); - ctrlLoSpinBox->setEnabled(true); - if(hv != ctrlHiSpinBox->value()) - { + case MusECore::MidiController::Program: + case MusECore::MidiController::Pitch: + case MusECore::MidiController::PolyAftertouch: // Unsupported yet. Need a way to select pitch. + case MusECore::MidiController::Aftertouch: + ctrlHiSpinBox->setEnabled(false); + ctrlLoSpinBox->setEnabled(false); ctrlHiSpinBox->blockSignals(true); - ctrlHiSpinBox->setValue(hv); - ctrlHiSpinBox->blockSignals(false); - } - if(lv != ctrlLoSpinBox->value()) - { ctrlLoSpinBox->blockSignals(true); - ctrlLoSpinBox->setValue(lv); + ctrlHiSpinBox->setValue(0); + ctrlLoSpinBox->setValue(0); + ctrlHiSpinBox->blockSignals(false); ctrlLoSpinBox->blockSignals(false); - } - } + break; + case MusECore::MidiController::Controller7: + ctrlHiSpinBox->setEnabled(false); + ctrlLoSpinBox->setEnabled(true); + + ctrlHiSpinBox->blockSignals(true); + ctrlHiSpinBox->setValue(0); + ctrlHiSpinBox->blockSignals(false); + + if(lv != ctrlLoSpinBox->value()) + { + ctrlLoSpinBox->blockSignals(true); + ctrlLoSpinBox->setValue(lv); + ctrlLoSpinBox->blockSignals(false); + } + break; + case MusECore::MidiController::Controller14: + case MusECore::MidiController::RPN: + case MusECore::MidiController::RPN14: + case MusECore::MidiController::NRPN: + case MusECore::MidiController::NRPN14: + ctrlHiSpinBox->setEnabled(true); + ctrlLoSpinBox->setEnabled(true); + if(hv != ctrlHiSpinBox->value()) + { + ctrlHiSpinBox->blockSignals(true); + ctrlHiSpinBox->setValue(hv); + ctrlHiSpinBox->blockSignals(false); + } + if(lv != ctrlLoSpinBox->value()) + { + ctrlLoSpinBox->blockSignals(true); + ctrlLoSpinBox->setValue(lv); + ctrlLoSpinBox->blockSignals(false); + } + break; + default: + printf("FIXME: MidiAudioControl::heartbeat: Unknown control type: %d\n", type); + break; + } _ctrl = MusECore::midiCtrlTerms2Number(type, (ctrlHiSpinBox->value() << 8) + ctrlLoSpinBox->value()); } @@ -184,46 +208,55 @@ void MidiAudioControl::chanChanged() void MidiAudioControl::updateCtrlBoxes() { - int idx = controlTypeComboBox->currentIndex(); - if(idx == -1) + if(controlTypeComboBox->currentIndex() == -1) return; - - if(idx == MusECore::MidiController::Program || idx == MusECore::MidiController::Pitch) - { - ctrlHiSpinBox->setEnabled(false); - ctrlLoSpinBox->setEnabled(false); - ctrlHiSpinBox->blockSignals(true); - ctrlLoSpinBox->blockSignals(true); - ctrlHiSpinBox->setValue(0); - ctrlLoSpinBox->setValue(0); - ctrlHiSpinBox->blockSignals(false); - ctrlLoSpinBox->blockSignals(false); - } - else if(idx == MusECore::MidiController::Controller7) - { - ctrlHiSpinBox->setEnabled(false); - ctrlLoSpinBox->setEnabled(true); + MusECore::MidiController::ControllerType t = (MusECore::MidiController::ControllerType)controlTypeComboBox->itemData(controlTypeComboBox->currentIndex()).toInt(); - ctrlHiSpinBox->blockSignals(true); - ctrlHiSpinBox->setValue(0); - ctrlHiSpinBox->blockSignals(false); - } - else + switch(t) { - ctrlHiSpinBox->setEnabled(true); - ctrlLoSpinBox->setEnabled(true); - } + case MusECore::MidiController::Program: + case MusECore::MidiController::Pitch: + case MusECore::MidiController::PolyAftertouch: // Unsupported yet. Need a way to select pitch. + case MusECore::MidiController::Aftertouch: + ctrlHiSpinBox->setEnabled(false); + ctrlLoSpinBox->setEnabled(false); + ctrlHiSpinBox->blockSignals(true); + ctrlLoSpinBox->blockSignals(true); + ctrlHiSpinBox->setValue(0); + ctrlLoSpinBox->setValue(0); + ctrlHiSpinBox->blockSignals(false); + ctrlLoSpinBox->blockSignals(false); + break; + case MusECore::MidiController::Controller7: + ctrlHiSpinBox->setEnabled(false); + ctrlLoSpinBox->setEnabled(true); + ctrlHiSpinBox->blockSignals(true); + ctrlHiSpinBox->setValue(0); + ctrlHiSpinBox->blockSignals(false); + break; + case MusECore::MidiController::Controller14: + case MusECore::MidiController::RPN: + case MusECore::MidiController::RPN14: + case MusECore::MidiController::NRPN: + case MusECore::MidiController::NRPN14: + ctrlHiSpinBox->setEnabled(true); + ctrlLoSpinBox->setEnabled(true); + break; + default: + printf("FIXME: MidiAudioControl::updateCtrlBoxes: Unknown control type: %d\n", t); + break; + } } void MidiAudioControl::ctrlTypeChanged(int idx) { if(idx == -1) return; - + updateCtrlBoxes(); _ctrl = (ctrlHiSpinBox->value() << 8) + ctrlLoSpinBox->value(); - _ctrl = MusECore::midiCtrlTerms2Number(MusECore::MidiController::ControllerType(idx), _ctrl); + _ctrl = MusECore::midiCtrlTerms2Number((MusECore::MidiController::ControllerType)controlTypeComboBox->itemData(idx).toInt(), _ctrl); resetLearn(); } @@ -233,7 +266,7 @@ void MidiAudioControl::ctrlHChanged() if(controlTypeComboBox->currentIndex() == -1) return; _ctrl = (ctrlHiSpinBox->value() << 8) + ctrlLoSpinBox->value(); - _ctrl = MusECore::midiCtrlTerms2Number(MusECore::MidiController::ControllerType(controlTypeComboBox->currentIndex()), _ctrl); + _ctrl = MusECore::midiCtrlTerms2Number((MusECore::MidiController::ControllerType)controlTypeComboBox->itemData(controlTypeComboBox->currentIndex()).toInt(), _ctrl); resetLearn(); } @@ -243,7 +276,7 @@ void MidiAudioControl::ctrlLChanged() if(controlTypeComboBox->currentIndex() == -1) return; _ctrl = (ctrlHiSpinBox->value() << 8) + ctrlLoSpinBox->value(); - _ctrl = MusECore::midiCtrlTerms2Number(MusECore::MidiController::ControllerType(controlTypeComboBox->currentIndex()), _ctrl); + _ctrl = MusECore::midiCtrlTerms2Number((MusECore::MidiController::ControllerType)controlTypeComboBox->itemData(controlTypeComboBox->currentIndex()).toInt(), _ctrl); resetLearn(); } @@ -282,59 +315,71 @@ void MidiAudioControl::update() channelSpinBox->blockSignals(false); int type = MusECore::midiControllerType(_ctrl); - if(type < controlTypeComboBox->count()) + int idx = controlTypeComboBox->findData(type); + if(idx != -1 && idx != controlTypeComboBox->currentIndex()) { controlTypeComboBox->blockSignals(true); - controlTypeComboBox->setCurrentIndex(type); + controlTypeComboBox->setCurrentIndex(idx); controlTypeComboBox->blockSignals(false); } int hv = (_ctrl >> 8) & 0xff; int lv = _ctrl & 0xff; - if(type == MusECore::MidiController::Program || type == MusECore::MidiController::Pitch) - { - ctrlHiSpinBox->setEnabled(false); - ctrlLoSpinBox->setEnabled(false); - ctrlHiSpinBox->blockSignals(true); - ctrlLoSpinBox->blockSignals(true); - ctrlHiSpinBox->setValue(0); - ctrlLoSpinBox->setValue(0); - ctrlHiSpinBox->blockSignals(false); - ctrlLoSpinBox->blockSignals(false); - } - else if(type == MusECore::MidiController::Controller7) - { - ctrlHiSpinBox->setEnabled(false); - ctrlLoSpinBox->setEnabled(true); - ctrlHiSpinBox->blockSignals(true); - ctrlHiSpinBox->setValue(0); - ctrlHiSpinBox->blockSignals(false); - - if(lv != ctrlLoSpinBox->value()) - { - ctrlLoSpinBox->blockSignals(true); - ctrlLoSpinBox->setValue(lv); - ctrlLoSpinBox->blockSignals(false); - } - } - else + switch(type) { - ctrlHiSpinBox->setEnabled(true); - ctrlLoSpinBox->setEnabled(true); - if(hv != ctrlHiSpinBox->value()) - { + case MusECore::MidiController::Program: + case MusECore::MidiController::Pitch: + case MusECore::MidiController::PolyAftertouch: // Unsupported yet. Need a way to select pitch. + case MusECore::MidiController::Aftertouch: + ctrlHiSpinBox->setEnabled(false); + ctrlLoSpinBox->setEnabled(false); ctrlHiSpinBox->blockSignals(true); - ctrlHiSpinBox->setValue(hv); - ctrlHiSpinBox->blockSignals(false); - } - if(lv != ctrlLoSpinBox->value()) - { ctrlLoSpinBox->blockSignals(true); - ctrlLoSpinBox->setValue(lv); + ctrlHiSpinBox->setValue(0); + ctrlLoSpinBox->setValue(0); + ctrlHiSpinBox->blockSignals(false); ctrlLoSpinBox->blockSignals(false); - } + break; + case MusECore::MidiController::Controller7: + ctrlHiSpinBox->setEnabled(false); + ctrlLoSpinBox->setEnabled(true); + + ctrlHiSpinBox->blockSignals(true); + ctrlHiSpinBox->setValue(0); + ctrlHiSpinBox->blockSignals(false); + + if(lv != ctrlLoSpinBox->value()) + { + ctrlLoSpinBox->blockSignals(true); + ctrlLoSpinBox->setValue(lv); + ctrlLoSpinBox->blockSignals(false); + } + break; + case MusECore::MidiController::Controller14: + case MusECore::MidiController::RPN: + case MusECore::MidiController::RPN14: + case MusECore::MidiController::NRPN: + case MusECore::MidiController::NRPN14: + ctrlHiSpinBox->setEnabled(true); + ctrlLoSpinBox->setEnabled(true); + if(hv != ctrlHiSpinBox->value()) + { + ctrlHiSpinBox->blockSignals(true); + ctrlHiSpinBox->setValue(hv); + ctrlHiSpinBox->blockSignals(false); + } + if(lv != ctrlLoSpinBox->value()) + { + ctrlLoSpinBox->blockSignals(true); + ctrlLoSpinBox->setValue(lv); + ctrlLoSpinBox->blockSignals(false); + } + break; + default: + printf("FIXME: MidiAudioControl::updateCtrlBoxes: Unknown control type: %d\n", type); + break; } } -} +} // namespace MusEGui diff --git a/muse2/muse/widgets/midi_audio_control_base.ui b/muse2/muse/widgets/midi_audio_control_base.ui index 2e341121..11ecc590 100644 --- a/muse2/muse/widgets/midi_audio_control_base.ui +++ b/muse2/muse/widgets/midi_audio_control_base.ui @@ -6,8 +6,8 @@ 0 0 - 341 - 148 + 367 + 156 @@ -80,46 +80,6 @@ 0 - - - Control7 - - - - - Control14 - - - - - RPN - - - - - NRPN - - - - - RPN14 - - - - - NRPN14 - - - - - Pitch - - - - - Program - - @@ -225,7 +185,7 @@ - Learn + &Learn true -- cgit v1.2.3