aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop
diff options
context:
space:
mode:
Diffstat (limited to 'qmidiplayer-desktop')
-rw-r--r--qmidiplayer-desktop/qmpchannelswindow.cpp21
-rw-r--r--qmidiplayer-desktop/qmpchannelswindow.hpp17
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.cpp3
3 files changed, 21 insertions, 20 deletions
diff --git a/qmidiplayer-desktop/qmpchannelswindow.cpp b/qmidiplayer-desktop/qmpchannelswindow.cpp
index 1800aa5..8968bed 100644
--- a/qmidiplayer-desktop/qmpchannelswindow.cpp
+++ b/qmidiplayer-desktop/qmpchannelswindow.cpp
@@ -14,9 +14,15 @@ qmpChannelsWindow::qmpChannelsWindow(QWidget *parent) :
pselectw=new qmpPresetSelector(this);
ceditw=new qmpChannelEditor(this);
cha=new QIcon(":/img/ledon.svg");chi=new QIcon(":/img/ledoff.svg");
- cb=new qmpCWNoteOnCB();fused=callbacksc=cbcnt=0;
- qmpMainWindow::getInstance()->getPlayer()->setEventHandlerCB(cb,nullptr);
- connect(cb,SIGNAL(onNoteOn()),this,SLOT(updateChannelActivity()));
+ fused=callbacksc=cbcnt=0;
+ eh=qmpMainWindow::getInstance()->getPlayer()->registerEventHandler(
+ [this](const void *ee,void*){
+ const SEvent *e=(const SEvent*)ee;
+ if((e->type&0xF0)==0x90&&e->p2>0&&(e->flags&0x01))
+ emit this->noteOn();
+ }
+ ,nullptr);
+ connect(this,&qmpChannelsWindow::noteOn,this,&qmpChannelsWindow::updateChannelActivity);
std::vector<std::string> devs=qmpMainWindow::getInstance()->getPlayer()->getMidiOutDevices();
size_t devc=devs.size();
//We setup default output here...
@@ -131,7 +137,7 @@ void qmpChannelsWindow::channelWindowsUpdate()
{
for(int i=0;i<16;++i)
ui->twChannels->item(i,4)->setText("");
- connect(cb,SIGNAL(onNoteOn()),this,SLOT(updateChannelActivity()));
+ connect(this,&qmpChannelsWindow::noteOn,this,&qmpChannelsWindow::updateChannelActivity);
fused=0;return;
}
++cbcnt;
@@ -139,7 +145,7 @@ void qmpChannelsWindow::channelWindowsUpdate()
{
if(callbacksc>8192)
{
- disconnect(cb,SIGNAL(onNoteOn()),this,SLOT(updateChannelActivity()));
+ disconnect(this,&qmpChannelsWindow::noteOn,this,&qmpChannelsWindow::updateChannelActivity);
fprintf(stderr,"Fuse!\n");fused=1;
}
cbcnt=0;
@@ -156,7 +162,7 @@ void qmpChannelsWindow::channelWindowsUpdate()
if(strcmp((ui->twChannels->item(i,4))->
text().toStdString().c_str(),data))
{
- connect(cb,SIGNAL(onNoteOn()),this,SLOT(updateChannelActivity()));
+ connect(this,&qmpChannelsWindow::noteOn,this,&qmpChannelsWindow::updateChannelActivity);
fused=0;
}
}
@@ -184,9 +190,10 @@ void qmpChannelsWindow::channelMSChanged()
qmpChannelsWindow::~qmpChannelsWindow()
{
qmpMainWindow::getInstance()->unregisterFunctionality("Channel");
+ qmpMainWindow::getInstance()->getPlayer()->unregisterEventHandler(eh);
delete chnlf;
delete chi;delete cha;
- delete cb;delete ui;
+ delete ui;
}
void qmpChannelsWindow::on_pbUnmute_clicked()
diff --git a/qmidiplayer-desktop/qmpchannelswindow.hpp b/qmidiplayer-desktop/qmpchannelswindow.hpp
index 36cba3c..207ee8d 100644
--- a/qmidiplayer-desktop/qmpchannelswindow.hpp
+++ b/qmidiplayer-desktop/qmpchannelswindow.hpp
@@ -48,16 +48,6 @@ class QDCComboBox:public QComboBox
void indexChangedSlot(int idx){emit(onChange(id,idx));}
};
-class qmpCWNoteOnCB:public QObject,public ICallBack
-{
- Q_OBJECT
- public:
- void callBack(const void* callerdata,void*)
- {if(((((const SEvent*)callerdata)->type)&0xF0)==0x90)emit onNoteOn();}
- signals:
- void onNoteOn();
-};
-
class qmpChannelsWindow;
class qmpChannelFunc:public qmpFuncBaseIntf
@@ -75,7 +65,7 @@ class qmpChannelsWindow:public QWidget
Q_OBJECT
public:
- explicit qmpChannelsWindow(QWidget *parent=0);
+ explicit qmpChannelsWindow(QWidget *parent=nullptr);
~qmpChannelsWindow();
void showEvent(QShowEvent *event);
void closeEvent(QCloseEvent *event);
@@ -90,6 +80,9 @@ class qmpChannelsWindow:public QWidget
void on_pbUnmute_clicked();
void on_pbUnsolo_clicked();
+ signals:
+ void noteOn();
+
protected:
bool eventFilter(QObject *o,QEvent *e);
@@ -98,8 +91,8 @@ class qmpChannelsWindow:public QWidget
qmpPresetSelector *pselectw;
qmpChannelEditor *ceditw;
QIcon *cha,*chi;
- qmpCWNoteOnCB *cb;
qmpChannelFunc *chnlf;
+ int eh;
//callback fuse... (avoid black midi blocking the main thread)
int callbacksc,cbcnt,fused;
};
diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp
index 5f9dfba..cd00b2e 100644
--- a/qmidiplayer-desktop/qmpmainwindow.cpp
+++ b/qmidiplayer-desktop/qmpmainwindow.cpp
@@ -54,7 +54,7 @@ qmpMainWindow::~qmpMainWindow()
std::vector<std::pair<qmpMidiOutRtMidi*,std::string>> rtdev=rtmididev->getDevices();
for(auto &i:rtdev)player->unregisterMidiOutDevice(i.second);
rtmididev->deleteDevices();
- delete pmgr;if(player)delete player;
+ delete pmgr;
if(timer)delete timer;
delete helpw;helpw=nullptr;
delete efxw;efxw=nullptr;
@@ -65,6 +65,7 @@ qmpMainWindow::~qmpMainWindow()
delete panicf;panicf=nullptr;
delete renderf;renderf=nullptr;
delete reloadsynf;reloadsynf=nullptr;
+ if(player)delete player;
delete ui;
}