summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2016-01-06 21:28:44 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2016-01-06 21:28:44 +0800
commit7fccb61519fe84b2ced274f1cc4859d5000e86c6 (patch)
treef66696e67d56e9e6015d613af84562364baaa9ed
parent8099672c3fd0bfc7804b0a92d05c57dcd4307268 (diff)
downloadQMidiPlayer-7fccb61519fe84b2ced274f1cc4859d5000e86c6.tar.xz
Maple Dream. (WTF)
-rw-r--r--ChangeLog8
-rw-r--r--README.md2
-rw-r--r--doc/index.html2
-rw-r--r--doc/mainwindow.html26
-rw-r--r--img/mainw.pngbin0 -> 32886 bytes
-rw-r--r--main.cpp4
-rw-r--r--qmpchannelswindow.cpp6
-rw-r--r--qmpmainwindow.cpp49
-rw-r--r--qmpmainwindow.hpp7
-rw-r--r--qmpmidiplay.cpp10
-rw-r--r--qmpplistwindow.cpp11
-rw-r--r--qmpplistwindow.hpp14
-rw-r--r--resources.qrc2
13 files changed, 116 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index 06bd431..908ff7d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2016-01-06 0.6.2 beta
+Initial command line parameters handling.
+Minor bug fixes.
+
+2016-01-04 0.6.1 alpha
+Avoid strange results in channel view.
+Fixed several crashes.
+
2016-01-03 0.6.1 alpha
Initial works on documentation.
Minor bug fixes.
diff --git a/README.md b/README.md
index aa991d9..1c82623 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# QMidiPlayer
A cross-platform midi file player based on libfluidsynth and Qt.
-Now it's in alpha stage. There are still a whole bunch of bugs, be careful...
+Now it's in beta stage. Crashes may still occur, ~run with gdb attatched if you could~.
Features:
* Channel mute/solo
diff --git a/doc/index.html b/doc/index.html
index 3fffe62..2e9157b 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -17,7 +17,7 @@
</ul>
<h1>Using QMidiPlayer</h1>
<ul>
- <li>The main window</li>
+ <li><a href="mainwindow.html">The main window</a></li>
<li>The channels dialog</li>
<li>The channels parameters editor</li>
<li>The playlist dialog</li>
diff --git a/doc/mainwindow.html b/doc/mainwindow.html
new file mode 100644
index 0000000..80bf2aa
--- /dev/null
+++ b/doc/mainwindow.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>QMidiPlayer Help</title>
+</head>
+<body>
+ <h1>Main Window</h1>
+ <img src="../img/mainw.png"><br>
+ <ul>
+ <li>1. Now playing. Right clicking here will bring up the <a href="#fileop"> file operation menu</a>.</li>
+ <li>2. Playing control slider. The total playing time is estimated and isn't 100% accurate.</li>
+ <li>3. Playing control buttons.</li>
+ <li>4. Settings button.</li>
+ <li>5. Dialog toggle buttons.</li>
+ <li>6. Master gain slier.</li>
+ <li>7. Polyphone indicator.</li>
+ <li>8. <s>It's me!</s></li>
+ </ul>
+ <h3><a name="fileop">File operation menu</a></h3>
+ <ul>
+ <li>File Information.</li>
+ <li>Render to Wave.</li>
+ </ul>
+ <br><a href="index.html">Return</a>
+</body>
+</html>
diff --git a/img/mainw.png b/img/mainw.png
new file mode 100644
index 0000000..c15f17d
--- /dev/null
+++ b/img/mainw.png
Binary files differ
diff --git a/main.cpp b/main.cpp
index c031262..c9f3b42 100644
--- a/main.cpp
+++ b/main.cpp
@@ -19,11 +19,11 @@
#include <QApplication>
#include <QStyle>
-int main(int argc, char *argv[])
+int main(int argc,char **argv)
{
QApplication a(argc,argv);
qmpMainWindow w;
- w.show();
+ if(w.pharseArgs(argc,argv)==1)return 0;
return a.exec();
}
diff --git a/qmpchannelswindow.cpp b/qmpchannelswindow.cpp
index 448e5b7..a9cf60e 100644
--- a/qmpchannelswindow.cpp
+++ b/qmpchannelswindow.cpp
@@ -67,6 +67,12 @@ void qmpChannelsWindow::moveEvent(QMoveEvent *event)
void qmpChannelsWindow::channelWindowsUpdate()
{
+ if(qmpMainWindow::getInstance()->getPlayer()->isFinished())
+ {
+ for(int i=0;i<16;++i)
+ ((QLabel*)ui->twChannels->cellWidget(i,3))->setText("");
+ return;
+ }
for(int i=0;i<16;++i)
{
char data[128],nm[24];
diff --git a/qmpmainwindow.cpp b/qmpmainwindow.cpp
index 00e23ff..242e52f 100644
--- a/qmpmainwindow.cpp
+++ b/qmpmainwindow.cpp
@@ -1,5 +1,6 @@
#include <cstdio>
#include <QUrl>
+#include <QDirIterator>
#include <QDesktopWidget>
#include "qmpmainwindow.hpp"
#include "ui_qmpmainwindow.h"
@@ -33,7 +34,7 @@ qmpMainWindow::qmpMainWindow(QWidget *parent) :
else setGeometry(QStyle::alignedRect(
Qt::LeftToRight,Qt::AlignCenter,size(),
qApp->desktop()->availableGeometry()));
- }
+ }show();
if(qmpSettingsWindow::getSettingsIntf()->value("DialogStatus/PListWShown",0).toInt())
{ui->pbPList->setChecked(true);on_pbPList_clicked();}
if(qmpSettingsWindow::getSettingsIntf()->value("DialogStatus/ChnlWShown",0).toInt())
@@ -53,6 +54,52 @@ qmpMainWindow::~qmpMainWindow()
delete ui;
}
+int qmpMainWindow::pharseArgs(int argc,char** argv)
+{
+ bool havemidi=false,loadfolder=false;
+ for(int i=1;i<argc;++i)
+ {
+ if(argv[i][0]=='-')
+ {
+ if(!strcmp(argv[i],"--help"))
+ {
+ printf("Usage: %s [Options] [Midi Files]\n",argv[0]);
+ printf("Possible options are: \n");
+ printf("-l, --load-all-files Load all files from the same folder.\n");
+ printf("--help Show this help and exit.\n");
+ printf("--version Show this version information and exit.\n");
+ return 1;
+ }
+ if(!strcmp(argv[i],"--version"))
+ {
+ printf("QMidiPlayer %s\n",APP_VERSION);
+ return 1;
+ }
+ if(!strcmp(argv[i],"-l")||!strcmp(argv[i],"--load-all-files"))
+ loadfolder=true;
+ }
+ else
+ if(fluid_is_midifile(argv[i]))
+ {
+ if(!havemidi){havemidi=true;plistw->emptyList();}
+ if(loadfolder||qmpSettingsWindow::getSettingsIntf()->value("Behavior/LoadFolder",0).toInt())
+ {
+ QDirIterator di(QUrl(argv[i]).adjusted(QUrl::RemoveFilename).toString());
+ while(di.hasNext())
+ {
+ QString c=di.next();
+ if((c.endsWith(".mid")||c.endsWith(".midi"))&&fluid_is_midifile(c.toStdString().c_str()))
+ plistw->insertItem(c.toStdString().c_str());
+ }
+ }
+ else
+ plistw->insertItem(argv[i]);
+ }
+ }
+ if(havemidi)on_pbPlayPause_clicked();
+ return 0;
+}
+
void qmpMainWindow::closeEvent(QCloseEvent *event)
{
on_pbStop_clicked();fin=true;
diff --git a/qmpmainwindow.hpp b/qmpmainwindow.hpp
index 894a476..331fc15 100644
--- a/qmpmainwindow.hpp
+++ b/qmpmainwindow.hpp
@@ -33,6 +33,8 @@ class qmpMainWindow:public QMainWindow
CMidiPlayer* getPlayer(){return player;}
QTimer* getTimer(){return timer;}
bool isFinalizing(){return fin;}
+ QString getFileName();
+ int pharseArgs(int argc,char** argv);
private slots:
void on_pbPlayPause_clicked();
@@ -53,7 +55,7 @@ class qmpMainWindow:public QMainWindow
void on_pushButton_clicked();
- public slots:
+ public slots:
void dialogClosed();
void selectionChanged();
@@ -75,9 +77,8 @@ class qmpMainWindow:public QMainWindow
QAction *fnA1,*fnA2;
void playerSetup();
- public:
- QString getFileName();
+ private:
static qmpMainWindow* ref;
public: static qmpMainWindow* getInstance(){return ref;}
};
diff --git a/qmpmidiplay.cpp b/qmpmidiplay.cpp
index 2578d6c..6825a12 100644
--- a/qmpmidiplay.cpp
+++ b/qmpmidiplay.cpp
@@ -245,11 +245,11 @@ void CMidiPlayer::setTCeptr(uint32_t ep,uint32_t st)
double CMidiPlayer::getFtime(){return ftime;}
void CMidiPlayer::getCurrentTimeSignature(int *n,int *d){*n=ctsn;*d=ctsd;}
void CMidiPlayer::getCurrentKeySignature(int *ks){*ks=cks;}
-uint32_t CMidiPlayer::getFileNoteCount(){return midiFile->getNoteCount();}
-uint32_t CMidiPlayer::getFileStandard(){return midiFile->getStandard();}
-const char* CMidiPlayer::getTitle(){return midiFile->getTitle();}
-const char* CMidiPlayer::getCopyright(){return midiFile->getCopyright();}
-double CMidiPlayer::getTempo(){return 60./(ctempo/1e6)*ctsd/4.;}
+uint32_t CMidiPlayer::getFileNoteCount(){return midiFile?midiFile->getNoteCount():0;}
+uint32_t CMidiPlayer::getFileStandard(){return midiFile?midiFile->getStandard():0;}
+const char* CMidiPlayer::getTitle(){return midiFile?midiFile->getTitle():"";}
+const char* CMidiPlayer::getCopyright(){return midiFile?midiFile->getCopyright():"";}
+double CMidiPlayer::getTempo(){return 60./(ctempo/1e6)/**ctsd/4.*/;}
uint32_t CMidiPlayer::getTCpaused(){return tcpaused;}
void CMidiPlayer::setTCpaused(uint32_t ps){tcpaused=ps;}
uint32_t CMidiPlayer::isFinished(){return finished;}
diff --git a/qmpplistwindow.cpp b/qmpplistwindow.cpp
index dd6f67d..85c33a3 100644
--- a/qmpplistwindow.cpp
+++ b/qmpplistwindow.cpp
@@ -100,6 +100,15 @@ void qmpPlistWindow::moveEvent(QMoveEvent *event)
}
}
+void qmpPlistWindow::emptyList()
+{
+ ui->lwFiles->clear();
+}
+void qmpPlistWindow::insertItem(QString i)
+{
+ ui->lwFiles->addItem(new QListWidgetItem(i));
+}
+
void qmpPlistWindow::on_pbAdd_clicked()
{
QStringList sl;
@@ -123,7 +132,7 @@ void qmpPlistWindow::on_pbAddFolder_clicked()
while(di.hasNext())
{
QString c=di.next();
- if(c.endsWith(".mid")||c.endsWith(".midi"))
+ if((c.endsWith(".mid")||c.endsWith(".midi"))&&fluid_is_midifile(c.toStdString().c_str()))
ui->lwFiles->addItem(new QListWidgetItem(c));
}
}
diff --git a/qmpplistwindow.hpp b/qmpplistwindow.hpp
index 4c67009..838bff8 100644
--- a/qmpplistwindow.hpp
+++ b/qmpplistwindow.hpp
@@ -26,32 +26,24 @@ class qmpPlistWindow : public QDialog
QString getNextItem();
QString getPrevItem();
QString getSelectedItem();
- //void loadPList(const char*);
- //void savePList(const char*);
+ void emptyList();
+ void insertItem(QString i);
signals:
void dialogClosing();
void selectionChanging();
private slots:
void on_pbAdd_clicked();
-
void on_pbAddFolder_clicked();
-
void on_pbRemove_clicked();
-
void on_pbClear_clicked();
-
void on_pbRepeat_clicked();
-
void on_pbShuffle_clicked();
-
void on_lwFiles_itemDoubleClicked();
-
void on_pbSave_clicked();
-
void on_pbLoad_clicked();
- private:
+ private:
Ui::qmpPlistWindow *ui;
int shuffle,repeat;//rep 0=off 1=one 2=all
};
diff --git a/resources.qrc b/resources.qrc
index 6555c01..03997c5 100644
--- a/resources.qrc
+++ b/resources.qrc
@@ -28,5 +28,7 @@
<file>doc/index.html</file>
<file>doc/version.html</file>
<file>doc/license.html</file>
+ <file>doc/mainwindow.html</file>
+ <file>img/mainw.png</file>
</qresource>
</RCC>