aboutsummaryrefslogtreecommitdiff
path: root/simple-visualization
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2019-11-02 22:13:32 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2019-11-02 22:13:32 +0800
commitb2ef363f49db70219ac1eaebb7d69dcdade8d60b (patch)
treecfc0e8da88dc27b62578dccbce367736e020f63d /simple-visualization
parent23525e2a648a23f099c2b533aa91839a2f8e829f (diff)
downloadQMidiPlayer-b2ef363f49db70219ac1eaebb7d69dcdade8d60b.tar.xz
Keyboard plugin: show additional information on the side.
qmpPluginAPI::registerEventHandler now accepts an optional argument that determines whether the handler is called prior to or after an event is sent.
Diffstat (limited to 'simple-visualization')
-rw-r--r--simple-visualization/qmpkeyboardwindow.cpp42
-rw-r--r--simple-visualization/qmpkeyboardwindow.hpp4
2 files changed, 39 insertions, 7 deletions
diff --git a/simple-visualization/qmpkeyboardwindow.cpp b/simple-visualization/qmpkeyboardwindow.cpp
index 562596c..8fe0e6f 100644
--- a/simple-visualization/qmpkeyboardwindow.cpp
+++ b/simple-visualization/qmpkeyboardwindow.cpp
@@ -1,23 +1,41 @@
#include <QVBoxLayout>
+#include <QGridLayout>
#include <QCloseEvent>
+#include <QLabel>
+#include "qmppianowidget.hpp"
#include "qmpkeyboardwindow.hpp"
qmpKeyboardWindow::qmpKeyboardWindow(qmpPluginAPI *_api,QWidget *parent):
QWidget(parent,Qt::Dialog),api(_api)
{
- setLayout(new QVBoxLayout());
+ setWindowTitle("Keyboard");
+ QGridLayout *grid;
+ setLayout(grid=new QGridLayout());
for(int ch=0;ch<16;++ch)
- layout()->addWidget(pw[ch]=new qmpPianoWidget(this));
+ {
+ grid->addWidget(lb[ch]=new QLabel,ch,0);
+ grid->addWidget(pw[ch]=new qmpPianoWidget(this),ch,1);
+ pw[ch]->setSizePolicy(QSizePolicy::Policy::Expanding,QSizePolicy::Policy::Preferred);
+ }
hide();
eh=api->registerEventHandler(
[this](const void* ee,void*){
const SEvent *e=(const SEvent*)ee;
+ int ch=e->type&0xF;
if((e->type&0xF0)==0x80||((e->type&0xF0)==0x90&&e->p2==0))
- emit keystateupdated(e->type&0xF,e->p1,false);
+ emit keystateupdated(ch,e->p1,false);
if((e->type&0xF0)==0x90&&e->p2>0)
- emit keystateupdated(e->type&0xF,e->p1,e->p2>0);
+ emit keystateupdated(ch,e->p1,e->p2>0);
+ if((e->type&0xF0)==0xB0||(e->type&0xF0)==0xC0)
+ lb[ch]->setText(
+ QString::fromStdString(api->getChannelPresetString(ch))+
+ QString("\nch:%1 v:%2 p:%3 e:%4")
+ .arg(QString::number(ch+1))
+ .arg(QString::number(api->getChannelCC(ch,0x7)))
+ .arg(QString::number(api->getChannelCC(ch,0xa)))
+ .arg(QString::number(api->getChannelCC(ch,0xb))));
}
- ,nullptr);
+ ,nullptr,true);
connect(this,&qmpKeyboardWindow::keystateupdated,this,&qmpKeyboardWindow::onkeystatesupdate);
}
qmpKeyboardWindow::~qmpKeyboardWindow()
@@ -32,4 +50,16 @@ void qmpKeyboardWindow::closeEvent(QCloseEvent *event)
void qmpKeyboardWindow::onkeystatesupdate(int ch,int key,bool state)
{pw[ch]->setKeyState(key,state);}
void qmpKeyboardWindow::resetAll()
-{for(int ch=0;ch<16;++ch)pw[ch]->reset();}
+{
+ for(int ch=0;ch<16;++ch)
+ {
+ pw[ch]->reset();
+ lb[ch]->setText(
+ QString::fromStdString(api->getChannelPresetString(ch))+
+ QString("\nch:%1 v:%2 p:%3 e:%4")
+ .arg(QString::number(ch+1))
+ .arg(QString::number(api->getChannelCC(ch,0x7)))
+ .arg(QString::number(api->getChannelCC(ch,0xa)))
+ .arg(QString::number(api->getChannelCC(ch,0xb))));
+ }
+}
diff --git a/simple-visualization/qmpkeyboardwindow.hpp b/simple-visualization/qmpkeyboardwindow.hpp
index 563b6b4..65ad266 100644
--- a/simple-visualization/qmpkeyboardwindow.hpp
+++ b/simple-visualization/qmpkeyboardwindow.hpp
@@ -2,15 +2,17 @@
#define QMPKEYBOARDWINDOW_HPP
#include "../include/qmpcorepublic.hpp"
-#include "qmppianowidget.hpp"
#include <QWidget>
+class QLabel;
+class qmpPianoWidget;
class qmpKeyboardWindow:public QWidget
{
Q_OBJECT
private:
qmpPianoWidget *pw[16];
+ QLabel *lb[16];
qmpPluginAPI *api;
int eh;
public: