From 8dc90ae27c24aec1851215f2cc28ee24eff01ea5 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Tue, 29 Dec 2015 23:54:24 +0800 Subject: Master Spark. (WTF) --- ChangeLog | 4 + qmidiplayer.pro | 12 +- qmpchanneleditor.cpp | 14 ++ qmpchanneleditor.hpp | 22 ++ qmpchanneleditor.ui | 579 ++++++++++++++++++++++++++++++++++++++++++++++++++ qmpchannelswindow.cpp | 12 +- qmpchannelswindow.hpp | 22 +- qmpmidiplay.cpp | 10 + qmpmidiplay.hpp | 6 + qmppresetselect.cpp | 93 ++++++++ qmppresetselect.hpp | 36 ++++ qmppresetselect.ui | 106 +++++++++ 12 files changed, 909 insertions(+), 7 deletions(-) create mode 100644 qmpchanneleditor.cpp create mode 100644 qmpchanneleditor.hpp create mode 100644 qmpchanneleditor.ui create mode 100644 qmppresetselect.cpp create mode 100644 qmppresetselect.hpp create mode 100644 qmppresetselect.ui diff --git a/ChangeLog b/ChangeLog index a4ea71e..79dc9fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ +2015-12-28 primitive version +Implemented the channel preset chooser. + 2015-12-28 primitive version Partially implemented the channel window. Fixed a seeking bug. +Minor cleanups. 2015-12-27 primitive version Implemented the play list. diff --git a/qmidiplayer.pro b/qmidiplayer.pro index 12745ee..c89da2c 100644 --- a/qmidiplayer.pro +++ b/qmidiplayer.pro @@ -17,16 +17,22 @@ SOURCES += main.cpp\ qmpmidiplay.cpp \ qmpmidiread.cpp \ qmpplistwindow.cpp \ - qmpchannelswindow.cpp + qmpchannelswindow.cpp \ + qmppresetselect.cpp \ + qmpchanneleditor.cpp HEADERS += qmpmainwindow.hpp \ qmpmidiplay.hpp \ qmpplistwindow.hpp \ - qmpchannelswindow.hpp + qmpchannelswindow.hpp \ + qmppresetselect.hpp \ + qmpchanneleditor.hpp FORMS += qmpmainwindow.ui \ qmpplistwindow.ui \ - qmpchannelswindow.ui + qmpchannelswindow.ui \ + qmppresetselect.ui \ + qmpchanneleditor.ui QMAKE_CXXFLAGS += -std=c++11 -Wall LIBS += -lfluidsynth diff --git a/qmpchanneleditor.cpp b/qmpchanneleditor.cpp new file mode 100644 index 0000000..287d3f1 --- /dev/null +++ b/qmpchanneleditor.cpp @@ -0,0 +1,14 @@ +#include "qmpchanneleditor.hpp" +#include "ui_qmpchanneleditor.h" + +qmpchanneleditor::qmpchanneleditor(QWidget *parent) : + QDialog(parent), + ui(new Ui::qmpchanneleditor) +{ + ui->setupUi(this); +} + +qmpchanneleditor::~qmpchanneleditor() +{ + delete ui; +} diff --git a/qmpchanneleditor.hpp b/qmpchanneleditor.hpp new file mode 100644 index 0000000..cef3b0b --- /dev/null +++ b/qmpchanneleditor.hpp @@ -0,0 +1,22 @@ +#ifndef QMPCHANNELEDITOR_HPP +#define QMPCHANNELEDITOR_HPP + +#include + +namespace Ui { + class qmpchanneleditor; +} + +class qmpchanneleditor : public QDialog +{ + Q_OBJECT + + public: + explicit qmpchanneleditor(QWidget *parent = 0); + ~qmpchanneleditor(); + + private: + Ui::qmpchanneleditor *ui; +}; + +#endif // QMPCHANNELEDITOR_HPP diff --git a/qmpchanneleditor.ui b/qmpchanneleditor.ui new file mode 100644 index 0000000..c482811 --- /dev/null +++ b/qmpchanneleditor.ui @@ -0,0 +1,579 @@ + + + qmpchanneleditor + + + + 0 + 0 + 422 + 300 + + + + + 422 + 300 + + + + + 422 + 300 + + + + Dialog + + + + + 10 + 10 + 21 + 21 + + + + < + + + + + + 30 + 10 + 21 + 20 + + + + 1 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 50 + 10 + 21 + 21 + + + + > + + + + + + 90 + 10 + 261 + 51 + + + + + 16 + + + + Yamaha Grand Piano + + + + + + 290 + 80 + 50 + 51 + + + + 127 + + + 127 + + + + + + 10 + 30 + 81 + 20 + + + + Bank: 0 + + + + + + 10 + 50 + 81 + 20 + + + + PC: 0 + + + + + + 280 + 130 + 66 + 20 + + + + Vol. 127 + + + Qt::AlignCenter + + + + + + 360 + 80 + 50 + 51 + + + + 127 + + + 64 + + + + + + 350 + 130 + 66 + 20 + + + + Pan. C + + + Qt::AlignCenter + + + + + + 0 + 70 + 141 + 101 + + + + Filters + + + + + 70 + 80 + 66 + 20 + + + + Res. 64 + + + Qt::AlignCenter + + + + + + 80 + 30 + 50 + 51 + + + + 127 + + + 64 + + + + + + 10 + 30 + 50 + 51 + + + + 127 + + + 64 + + + + + + 0 + 80 + 71 + 20 + + + + Cut. 64 + + + Qt::AlignCenter + + + + + + + 140 + 70 + 141 + 101 + + + + Effects + + + + + 70 + 80 + 66 + 20 + + + + Chr. 64 + + + Qt::AlignCenter + + + + + + 80 + 30 + 50 + 51 + + + + 127 + + + 64 + + + + + + 10 + 30 + 50 + 51 + + + + 127 + + + 64 + + + + + + 0 + 80 + 71 + 20 + + + + Rev. 64 + + + Qt::AlignCenter + + + + + + + 0 + 170 + 211 + 101 + + + + Envelope + + + + + 70 + 80 + 66 + 20 + + + + Dec. 64 + + + Qt::AlignCenter + + + + + + 80 + 30 + 50 + 51 + + + + 127 + + + 64 + + + + + + 10 + 30 + 50 + 51 + + + + 127 + + + 64 + + + + + + 0 + 80 + 71 + 20 + + + + Atk. 64 + + + Qt::AlignCenter + + + + + + 150 + 30 + 50 + 51 + + + + 127 + + + 64 + + + + + + 140 + 80 + 66 + 20 + + + + Rel. 64 + + + Qt::AlignCenter + + + + + + + 210 + 170 + 211 + 101 + + + + Vibrato + + + + + 70 + 80 + 66 + 20 + + + + Dep. 64 + + + Qt::AlignCenter + + + + + + 80 + 30 + 50 + 51 + + + + 127 + + + 64 + + + + + + 10 + 30 + 50 + 51 + + + + 127 + + + 64 + + + + + + 0 + 80 + 71 + 20 + + + + Rate 64 + + + Qt::AlignCenter + + + + + + 150 + 30 + 50 + 51 + + + + 127 + + + 64 + + + + + + 140 + 80 + 66 + 20 + + + + Del. 64 + + + Qt::AlignCenter + + + + + + + 350 + 0 + 71 + 31 + + + + OK + + + + + + 350 + 40 + 71 + 31 + + + + Cancel + + + + + + diff --git a/qmpchannelswindow.cpp b/qmpchannelswindow.cpp index 6aca878..635918e 100644 --- a/qmpchannelswindow.cpp +++ b/qmpchannelswindow.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include "qmpchannelswindow.hpp" #include "ui_qmpchannelswindow.h" #include "qmpmainwindow.hpp" @@ -11,6 +10,7 @@ qmpchannelswindow::qmpchannelswindow(QWidget *parent) : ui(new Ui::qmpchannelswindow) { ui->setupUi(this); + pselectw=new qmppresetselect(this); connect(this,SIGNAL(dialogClosing()),parent,SLOT(dialogClosed())); for(int i=0;i<16;++i) { @@ -22,7 +22,9 @@ qmpchannelswindow::qmpchannelswindow(QWidget *parent) : QComboBox *cb=(QComboBox*)ui->twChannels->cellWidget(i,2); //stub cb->addItem("Internal fluidsynth"); - ui->twChannels->setCellWidget(i,3,new QLabel("")); + 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->setColumnWidth(0,32); @@ -86,3 +88,9 @@ void qmpchannelswindow::on_pbUnsolo_clicked() ((qmpMainWindow*)this->parent())->getPlayer()->setSolo(i,false); } } + +void qmpchannelswindow::showPresetWindow(int chid) +{ + pselectw->show(); + pselectw->setupWindow(chid); +} diff --git a/qmpchannelswindow.hpp b/qmpchannelswindow.hpp index 4bf3ad2..a594a5a 100644 --- a/qmpchannelswindow.hpp +++ b/qmpchannelswindow.hpp @@ -1,14 +1,30 @@ #ifndef QMPCHANNELSWINDOW_H #define QMPCHANNELSWINDOW_H +#include #include #include +#include "qmppresetselect.hpp" namespace Ui { class qmpchannelswindow; } -class qmpchannelswindow : public QDialog +class QDCLabel:public QLabel +{ + Q_OBJECT + using QLabel::QLabel; + private: + int id; + protected: + void mouseDoubleClickEvent(QMouseEvent *event){event->accept();emit onDoubleClick(id);} + public: + void setID(int _id){id=_id;} + signals: + void onDoubleClick(int id); +}; + +class qmpchannelswindow:public QDialog { Q_OBJECT @@ -21,13 +37,15 @@ class qmpchannelswindow : public QDialog public slots: void channelWindowsUpdate(); void channelMSChanged(); + void showPresetWindow(int chid); private slots: void on_pbUnmute_clicked(); void on_pbUnsolo_clicked(); - private: + private: Ui::qmpchannelswindow *ui; + qmppresetselect *pselectw; }; #endif // QMPCHANNELSWINDOW_H diff --git a/qmpmidiplay.cpp b/qmpmidiplay.cpp index b676c99..112b8e9 100644 --- a/qmpmidiplay.cpp +++ b/qmpmidiplay.cpp @@ -220,6 +220,12 @@ void CMidiPlayer::getChannelPreset(int ch,int *b,int *p,char *name) *b=info.bank;*p=info.program; strcpy(name,info.name); } +void CMidiPlayer::setChannelPreset(int ch,int b,int p) +{ + if(!synth)return; + fluid_synth_bank_select(synth,ch,b); + fluid_synth_program_change(synth,ch,p); +} //16MSB..LSB1 void CMidiPlayer::setBit(uint16_t &n, uint16_t bn, uint16_t b) {n^=(-b^n)&(1< +#include "qmppresetselect.hpp" +#include "ui_qmppresetselect.h" +#include "qmpmainwindow.hpp" + +qmppresetselect::qmppresetselect(QWidget *parent) : + QDialog(parent), + ui(new Ui::qmppresetselect) +{ + ui->setupUi(this); +} + +qmppresetselect::~qmppresetselect() +{ + delete ui; +} + +void qmppresetselect::showEvent(QShowEvent *e) +{ + e->accept();memset(presets,0,sizeof(presets)); + CMidiPlayer *plyr=((qmpMainWindow*)(this->parent()->parent()))->getPlayer(); + int sfc=plyr->getSFCount(); + for(int i=0;igetSFPtr(i); + fluid_preset_t preset; + psf->iteration_start(psf); + while(psf->iteration_next(psf,&preset)) + strcpy(presets[preset.get_banknum(&preset)][preset.get_num(&preset)],preset.get_name(&preset)); + } + ui->lwBankSelect->clear(); + ui->lwPresetSelect->clear(); + for(int i=0;i<=128;++i) + { + int b=0; + for(int j=0;j<128;++j)if(strlen(presets[i][j])){b=1;break;} + if(b)ui->lwBankSelect->addItem(QString::number(i)); + } +} +void qmppresetselect::setupWindow(int chid) +{ + CMidiPlayer *plyr=((qmpMainWindow*)(this->parent()->parent()))->getPlayer(); + ch=chid;int b,p,r;char name[30]; + plyr->getChannelPreset(chid,&b,&p,name); + for(int i=0;ilwBankSelect->count();++i) + { + sscanf(ui->lwBankSelect->item(i)->text().toStdString().c_str(),"%d",&r); + if(r==b){ui->lwBankSelect->setCurrentRow(i);break;} + } + r=0; + for(int i=0,cr=0;i<128;++i) + if(strlen(presets[b][i])) + { + sprintf(name,"%d %s",i,presets[b][i]); + if(i==p)r=cr; + ui->lwPresetSelect->addItem(name); + cr++; + } + ui->lwPresetSelect->setCurrentRow(r); +} + +void qmppresetselect::on_pbCancel_clicked() +{ + close(); +} + +void qmppresetselect::on_pbOk_clicked() +{ + CMidiPlayer *plyr=((qmpMainWindow*)(this->parent()->parent()))->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); + close(); +} + +void qmppresetselect::on_lwPresetSelect_itemDoubleClicked() +{ + on_pbOk_clicked(); +} + +void qmppresetselect::on_lwBankSelect_currentRowChanged() +{ + ui->lwPresetSelect->clear(); + if(!ui->lwBankSelect->currentItem())return; + char name[30];int b; + sscanf(ui->lwBankSelect->currentItem()->text().toStdString().c_str(),"%d",&b); + for(int i=0;i<128;++i) + if(strlen(presets[b][i])) + { + sprintf(name,"%d %s",i,presets[b][i]); + ui->lwPresetSelect->addItem(name); + } +} diff --git a/qmppresetselect.hpp b/qmppresetselect.hpp new file mode 100644 index 0000000..51d0f21 --- /dev/null +++ b/qmppresetselect.hpp @@ -0,0 +1,36 @@ +#ifndef QMPPRESETSELECT_H +#define QMPPRESETSELECT_H + +#include +#include + +namespace Ui { + class qmppresetselect; +} + +class qmppresetselect:public QDialog +{ + Q_OBJECT + + public: + explicit qmppresetselect(QWidget *parent = 0); + ~qmppresetselect(); + void showEvent(QShowEvent* e); + void setupWindow(int chid); + + private slots: + void on_pbCancel_clicked(); + + void on_pbOk_clicked(); + + void on_lwBankSelect_currentRowChanged(); + + void on_lwPresetSelect_itemDoubleClicked(); + + private: + Ui::qmppresetselect *ui; + char presets[129][128][24]; + int ch; +}; + +#endif // QMPPRESETSELECT_H diff --git a/qmppresetselect.ui b/qmppresetselect.ui new file mode 100644 index 0000000..65a03f4 --- /dev/null +++ b/qmppresetselect.ui @@ -0,0 +1,106 @@ + + + qmppresetselect + + + + 0 + 0 + 404 + 300 + + + + + 404 + 300 + + + + + 404 + 300 + + + + Preset Selection + + + true + + + + + 10 + 30 + 71 + 221 + + + + + + + 90 + 30 + 301 + 221 + + + + + + + 10 + 10 + 66 + 20 + + + + Bank + + + + + + 90 + 10 + 66 + 20 + + + + Preset + + + + + + 300 + 260 + 97 + 36 + + + + OK + + + + + + 190 + 260 + 97 + 36 + + + + Cancel + + + + + + -- cgit v1.2.3