Skip to content

Commit

Permalink
Improved design of the window, added piano keyboard to test notes
Browse files Browse the repository at this point in the history
  • Loading branch information
Wohlstand committed Jun 9, 2016
1 parent f368fb8 commit ec1e197
Show file tree
Hide file tree
Showing 15 changed files with 2,162 additions and 1,180 deletions.
10 changes: 8 additions & 2 deletions FMBankEdit.pro
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,27 @@ MOC_DIR = $$BUILD_OBJ_DIR/_build_$$ARCH/$$TARGET/_$$BUILDTP/.moc
RCC_DIR = $$BUILD_OBJ_DIR/_build_$$ARCH/$$TARGET/_$$BUILDTP/.rcc
UI_DIR = $$BUILD_OBJ_DIR/_build_$$ARCH/$$TARGET/_$$BUILDTP/.ui

win32: RC_FILE = $$PWD/resources/res.rc

SOURCES += main.cpp\
bank_editor.cpp \
ins_names.cpp \
bank.cpp \
FileFormats/junlevizion.cpp \
opl/dbopl.cpp \
opl/generator.cpp
opl/generator.cpp \
piano.cpp

HEADERS += bank_editor.h \
ins_names.h \
bank.h \
FileFormats/junlevizion.h \
version.h \
opl/dbopl.h \
opl/generator.h
opl/generator.h \
piano.h

FORMS += bank_editor.ui

RESOURCES += \
resources/resources.qrc
165 changes: 105 additions & 60 deletions bank_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//#include <QtDebug>

BankEditor::BankEditor(QWidget *parent) :
QDialog(parent),
QMainWindow(parent),
ui(new Ui::BankEditor)
{
ui->setupUi(this);
Expand Down Expand Up @@ -65,6 +65,10 @@ BankEditor::BankEditor(QWidget *parent) :
connect(ui->deepVibrato, SIGNAL(toggled(bool)), m_generator, SLOT(changeDeepVibrato(bool)));
connect(ui->deepTremolo, SIGNAL(toggled(bool)), m_generator, SLOT(changeDeepTremolo(bool)));

connect(ui->piano, SIGNAL(gotNote(int)), ui->noteToTest, SLOT(setValue(int)));
connect(ui->piano, SIGNAL(pressed()), m_generator, SLOT(PlayNote()));
connect(ui->piano, SIGNAL(released()), m_generator, SLOT(MuteNote()));

//qDebug() << "Start generator";
m_generator->start();

Expand All @@ -83,6 +87,82 @@ BankEditor::~BankEditor()
delete ui;
}

void BankEditor::on_actionNew_triggered()
{
ui->currentFile->setText(tr("<Untitled>"));
m_bank.reset();
on_instruments_currentItemChanged(NULL, NULL);
}

void BankEditor::on_actionAbout_triggered()
{
QMessageBox::information(this,
tr("About bank editor"),
tr("FM Bank Editor for Yamaha OPL3/OPL2 chip, Version %1\n\n"
"(c) 2016, Vitaly Novichkov \"Wohlstand\"\n"
"\n"
"Licensed under GNU GPLv3\n\n"
"Source code available on GitHub:\n"
"%2").arg(VERSION).arg("https://github.com/Wohlstand/OPL3BankEditor"),
QMessageBox::Ok);

}

void BankEditor::on_actionOpen_triggered()
{
QString fileToOpen;
fileToOpen = QFileDialog::getOpenFileName(this, "Open bank file", m_recentPath, "JunleVision bank (*.op3)");
if(fileToOpen.isEmpty())
return;

int err = JunleVizion::loadFile(fileToOpen, m_bank);
if(err != JunleVizion::ERR_OK)
{
QString errText;
switch(err)
{
case JunleVizion::ERR_BADFORMAT: errText = "Bad file format"; break;
case JunleVizion::ERR_NOFILE: errText = "Can't open file"; break;
}
QMessageBox::warning(this, "Can't open bank file!", "Can't open bank file because "+errText, QMessageBox::Ok);
} else {
m_recentPath = fileToOpen;
if(!ui->instruments->selectedItems().isEmpty())
on_instruments_currentItemChanged(ui->instruments->selectedItems().first(), NULL);
else
on_instruments_currentItemChanged(NULL, NULL);
ui->currentFile->setText(fileToOpen);
}
}

void BankEditor::on_actionSave_triggered()
{
QString fileToSave;
fileToSave = QFileDialog::getSaveFileName(this, "Save bank file", m_recentPath, "JunleVision bank (*.op3)");
if(fileToSave.isEmpty())
return;

int err = JunleVizion::saveFile(fileToSave, m_bank);
if(err != JunleVizion::ERR_OK)
{
QString errText;
switch(err)
{
case JunleVizion::ERR_NOFILE: errText = "Can't open file for write!"; break;
}
QMessageBox::warning(this, "Can't save bank file!", "Can't save bank file because "+errText, QMessageBox::Ok);
} else {
ui->currentFile->setText(fileToSave);
}
}

void BankEditor::on_actionExit_triggered()
{
this->close();
}



void BankEditor::pushTimerExpired()
{
if (m_audioOutput && m_audioOutput->state() != QAudio::StoppedState)
Expand Down Expand Up @@ -127,9 +207,14 @@ void BankEditor::loadInstrument()
if(!m_curInst)
{
ui->editzone->setEnabled(false);
ui->testNoteBox->setEnabled(false);
ui->piano->setEnabled(false);
return;
}

ui->editzone->setEnabled(true);
ui->testNoteBox->setEnabled(true);
ui->piano->setEnabled(ui->melodic->isChecked());

m_lock = true;
ui->perc_noteNum->setValue( m_curInst->percNoteNum );
Expand Down Expand Up @@ -212,8 +297,26 @@ void BankEditor::sendPatch()
m_generator->changePatch(*m_curInst);
}

void BankEditor::setDrumMode(bool dmode)
{
if(dmode)
{
if(ui->noteToTest->isEnabled())
{
m_recentMelodicNote = ui->noteToTest->value();
}
} else {
ui->noteToTest->setValue(m_recentMelodicNote);
}
ui->noteToTest->setDisabled(dmode);
ui->testMajor->setDisabled(dmode);
ui->testMinor->setDisabled(dmode);
ui->piano->setDisabled(dmode);
}

void BankEditor::setMelodic()
{
setDrumMode(false);
ui->instruments->clear();
for(int i=0; i<128; i++)
{
Expand All @@ -223,15 +326,11 @@ void BankEditor::setMelodic()
item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
ui->instruments->addItem(item);
}
ui->noteToTest->setValue(m_recentMelodicNote);
ui->noteToTest->setDisabled(false);
}

void BankEditor::setDrums()
{
if(ui->noteToTest->isEnabled())
m_recentMelodicNote = ui->noteToTest->value();
ui->noteToTest->setDisabled(true);
setDrumMode(true);
ui->instruments->clear();
for(int i=0; i<128; i++)
{
Expand All @@ -243,53 +342,6 @@ void BankEditor::setDrums()
}
}

void BankEditor::on_openBank_clicked()
{
QString fileToOpen;
fileToOpen = QFileDialog::getOpenFileName(this, "Open bank file", m_recentPath, "JunleVision bank (*.op3)");
if(fileToOpen.isEmpty())
return;

int err = JunleVizion::loadFile(fileToOpen, m_bank);
if(err != JunleVizion::ERR_OK)
{
QString errText;
switch(err)
{
case JunleVizion::ERR_BADFORMAT: errText = "Bad file format"; break;
case JunleVizion::ERR_NOFILE: errText = "Can't open file"; break;
}
QMessageBox::warning(this, "Can't open bank file!", "Can't open bank file because "+errText, QMessageBox::Ok);
} else {
m_recentPath = fileToOpen;
if(!ui->instruments->selectedItems().isEmpty())
on_instruments_currentItemChanged(ui->instruments->selectedItems().first(), NULL);
else
on_instruments_currentItemChanged(NULL, NULL);
}
}

void BankEditor::on_SaveBank_clicked()
{
QString fileToOpen;
fileToOpen = QFileDialog::getSaveFileName(this, "Save bank file", m_recentPath, "JunleVision bank (*.op3)");
if(fileToOpen.isEmpty())
return;

int err = JunleVizion::saveFile(fileToOpen, m_bank);
if(err != JunleVizion::ERR_OK)
{
QString errText;
switch(err)
{
case JunleVizion::ERR_NOFILE: errText = "Can't open file for write!"; break;
}
QMessageBox::warning(this, "Can't save bank file!", "Can't save bank file because "+errText, QMessageBox::Ok);
}
}






Expand Down Expand Up @@ -784,10 +836,3 @@ void BankEditor::on_op4_ksr_toggled(bool checked)
}









16 changes: 12 additions & 4 deletions bank_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <QAudioOutput>
#include <QTimer>
#include <QDialog>
#include <QMainWindow>
#include <QList>
#include <QListWidgetItem>
#include "bank.h"
Expand All @@ -13,7 +13,7 @@ namespace Ui {
class BankEditor;
}

class BankEditor : public QDialog
class BankEditor : public QMainWindow
{
Q_OBJECT

Expand All @@ -30,15 +30,20 @@ class BankEditor : public QDialog

void sendPatch();

void setDrumMode(bool dmode);

public slots:
void setMelodic();
void setDrums();

private slots:
void on_instruments_currentItemChanged(QListWidgetItem *current, QListWidgetItem *);

void on_openBank_clicked();
void on_SaveBank_clicked();
void on_actionAbout_triggered();
void on_actionOpen_triggered();
void on_actionSave_triggered();
void on_actionExit_triggered();


void on_feedback1_valueChanged(int arg1);
void on_am1_clicked(bool checked);
Expand Down Expand Up @@ -106,6 +111,9 @@ private slots:

void pushTimerExpired();


void on_actionNew_triggered();

private:
Ui::BankEditor *ui;
bool m_lock;
Expand Down
Loading

1 comment on commit ec1e197

@Alucard648
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for piano. That was surprisingly quick.

Please sign in to comment.