From 172975be45eac2276b0653d4549efbd6df9f7c46 Mon Sep 17 00:00:00 2001 From: Yohann Dedy Date: Mon, 5 Sep 2016 02:16:21 +0200 Subject: [PATCH] Added Thru/Masterchannel dump request --- src/mainwindow.cpp | 19 ++++++++++++++----- src/mainwindow.h | 4 +++- src/settingswindow.cpp | 30 +++++++++++++++++++++++++----- src/settingswindow.h | 2 ++ 4 files changed, 44 insertions(+), 11 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4f175eb..c61e4cf 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -14,9 +14,8 @@ mainWindow::mainWindow(QWidget *parent) : _midiIn(new QMidiIn(this)), _midiOut(new QMidiOut(this)) { - //_midiIn->openPort(NULL); - //_midiOut->openPort(NULL); - + _prefixPocketC = {0xF0,0x00,0x20,0x20,0x14,0x00}; + _midiIn->setIgnoreTypes(false, false, false); // Layout QWidget *mainWidget = new QWidget(this); @@ -87,6 +86,7 @@ void mainWindow::onMidiMessageReceive(QMidiMessage *message) { case THRU_MC_DUMP: { + _settingsWindow->updateConfig(message); break; } @@ -106,7 +106,6 @@ void mainWindow::onMidiMessageReceive(QMidiMessage *message) void mainWindow::openSettingsWindow() { - qDebug() << "Open settings window here" ; _settingsWindow->setWindowModality(Qt::ApplicationModal); _settingsWindow->show(); } @@ -119,7 +118,17 @@ void mainWindow::openMidiPorts(){ _midiIn->openPort(_settingsWindow->_inPortComboBox->currentIndex()); } if(_settingsWindow->_outPortComboBox->currentText() != "None"){ - qDebug()<< "Selected MIDI OUT : " <<_settingsWindow->_inPortComboBox->currentText(); + qDebug()<< "Selected MIDI OUT : " <<_settingsWindow->_outPortComboBox->currentText(); _midiOut->openPort(_settingsWindow->_outPortComboBox->currentIndex()); } } + +void mainWindow::sendThruMasterChnRequest(){ + std::vector rawRequest; + rawRequest = _prefixPocketC; + rawRequest.push_back(0x56); + rawRequest.push_back(0x00); + rawRequest.push_back(0x00); + rawRequest.push_back(0xF7); + if(_midiOut->isPortOpen()) _midiOut->sendRawMessage(rawRequest); +} diff --git a/src/mainwindow.h b/src/mainwindow.h index 461bfd4..22c10e6 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -24,7 +24,6 @@ enum deviceCommandByte { VERSION_ANS = 0x00, }; - class mainWindow : public QMainWindow { Q_OBJECT @@ -38,6 +37,7 @@ public: ~mainWindow(); + std::vector _prefixPocketC; QMidiMessage* _midiMessage; deviceCommandByte _deviceCommandByte; @@ -60,8 +60,10 @@ public slots: void openSettingsWindow(); //void updateDeviceConfig(std::bitset<3> thru, int mastChn); //void updatePresetSettings(std::vector* presetSettings); + void infoPopup(); private slots: void openMidiPorts(); + void sendThruMasterChnRequest(); }; diff --git a/src/settingswindow.cpp b/src/settingswindow.cpp index e938ce9..b8191fd 100644 --- a/src/settingswindow.cpp +++ b/src/settingswindow.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include settingsWindow::settingsWindow(QWidget *parent) : @@ -37,8 +38,10 @@ settingsWindow::settingsWindow(QWidget *parent) : emit _outPortComboBox->setCurrentIndex(_outPortComboBox->count()-1); - QPushButton *bouton = new QPushButton(); - bouton->setText("Apply"); + QPushButton *applyBouton = new QPushButton(); + applyBouton->setText("Apply"); + connect(applyBouton, SIGNAL(clicked(bool)), parent, SLOT(openMidiPorts())); + // THRU MASTER CHANNEL QGroupBox *thruChnBox = new QGroupBox("Thru Settings"); @@ -54,6 +57,8 @@ settingsWindow::settingsWindow(QWidget *parent) : QPushButton *setConfigButton = new QPushButton; setConfigButton->setText("Set configuration"); + connect(getConfigButton, SIGNAL(clicked(bool)),parent,SLOT(sendThruMasterChnRequest())); + QVBoxLayout *vbox = new QVBoxLayout; vbox->addWidget(_channelThruCheckBox); vbox->addWidget(_sysexThruCheckBox); @@ -68,7 +73,7 @@ settingsWindow::settingsWindow(QWidget *parent) : mainLayout->addWidget(_inPortComboBox); mainLayout->addWidget(new QLabel("Midi OUT")); mainLayout->addWidget(_outPortComboBox); - mainLayout->addWidget(bouton); + mainLayout->addWidget(applyBouton); mainLayout->addWidget(thruChnBox); mainWidget->setLayout(mainLayout); @@ -77,7 +82,8 @@ settingsWindow::settingsWindow(QWidget *parent) : connect(_channelThruCheckBox,SIGNAL(toggled(bool)),this,SLOT(onThruCheckboxChange())); connect(_sysexThruCheckBox,SIGNAL(toggled(bool)),this,SLOT(onThruCheckboxChange())); connect(_realtimeThruCheckBox,SIGNAL(toggled(bool)),this,SLOT(onThruCheckboxChange())); - connect(bouton, SIGNAL(clicked(bool)),parent, SLOT(openMidiPorts())); + + } settingsWindow::~settingsWindow() @@ -88,5 +94,19 @@ void settingsWindow::onThruCheckboxChange(){ _thruBitset->set(0, _channelThruCheckBox->isChecked()); _thruBitset->set(1, _sysexThruCheckBox->isChecked()); _thruBitset->set(2,_realtimeThruCheckBox->isChecked()); - qDebug()<< "_thruBitset = " <<_thruBitset->to_ulong(); +} + +void settingsWindow::updateConfig(QMidiMessage* message){ + int mc = message->getRawMessage().at(8)+1; + _masterChannelSpinBox->setValue(mc); + + std::bitset<3> thruVal (message->getRawMessage().at(7)); + _channelThruCheckBox->setChecked(thruVal.test(0)); + _sysexThruCheckBox->setChecked(thruVal.test(1)); + _realtimeThruCheckBox->setChecked(thruVal.test(2)); +} + +void settingsWindow::onSetConfig(){ + + } diff --git a/src/settingswindow.h b/src/settingswindow.h index 03618e5..aa14228 100644 --- a/src/settingswindow.h +++ b/src/settingswindow.h @@ -40,6 +40,8 @@ signals: public slots: void onThruCheckboxChange(); + void updateConfig(QMidiMessage* message); + void onSetConfig(); }; #endif // SETTINGSWINDOW_H