From b1be9e45b5abdf0a03181b9cee8dc208a762fe57 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Wed, 30 Dec 2015 23:45:12 +0800 Subject: Complete Darkness. (WTF) --- ChangeLog | 5 +- README.md | 4 +- qmpchanneleditor.cpp | 186 ++++++++++++++++++++++++++++++++++++++++++++++++++ qmpchanneleditor.hpp | 63 +++++++++++++++-- qmpchanneleditor.ui | 157 +++++++++++++++++++----------------------- qmpchannelswindow.cpp | 21 ++++-- qmpchannelswindow.hpp | 18 +++++ qmpmainwindow.cpp | 4 +- qmpmainwindow.hpp | 14 ++-- qmpmidiplay.cpp | 12 ++-- qmpmidiplay.hpp | 2 + qmppresetselect.cpp | 8 ++- 12 files changed, 374 insertions(+), 120 deletions(-) diff --git a/ChangeLog b/ChangeLog index 79dc9fd..4f8cfe6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,7 @@ -2015-12-28 primitive version +2015-12-30 primitive version +Implemented the channel parameter editor. + +2015-12-29 primitive version Implemented the channel preset chooser. 2015-12-28 primitive version diff --git a/README.md b/README.md index 50eb3cd..0c06f83 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ A cross-platform midi file player based on libfluidsynth and Qt. Currently it's still very incomplete and not suitable for everyday use. Planned features: -* Channel mute/solo (not implemented) -* Editing channel parameters on-the-fly (not implemented) +* Channel mute/solo +* Editing channel parameters on-the-fly (partially implemented) * Playlists (partially implemented) * Editing synthesizer effects (not implemented) * Visualization (not implemented) diff --git a/qmpchanneleditor.cpp b/qmpchanneleditor.cpp index 287d3f1..667d553 100644 --- a/qmpchanneleditor.cpp +++ b/qmpchanneleditor.cpp @@ -1,5 +1,7 @@ +#include #include "qmpchanneleditor.hpp" #include "ui_qmpchanneleditor.h" +#include "qmpmainwindow.hpp" qmpchanneleditor::qmpchanneleditor(QWidget *parent) : QDialog(parent), @@ -12,3 +14,187 @@ qmpchanneleditor::~qmpchanneleditor() { delete ui; } + +void qmpchanneleditor::setupWindow(int chid) +{ + char str[30];if(~chid)ch=chid; + sprintf(str,"Channel Parameter Editor - Channel #%d",ch+1); + setWindowTitle(str); + CMidiPlayer* player=qmpMainWindow::getInstance()->getPlayer(); + int b,p; + player->getChannelPreset(ch,&b,&p,str); + ui->lbPresetName->setText(str); + sprintf(str,"BK: %d",b);ui->lbBank->setText(str); + sprintf(str,"PC: %d",p);ui->lbPreset->setText(str); + ui->lbChannelNumber->setText(QString::number(ch+1)); +#define setupControl(ccid,lb,d,ccname)\ + b=player->getCC(ch,ccid);\ + sprintf(str,"%s %d",ccname,b);\ + ui->lb->setText(str);\ + ui->d->setValue(b); + setupControl(7,lbVol,dVol,"Vol."); + setupControl(91,lbReverb,dReverb,"Rev."); + setupControl(93,lbChorus,dChorus,"Chr."); + setupControl(71,lbReso,dReso,"Res."); + setupControl(74,lbCut,dCut,"Cut."); + setupControl(73,lbAttack,dAttack,"Atk."); + setupControl(75,lbDecay,dDecay,"Dec."); + setupControl(72,lbRelease,dRelease,"Rel."); + setupControl(76,lbRate,dRate,"Rate"); + setupControl(77,lbDepth,dDepth,"Dep."); + setupControl(78,lbDelay,dDelay,"Del."); + b=player->getCC(ch,10); + if(b==64)strcpy(str,"Pan. C"); + else if(b<64)sprintf(str,"Pan. L%d",64-b);else sprintf(str,"Pan. R%d",b-64); + ui->lbPan->setText(str); + ui->dPan->setValue(b); +} + +void qmpchanneleditor::sendCC() +{ + CMidiPlayer* player=qmpMainWindow::getInstance()->getPlayer(); + player->setCC(ch,7,ui->dVol->value()); + player->setCC(ch,10,ui->dPan->value()); + player->setCC(ch,91,ui->dReverb->value()); + player->setCC(ch,93,ui->dChorus->value()); + player->setCC(ch,71,ui->dReso->value()); + player->setCC(ch,74,ui->dCut->value()); + player->setCC(ch,73,ui->dAttack->value()); + player->setCC(ch,75,ui->dDecay->value()); + player->setCC(ch,72,ui->dRelease->value()); + player->setCC(ch,76,ui->dRate->value()); + player->setCC(ch,77,ui->dDepth->value()); + player->setCC(ch,78,ui->dDelay->value()); +} + +void qmpchanneleditor::showEvent(QShowEvent *e) +{ + e->accept(); + connect(qmpMainWindow::getInstance()->getTimer(),SIGNAL(timeout()),this,SLOT(setupWindow())); +} +void qmpchanneleditor::closeEvent(QCloseEvent *e) +{ + e->accept(); + disconnect(qmpMainWindow::getInstance()->getTimer(),SIGNAL(timeout()),this,SLOT(setupWindow())); +} + +void qmpchanneleditor::on_pbChLeft_clicked() +{ + if(ch>0)--ch;else ch=15;setupWindow(); +} + +void qmpchanneleditor::on_pbChRight_clicked() +{ + if(ch<15)++ch;else ch=0;setupWindow(); +} + +#define dc disconnect(qmpMainWindow::getInstance()->getTimer(),SIGNAL(timeout()),this,SLOT(setupWindow())) +#define rc connect(qmpMainWindow::getInstance()->getTimer(),SIGNAL(timeout()),this,SLOT(setupWindow()));sendCC() + +void qmpchanneleditor::on_dCut_sliderPressed() +{dc;} + +void qmpchanneleditor::on_dReso_sliderPressed() +{dc;} + +void qmpchanneleditor::on_dReverb_sliderPressed() +{dc;} + +void qmpchanneleditor::on_dChorus_sliderPressed() +{dc;} + +void qmpchanneleditor::on_dVol_sliderPressed() +{dc;} + +void qmpchanneleditor::on_dPan_sliderPressed() +{dc;} + +void qmpchanneleditor::on_dAttack_sliderPressed() +{dc;} + +void qmpchanneleditor::on_dDecay_sliderPressed() +{dc;} + +void qmpchanneleditor::on_dRelease_sliderPressed() +{dc;} + +void qmpchanneleditor::on_dRate_sliderPressed() +{dc;} + +void qmpchanneleditor::on_dDepth_sliderPressed() +{dc;} + +void qmpchanneleditor::on_dDelay_sliderPressed() +{dc;} + +void qmpchanneleditor::on_dAttack_sliderReleased() +{rc;} + +void qmpchanneleditor::on_dDecay_sliderReleased() +{rc;} + +void qmpchanneleditor::on_dRelease_sliderReleased() +{rc;} + +void qmpchanneleditor::on_dRate_sliderReleased() +{rc;} + +void qmpchanneleditor::on_dDepth_sliderReleased() +{rc;} + +void qmpchanneleditor::on_dDelay_sliderReleased() +{rc;} + +void qmpchanneleditor::on_dCut_sliderReleased() +{rc;} + +void qmpchanneleditor::on_dReso_sliderReleased() +{rc;} + +void qmpchanneleditor::on_dReverb_sliderReleased() +{rc;} + +void qmpchanneleditor::on_dChorus_sliderReleased() +{rc;} + +void qmpchanneleditor::on_dVol_sliderReleased() +{rc;} + +void qmpchanneleditor::on_dPan_sliderReleased() +{rc;} + +void qmpchanneleditor::on_dCut_valueChanged() +{rc;} + +void qmpchanneleditor::on_dReso_valueChanged() +{rc;} + +void qmpchanneleditor::on_dReverb_valueChanged() +{rc;} + +void qmpchanneleditor::on_dChorus_valueChanged() +{rc;} + +void qmpchanneleditor::on_dVol_valueChanged() +{rc;} + +void qmpchanneleditor::on_dPan_valueChanged() +{rc;} + +void qmpchanneleditor::on_dAttack_valueChanged() +{rc;} + +void qmpchanneleditor::on_dDecay_valueChanged() +{rc;} + +void qmpchanneleditor::on_dRelease_valueChanged() +{rc;} + +void qmpchanneleditor::on_dRate_valueChanged() +{rc;} + +void qmpchanneleditor::on_dDepth_valueChanged() +{rc;} + +void qmpchanneleditor::on_dDelay_valueChanged() +{rc;} diff --git a/qmpchanneleditor.hpp b/qmpchanneleditor.hpp index cef3b0b..019cfb4 100644 --- a/qmpchanneleditor.hpp +++ b/qmpchanneleditor.hpp @@ -1,22 +1,71 @@ -#ifndef QMPCHANNELEDITOR_HPP -#define QMPCHANNELEDITOR_HPP +#ifndef QMPCHANNELEDITOR_H +#define QMPCHANNELEDITOR_H #include +#include +#include namespace Ui { class qmpchanneleditor; } -class qmpchanneleditor : public QDialog +class qmpchanneleditor:public QDialog { Q_OBJECT public: - explicit qmpchanneleditor(QWidget *parent = 0); - ~qmpchanneleditor(); + explicit qmpchanneleditor(QWidget *parent=0); + ~qmpchanneleditor(); + protected: + void showEvent(QShowEvent *e); + void closeEvent(QCloseEvent *e); + public slots: + void setupWindow(int chid=-1); + + private slots: + void on_pbChLeft_clicked(); + void on_pbChRight_clicked(); + void on_dCut_sliderPressed(); + void on_dReso_sliderPressed(); + void on_dReverb_sliderPressed(); + void on_dChorus_sliderPressed(); + void on_dVol_sliderPressed(); + void on_dPan_sliderPressed(); + void on_dAttack_sliderPressed(); + void on_dDecay_sliderPressed(); + void on_dRelease_sliderPressed(); + void on_dRate_sliderPressed(); + void on_dDepth_sliderPressed(); + void on_dDelay_sliderPressed(); + void on_dAttack_sliderReleased(); + void on_dDecay_sliderReleased(); + void on_dRelease_sliderReleased(); + void on_dRate_sliderReleased(); + void on_dDepth_sliderReleased(); + void on_dDelay_sliderReleased(); + void on_dCut_sliderReleased(); + void on_dReso_sliderReleased(); + void on_dReverb_sliderReleased(); + void on_dChorus_sliderReleased(); + void on_dVol_sliderReleased(); + void on_dPan_sliderReleased(); + void on_dCut_valueChanged(); + void on_dReso_valueChanged(); + void on_dReverb_valueChanged(); + void on_dChorus_valueChanged(); + void on_dVol_valueChanged(); + void on_dPan_valueChanged(); + void on_dAttack_valueChanged(); + void on_dDecay_valueChanged(); + void on_dRelease_valueChanged(); + void on_dRate_valueChanged(); + void on_dDepth_valueChanged(); + void on_dDelay_valueChanged(); private: - Ui::qmpchanneleditor *ui; + Ui::qmpchanneleditor *ui; + int ch; + void sendCC(); }; -#endif // QMPCHANNELEDITOR_HPP +#endif // QMPCHANNELEDITOR_H diff --git a/qmpchanneleditor.ui b/qmpchanneleditor.ui index c482811..b45e7de 100644 --- a/qmpchanneleditor.ui +++ b/qmpchanneleditor.ui @@ -85,22 +85,6 @@ Yamaha Grand Piano - - - - 290 - 80 - 50 - 51 - - - - 127 - - - 127 - - @@ -111,7 +95,7 @@ - Bank: 0 + BK: 0 @@ -127,54 +111,6 @@ PC: 0 - - - - 280 - 130 - 66 - 20 - - - - Vol. 127 - - - Qt::AlignCenter - - - - - - 360 - 80 - 50 - 51 - - - - 127 - - - 64 - - - - - - 350 - 130 - 66 - 20 - - - - Pan. C - - - Qt::AlignCenter - - @@ -547,31 +483,82 @@ - + - 350 - 0 - 71 - 31 - - - - OK - - - - - - 350 - 40 - 71 - 31 + 280 + 70 + 141 + 101 - - Cancel + + Mixer + + + + 70 + 80 + 66 + 20 + + + + Pan. C + + + Qt::AlignCenter + + + + + + 80 + 30 + 50 + 51 + + + + 127 + + + 64 + + + + + + 0 + 80 + 66 + 20 + + + + Vol. 127 + + + Qt::AlignCenter + + + + + + 10 + 30 + 50 + 51 + + + + 127 + + + 127 + + diff --git a/qmpchannelswindow.cpp b/qmpchannelswindow.cpp index 635918e..ce05468 100644 --- a/qmpchannelswindow.cpp +++ b/qmpchannelswindow.cpp @@ -11,6 +11,7 @@ qmpchannelswindow::qmpchannelswindow(QWidget *parent) : { ui->setupUi(this); pselectw=new qmppresetselect(this); + ceditw=new qmpchanneleditor(this); connect(this,SIGNAL(dialogClosing()),parent,SLOT(dialogClosed())); for(int i=0;i<16;++i) { @@ -25,7 +26,9 @@ qmpchannelswindow::qmpchannelswindow(QWidget *parent) : ui->twChannels->setCellWidget(i,3,new QDCLabel("")); ((QDCLabel*)ui->twChannels->cellWidget(i,3))->setID(i); connect(ui->twChannels->cellWidget(i,3),SIGNAL(onDoubleClick(int)),this,SLOT(showPresetWindow(int))); - ui->twChannels->setCellWidget(i,4,new QPushButton("...")); + ui->twChannels->setCellWidget(i,4,new QDCPushButton("...")); + ((QDCLabel*)ui->twChannels->cellWidget(i,4))->setID(i); + connect(ui->twChannels->cellWidget(i,4),SIGNAL(onClick(int)),this,SLOT(showChannelEditorWindow(int))); } ui->twChannels->setColumnWidth(0,32); ui->twChannels->setColumnWidth(1,32); @@ -47,7 +50,7 @@ void qmpchannelswindow::channelWindowsUpdate() { char data[128],nm[24]; int b,p; - ((qmpMainWindow*)this->parent())->getPlayer()->getChannelPreset(i,&b,&p,nm); + qmpMainWindow::getInstance()->getPlayer()->getChannelPreset(i,&b,&p,nm); sprintf(data,"%d:%d %s",b,p,nm); ((QLabel*)ui->twChannels->cellWidget(i,3))->setText(data); } @@ -61,8 +64,8 @@ void qmpchannelswindow::channelMSChanged() m=(QCheckBox*)ui->twChannels->cellWidget(i,0); s=(QCheckBox*)ui->twChannels->cellWidget(i,1); if(m->isChecked()&&s->isChecked())s->setChecked(false); - ((qmpMainWindow*)this->parent())->getPlayer()->setMute(i,m->isChecked()); - ((qmpMainWindow*)this->parent())->getPlayer()->setSolo(i,s->isChecked()); + qmpMainWindow::getInstance()->getPlayer()->setMute(i,m->isChecked()); + qmpMainWindow::getInstance()->getPlayer()->setSolo(i,s->isChecked()); } } @@ -76,7 +79,7 @@ void qmpchannelswindow::on_pbUnmute_clicked() for(int i=0;i<16;++i) { ((QCheckBox*)ui->twChannels->cellWidget(i,0))->setChecked(false); - ((qmpMainWindow*)this->parent())->getPlayer()->setMute(i,false); + qmpMainWindow::getInstance()->getPlayer()->setMute(i,false); } } @@ -85,7 +88,7 @@ void qmpchannelswindow::on_pbUnsolo_clicked() for(int i=0;i<16;++i) { ((QCheckBox*)ui->twChannels->cellWidget(i,1))->setChecked(false); - ((qmpMainWindow*)this->parent())->getPlayer()->setSolo(i,false); + qmpMainWindow::getInstance()->getPlayer()->setSolo(i,false); } } @@ -94,3 +97,9 @@ void qmpchannelswindow::showPresetWindow(int chid) pselectw->show(); pselectw->setupWindow(chid); } + +void qmpchannelswindow::showChannelEditorWindow(int chid) +{ + ceditw->show(); + ceditw->setupWindow(chid); +} diff --git a/qmpchannelswindow.hpp b/qmpchannelswindow.hpp index a594a5a..c87a90f 100644 --- a/qmpchannelswindow.hpp +++ b/qmpchannelswindow.hpp @@ -2,9 +2,11 @@ #define QMPCHANNELSWINDOW_H #include +#include #include #include #include "qmppresetselect.hpp" +#include "qmpchanneleditor.hpp" namespace Ui { class qmpchannelswindow; @@ -24,6 +26,20 @@ class QDCLabel:public QLabel void onDoubleClick(int id); }; +class QDCPushButton:public QPushButton +{ + Q_OBJECT + using QPushButton::QPushButton; + private: + int id; + protected: + void mousePressEvent(QMouseEvent *event){QPushButton::mousePressEvent(event);emit onClick(id);} + public: + void setID(int _id){id=_id;} + signals: + void onClick(int id); +}; + class qmpchannelswindow:public QDialog { Q_OBJECT @@ -38,6 +54,7 @@ class qmpchannelswindow:public QDialog void channelWindowsUpdate(); void channelMSChanged(); void showPresetWindow(int chid); + void showChannelEditorWindow(int chid); private slots: void on_pbUnmute_clicked(); @@ -46,6 +63,7 @@ class qmpchannelswindow:public QDialog private: Ui::qmpchannelswindow *ui; qmppresetselect *pselectw; + qmpchanneleditor *ceditw; }; #endif // QMPCHANNELSWINDOW_H diff --git a/qmpmainwindow.cpp b/qmpmainwindow.cpp index 69cf9df..f79583c 100644 --- a/qmpmainwindow.cpp +++ b/qmpmainwindow.cpp @@ -4,6 +4,8 @@ #include "ui_qmpmainwindow.h" #include "qmpmidiplay.hpp" +qmpMainWindow* qmpMainWindow::ref=NULL; + qmpMainWindow::qmpMainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::qmpMainWindow) @@ -13,7 +15,7 @@ qmpMainWindow::qmpMainWindow(QWidget *parent) : plistw=new qmpplistwindow(this); chnlw=new qmpchannelswindow(this); ui->lbFileName->setText(""); - timer=new QTimer(this); + timer=new QTimer(this);ref=this; connect(timer,SIGNAL(timeout()),this,SLOT(updateWidgets())); connect(timer,SIGNAL(timeout()),chnlw,SLOT(channelWindowsUpdate())); } diff --git a/qmpmainwindow.hpp b/qmpmainwindow.hpp index 8d64f37..ae62bb4 100644 --- a/qmpmainwindow.hpp +++ b/qmpmainwindow.hpp @@ -14,7 +14,7 @@ namespace Ui { class qmpMainWindow; } -class qmpMainWindow : public QMainWindow +class qmpMainWindow:public QMainWindow { Q_OBJECT @@ -23,24 +23,18 @@ class qmpMainWindow : public QMainWindow void closeEvent(QCloseEvent *event); ~qmpMainWindow(); CMidiPlayer* getPlayer(){return player;} + QTimer* getTimer(){return timer;} private slots: void on_pbPlayPause_clicked(); void updateWidgets(); - void on_hsTimer_sliderPressed(); - void on_hsTimer_sliderReleased(); - void on_vsMasterVol_valueChanged(); - void on_pbStop_clicked(); - void on_pbPList_clicked(); void on_pbPrev_clicked(); - void on_pbNext_clicked(); - void on_pbChannels_clicked(); public slots: @@ -58,6 +52,8 @@ class qmpMainWindow : public QMainWindow qmpplistwindow *plistw; qmpchannelswindow *chnlw; + static qmpMainWindow* ref; + public: static qmpMainWindow* getInstance(){return ref;} }; -#endif // QMPMAINWINDOW_HPP +#endif // QMPMAINWINDOW_H diff --git a/qmpmidiplay.cpp b/qmpmidiplay.cpp index 112b8e9..e9014d0 100644 --- a/qmpmidiplay.cpp +++ b/qmpmidiplay.cpp @@ -230,13 +230,13 @@ void CMidiPlayer::setChannelPreset(int ch,int b,int p) void CMidiPlayer::setBit(uint16_t &n, uint16_t bn, uint16_t b) {n^=(-b^n)&(1<accept();memset(presets,0,sizeof(presets)); - CMidiPlayer *plyr=((qmpMainWindow*)(this->parent()->parent()))->getPlayer(); + CMidiPlayer *plyr=qmpMainWindow::getInstance()->getPlayer(); int sfc=plyr->getSFCount(); for(int i=0;iparent()->parent()))->getPlayer(); + CMidiPlayer *plyr=qmpMainWindow::getInstance()->getPlayer(); ch=chid;int b,p,r;char name[30]; + sprintf(name,"Preset Selection - Channel #%d",ch); + setWindowTitle(name); plyr->getChannelPreset(chid,&b,&p,name); for(int i=0;ilwBankSelect->count();++i) { @@ -66,7 +68,7 @@ void qmppresetselect::on_pbCancel_clicked() void qmppresetselect::on_pbOk_clicked() { - CMidiPlayer *plyr=((qmpMainWindow*)(this->parent()->parent()))->getPlayer(); + CMidiPlayer *plyr=qmpMainWindow::getInstance()->getPlayer(); int b,p;sscanf(ui->lwBankSelect->currentItem()->text().toStdString().c_str(),"%d",&b); sscanf(ui->lwPresetSelect->currentItem()->text().toStdString().c_str(),"%d",&p); plyr->setChannelPreset(ch,b,p); -- cgit v1.2.3