diff options
Diffstat (limited to 'qmpmainwindow.cpp')
-rw-r--r-- | qmpmainwindow.cpp | 118 |
1 files changed, 107 insertions, 11 deletions
diff --git a/qmpmainwindow.cpp b/qmpmainwindow.cpp index 525cb1e..d6cfc6e 100644 --- a/qmpmainwindow.cpp +++ b/qmpmainwindow.cpp @@ -1,5 +1,6 @@ #include <cstdio> #include <QUrl> +#include <QDesktopWidget> #include "qmpmainwindow.hpp" #include "ui_qmpmainwindow.h" #include "qmpmidiplay.hpp" @@ -20,8 +21,26 @@ qmpMainWindow::qmpMainWindow(QWidget *parent) : infow=new qmpInfoWindow(this); timer=new QTimer(this); fnA1=new QAction("File Information",ui->lbFileName); + fnA2=new QAction("Render to Wave",ui->lbFileName); ui->lbFileName->addAction(fnA1); + ui->lbFileName->addAction(fnA2); + if(qmpSettingsWindow::getSettingsIntf()->value("Behavior/DialogStatus","").toInt()) + { + QRect g=geometry(); + g.setTopLeft(qmpSettingsWindow::getSettingsIntf()->value("DialogStatus/MainW",QPoint(-999,-999)).toPoint()); + if(g.topLeft()!=QPoint(-999,-999))setGeometry(g); + else setGeometry(QStyle::alignedRect( + Qt::LeftToRight,Qt::AlignCenter,size(), + qApp->desktop()->availableGeometry())); + } + if(qmpSettingsWindow::getSettingsIntf()->value("DialogStatus/PListWShown",0).toInt()) + {ui->pbPList->setChecked(true);on_pbPList_clicked();} + if(qmpSettingsWindow::getSettingsIntf()->value("DialogStatus/ChnlWShown",0).toInt()) + {ui->pbChannels->setChecked(true);on_pbChannels_clicked();} + if(qmpSettingsWindow::getSettingsIntf()->value("DialogStatus/EfxWShown",0).toInt()) + {ui->pbEfx->setChecked(true);on_pbEfx_clicked();} connect(fnA1,SIGNAL(triggered()),this,SLOT(onfnA1())); + connect(fnA2,SIGNAL(triggered()),this,SLOT(onfnA2())); connect(timer,SIGNAL(timeout()),this,SLOT(updateWidgets())); connect(timer,SIGNAL(timeout()),chnlw,SLOT(channelWindowsUpdate())); connect(timer,SIGNAL(timeout()),infow,SLOT(updateInfo())); @@ -35,7 +54,7 @@ qmpMainWindow::~qmpMainWindow() void qmpMainWindow::closeEvent(QCloseEvent *event) { - on_pbStop_clicked(); + on_pbStop_clicked();fin=true; efxw->close();chnlw->close(); plistw->close();infow->close(); settingsw->close(); @@ -47,8 +66,17 @@ void qmpMainWindow::closeEvent(QCloseEvent *event) event->accept(); } +void qmpMainWindow::moveEvent(QMoveEvent *event) +{ + if(qmpSettingsWindow::getSettingsIntf()->value("Behavior/DialogStatus","").toInt()) + { + qmpSettingsWindow::getSettingsIntf()->setValue("DialogStatus/MainW",event->pos()); + } +} + void qmpMainWindow::updateWidgets() { + fnA2->setEnabled(stopped); if(player->isFinished()&&playerTh) { if(!plistw->getRepeat()) @@ -77,12 +105,22 @@ void qmpMainWindow::updateWidgets() player->playerInit();playerSetup();player->fluidInitialize(); for(int i=settingsw->getSFWidget()->count()-1;i>=0;--i) player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str()); - player->setGain(ui->vsMasterVol->value()/250.); + player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange(); playerTh=new std::thread(&CMidiPlayer::playerThread,player); st=std::chrono::steady_clock::now();offset=0; timer->start(100); } } + if(renderTh) + { + if(player->isFinished()) + { + renderTh->join();timer->stop(); + ui->centralWidget->setEnabled(true); + delete renderTh;renderTh=NULL; + player->rendererDeinit(); + } + } while(!player->isFinished()&&player->getTCeptr()>player->getStamp(ui->hsTimer->value()) &&ui->hsTimer->value()<=100&&!dragging) ui->hsTimer->setValue(ui->hsTimer->value()+1); @@ -103,7 +141,7 @@ QString qmpMainWindow::getFileName(){return ui->lbFileName->text();} void qmpMainWindow::playerSetup() { fluid_settings_t* fsettings=player->getFluidSettings(); - const QSettings* settings=qmpSettingsWindow::getSettingsIntf(); + QSettings* settings=qmpSettingsWindow::getSettingsIntf(); fluid_settings_setstr(fsettings,"audio.driver",settings->value("Audio/Driver","").toString().toStdString().c_str()); fluid_settings_setint(fsettings,"audio.period-size",settings->value("Audio/BufSize","").toInt()); fluid_settings_setint(fsettings,"audio.periods",settings->value("Audio/BufCnt","").toInt()); @@ -111,6 +149,28 @@ void qmpMainWindow::playerSetup() fluid_settings_setint(fsettings,"synth.sample-rate",settings->value("Audio/Frequency","").toInt()); fluid_settings_setint(fsettings,"synth.polyphony",settings->value("Audio/Polyphony","").toInt()); fluid_settings_setint(fsettings,"synth.cpu-cores",settings->value("Audio/Threads","").toInt()); + char bsmode[4]; + if(settings->value("Audio/AutoBS",1).toInt()&&player->getFileStandard()) + switch(player->getFileStandard()) + { + case 1:strcpy(bsmode,"gm");break; + case 2:strcpy(bsmode,"mma");break; + case 3:strcpy(bsmode,"gs");break; + case 4:strcpy(bsmode,"xg");break; + } + else + { + if(settings->value("Audio/BankSelect","CC#0").toString()==QString("Ignored")) + strcpy(bsmode,"gm"); + if(settings->value("Audio/BankSelect","CC#0").toString()==QString("CC#0")) + strcpy(bsmode,"gs"); + if(settings->value("Audio/BankSelect","CC#0").toString()==QString("CC#32")) + strcpy(bsmode,"xg"); + if(settings->value("Audio/BankSelect","CC#0").toString()==QString("CC#0*128+CC#32")) + strcpy(bsmode,"mma"); + } + fluid_settings_setstr(fsettings,"synth.midi-bank-select",bsmode); + player->sendSysX(settings->value("Midi/SendSysEx",1).toInt()); } void qmpMainWindow::on_pbPlayPause_clicked() @@ -128,7 +188,7 @@ void qmpMainWindow::on_pbPlayPause_clicked() player->playerInit();playerSetup();player->fluidInitialize(); for(int i=settingsw->getSFWidget()->count()-1;i>=0;--i) player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str()); - player->setGain(ui->vsMasterVol->value()/250.); + player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange(); playerTh=new std::thread(&CMidiPlayer::playerThread,player); st=std::chrono::steady_clock::now();offset=0; timer->start(100); @@ -187,7 +247,7 @@ void qmpMainWindow::on_pbStop_clicked() if(!stopped) { timer->stop();stopped=true;playing=false; - player->playerDeinit(); + player->playerDeinit();fnA2->setEnabled(stopped); if(playerTh){playerTh->join();delete playerTh;playerTh=NULL;} chnlw->on_pbUnmute_clicked();chnlw->on_pbUnsolo_clicked(); ui->pbPlayPause->setIcon(QIcon(":/img/play.png")); @@ -207,12 +267,28 @@ void qmpMainWindow::dialogClosed() void qmpMainWindow::on_pbPList_clicked() { - if(ui->pbPList->isChecked())plistw->show();else plistw->close(); + if(ui->pbPList->isChecked()) + { + QRect g=plistw->geometry(); + g.setTopLeft(qmpSettingsWindow::getSettingsIntf()->value("DialogStatus/PListW",QPoint(-999,-999)).toPoint()); + if(g.topLeft()==QPoint(-999,-999)) + g.setTopLeft(window()->mapToGlobal(window()->rect().center())-plistw->rect().center()); + plistw->setGeometry(g); + plistw->show(); + }else plistw->close(); } void qmpMainWindow::on_pbChannels_clicked() { - if(ui->pbChannels->isChecked())chnlw->show();else chnlw->close(); + if(ui->pbChannels->isChecked()) + { + QRect g=chnlw->geometry(); + g.setTopLeft(qmpSettingsWindow::getSettingsIntf()->value("DialogStatus/ChnlW",QPoint(-999,-999)).toPoint()); + if(g.topLeft()==QPoint(-999,-999)) + g.setTopLeft(window()->mapToGlobal(window()->rect().center())-chnlw->rect().center()); + chnlw->setGeometry(g); + chnlw->show(); + }else chnlw->close(); } void qmpMainWindow::on_pbPrev_clicked() @@ -229,7 +305,7 @@ void qmpMainWindow::on_pbPrev_clicked() player->playerInit();playerSetup();player->fluidInitialize(); for(int i=settingsw->getSFWidget()->count()-1;i>=0;--i) player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str()); - player->setGain(ui->vsMasterVol->value()/250.); + player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange(); playerTh=new std::thread(&CMidiPlayer::playerThread,player); st=std::chrono::steady_clock::now();offset=0; timer->start(100); @@ -249,7 +325,7 @@ void qmpMainWindow::on_pbNext_clicked() player->playerInit();playerSetup();player->fluidInitialize(); for(int i=settingsw->getSFWidget()->count()-1;i>=0;--i) player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str()); - player->setGain(ui->vsMasterVol->value()/250.); + player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange(); playerTh=new std::thread(&CMidiPlayer::playerThread,player); st=std::chrono::steady_clock::now();offset=0; timer->start(100); @@ -272,7 +348,7 @@ void qmpMainWindow::selectionChanged() player->playerInit();playerSetup();player->fluidInitialize(); for(int i=settingsw->getSFWidget()->count()-1;i>=0;--i) player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str()); - player->setGain(ui->vsMasterVol->value()/250.); + player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange(); playerTh=new std::thread(&CMidiPlayer::playerThread,player); st=std::chrono::steady_clock::now();offset=0; timer->start(100); @@ -280,7 +356,16 @@ void qmpMainWindow::selectionChanged() void qmpMainWindow::on_pbEfx_clicked() { - if(ui->pbEfx->isChecked())efxw->show();else efxw->close(); + if(ui->pbEfx->isChecked()) + { + QRect g=efxw->geometry(); + g.setTopLeft(qmpSettingsWindow::getSettingsIntf()->value("DialogStatus/EfxW",QPoint(-999,-999)).toPoint()); + if(g.topLeft()==QPoint(-999,-999)) + g.setTopLeft(window()->mapToGlobal(window()->rect().center())-efxw->rect().center()); + efxw->setGeometry(g); + efxw->show(); + } + else efxw->close(); } void qmpMainWindow::on_lbFileName_customContextMenuRequested(const QPoint &pos) @@ -295,6 +380,17 @@ void qmpMainWindow::onfnA1() infow->show(); } +void qmpMainWindow::onfnA2() +{ + player->rendererLoadFile((plistw->getSelectedItem()+QString(".wav")).toStdString().c_str()); + playerSetup();player->rendererInit(plistw->getSelectedItem().toStdString().c_str()); + ui->centralWidget->setEnabled(false); + for(int i=settingsw->getSFWidget()->count()-1;i>=0;--i) + player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str()); + player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange();timer->start(100); + renderTh=new std::thread(&CMidiPlayer::rendererThread,player); +} + void qmpMainWindow::on_pbSettings_clicked() { if(ui->pbSettings->isChecked())settingsw->show();else settingsw->close(); |