diff options
author | Chris Xiong <chirs241097@gmail.com> | 2020-05-12 00:58:40 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2020-05-12 00:58:40 +0800 |
commit | a7407edaf81c685d4a389785a405a53a5de4b148 (patch) | |
tree | e6e4f2d85f2172c94ac83a6e8f01e1e90a78ede9 /qmidiplayer-lite/qmpcorewrapper.hpp | |
parent | 437b7b16c322a8e53ac55a5f831098494d9a7073 (diff) | |
download | QMidiPlayer-a7407edaf81c685d4a389785a405a53a5de4b148.tar.xz |
Format EVERYTHING.
Hopefully this will make the source code less horrendous and actually
readable.
The command used was:
```
astyle --suffix=none --style=allman --attach-extern-c --attach-closing-while --indent-switches --indent-after-parens --pad-oper --pad-header --unpad-paren --align-pointer=name --recursive './*.cpp,*.hpp'
```
Diffstat (limited to 'qmidiplayer-lite/qmpcorewrapper.hpp')
-rw-r--r-- | qmidiplayer-lite/qmpcorewrapper.hpp | 106 |
1 files changed, 58 insertions, 48 deletions
diff --git a/qmidiplayer-lite/qmpcorewrapper.hpp b/qmidiplayer-lite/qmpcorewrapper.hpp index 090edc7..07dff65 100644 --- a/qmidiplayer-lite/qmpcorewrapper.hpp +++ b/qmidiplayer-lite/qmpcorewrapper.hpp @@ -5,56 +5,66 @@ #include <thread> #include <fluidsynth.h> #include "../core/qmpmidiplay.hpp" -class CQMPCoreWrapper:public QObject +class CQMPCoreWrapper: public QObject { - Q_OBJECT + Q_OBJECT private: - CMidiPlayer *mp; - std::thread *playerTh; - int curprog; + CMidiPlayer *mp; + std::thread *playerTh; + int curprog; public: - explicit CQMPCoreWrapper(QObject* parent=0):QObject(parent) - { - mp=new CMidiPlayer(); - } - ~CQMPCoreWrapper(){delete mp;} - Q_INVOKABLE void initFluidSynth(QUrl sfpath) - { - mp->fluid()->setOptStr("audio.driver","pulseaudio"); - mp->fluid()->deviceInit(); - mp->fluid()->loadSFont(sfpath.toLocalFile().toStdString().c_str()); - for(int i=0;i<16;++i) - mp->setChannelOutput(i,0); - } - Q_INVOKABLE void deinitFluidSynth() - { - mp->fluid()->deviceDeinit(); - } - Q_INVOKABLE void loadFile(QUrl file) - { - mp->playerLoadFile(file.toLocalFile().toStdString().c_str()); - mp->playerInit();curprog=0; - } - Q_INVOKABLE void playFile() - { - playerTh=new std::thread(&CMidiPlayer::playerThread,mp); - } - Q_INVOKABLE void stop() - { - mp->playerDeinit();playerTh->join();delete playerTh; - mp->playerPanic(); - } - Q_INVOKABLE int getProgress() - { - while(!mp->isFinished()&&mp->getTCeptr()>mp->getStamp(curprog) - &&curprog<=100) - ++curprog; - return curprog; - } - Q_INVOKABLE void panic(){mp->playerPanic();} - Q_INVOKABLE void setTCeptr(int perct) - { - mp->setTCeptr(mp->getStamp(perct),perct);curprog=perct; - } + explicit CQMPCoreWrapper(QObject *parent = 0): QObject(parent) + { + mp = new CMidiPlayer(); + } + ~CQMPCoreWrapper() + { + delete mp; + } + Q_INVOKABLE void initFluidSynth(QUrl sfpath) + { + mp->fluid()->setOptStr("audio.driver", "pulseaudio"); + mp->fluid()->deviceInit(); + mp->fluid()->loadSFont(sfpath.toLocalFile().toStdString().c_str()); + for (int i = 0; i < 16; ++i) + mp->setChannelOutput(i, 0); + } + Q_INVOKABLE void deinitFluidSynth() + { + mp->fluid()->deviceDeinit(); + } + Q_INVOKABLE void loadFile(QUrl file) + { + mp->playerLoadFile(file.toLocalFile().toStdString().c_str()); + mp->playerInit(); + curprog = 0; + } + Q_INVOKABLE void playFile() + { + playerTh = new std::thread(&CMidiPlayer::playerThread, mp); + } + Q_INVOKABLE void stop() + { + mp->playerDeinit(); + playerTh->join(); + delete playerTh; + mp->playerPanic(); + } + Q_INVOKABLE int getProgress() + { + while (!mp->isFinished() && mp->getTCeptr() > mp->getStamp(curprog) + && curprog <= 100) + ++curprog; + return curprog; + } + Q_INVOKABLE void panic() + { + mp->playerPanic(); + } + Q_INVOKABLE void setTCeptr(int perct) + { + mp->setTCeptr(mp->getStamp(perct), perct); + curprog = perct; + } }; #endif // QMPCOREWRAPPER_H |