Commit 4a558599 authored by Gustavo Carneiro's avatar Gustavo Carneiro Committed by Tomaz Canabrava
Browse files

minuet: clean code

parent 32bf62a5
...@@ -39,8 +39,9 @@ void CsEngine::run() ...@@ -39,8 +39,9 @@ void CsEngine::run()
QFile file(m_fileName); QFile file(m_fileName);
file.open(QIODevice::ReadOnly); file.open(QIODevice::ReadOnly);
qDebug() << "Template: "; qDebug() << "Template: ";
while (!file.atEnd()) while (!file.atEnd()) {
qDebug() << file.readLine(); qDebug() << file.readLine();
}
file.close(); file.close();
qWarning() << "Dir " << QDir::currentPath() << " contains sf_GMbank.sf2? " << QDir::current().entryList(QDir::Files).contains("sf_GMbank.sf2"); qWarning() << "Dir " << QDir::currentPath() << " contains sf_GMbank.sf2? " << QDir::current().entryList(QDir::Files).contains("sf_GMbank.sf2");
qWarning() << "Dir " << QCoreApplication::applicationDirPath() << " contains libfluidOpcodes.so? " << QDir(QCoreApplication::applicationDirPath()).entryList(QDir::Files).contains("libfluidOpcodes.so"); qWarning() << "Dir " << QCoreApplication::applicationDirPath() << " contains libfluidOpcodes.so? " << QDir(QCoreApplication::applicationDirPath()).entryList(QDir::Files).contains("libfluidOpcodes.so");
......
...@@ -62,12 +62,14 @@ void CsoundSoundController::openExerciseFile() ...@@ -62,12 +62,14 @@ void CsoundSoundController::openExerciseFile()
qDebug() << "RESERVED: " << reserved << " Contents: " << reserved.entryList(QDir::AllEntries); qDebug() << "RESERVED: " << reserved << " Contents: " << reserved.entryList(QDir::AllEntries);
QDirIterator it("/", QDirIterator::Subdirectories); QDirIterator it("/", QDirIterator::Subdirectories);
while (it.hasNext()) while (it.hasNext()) {
qDebug() << "FILE: " << it.next(); qDebug() << "FILE: " << it.next();
}
foreach (const QString &templateString, templateList) { foreach (const QString &templateString, templateList) {
QFile sfile(templateString); QFile sfile(templateString);
if (!sfile.open(QIODevice::ReadOnly | QIODevice::Text)) if (!sfile.open(QIODevice::ReadOnly | QIODevice::Text)) {
return; return;
}
QTextStream in(&sfile); QTextStream in(&sfile);
QString lineData; QString lineData;
...@@ -103,7 +105,7 @@ void CsoundSoundController::appendEvent(QList<unsigned int> midiNotes, QList<flo ...@@ -103,7 +105,7 @@ void CsoundSoundController::appendEvent(QList<unsigned int> midiNotes, QList<flo
QFile m_csdFileOpen(QStringLiteral("./template.csd")); QFile m_csdFileOpen(QStringLiteral("./template.csd"));
qDebug() << "CREATING " << QDir::currentPath() + "/template.csd"; qDebug() << "CREATING " << QDir::currentPath() + "/template.csd";
if(!m_csdFileOpen.isOpen()) { if (!m_csdFileOpen.isOpen()) {
m_csdFileOpen.open(QIODevice::ReadWrite | QIODevice::Text); m_csdFileOpen.open(QIODevice::ReadWrite | QIODevice::Text);
} }
m_csdFileOpen.resize(0); m_csdFileOpen.resize(0);
...@@ -114,13 +116,13 @@ void CsoundSoundController::appendEvent(QList<unsigned int> midiNotes, QList<flo ...@@ -114,13 +116,13 @@ void CsoundSoundController::appendEvent(QList<unsigned int> midiNotes, QList<flo
fifthParam = QStringLiteral(""); fifthParam = QStringLiteral("");
} }
for(int i=0; i<midiNotes.count(); i++) { for (int i = 0; i < midiNotes.count(); i++) {
QString initScore = QString("i 1 %1 %2 %3 %4\n").arg(QString::number(barStartInfo.at(i))).arg(QString::number(1)).arg(QString::number(midiNotes.at(i))).arg(fifthParam); QString initScore = QString("i 1 %1 %2 %3 %4\n").arg(QString::number(barStartInfo.at(i))).arg(QString::number(1)).arg(QString::number(midiNotes.at(i))).arg(fifthParam);
// content += initScore; // content += initScore;
} }
if (playMode != "rhythm") { if (playMode != "rhythm") {
QString instrInit = "i 99 0 " + QString::number(barStartInfo.at(barStartInfo.count()-1)+1) + "\ne\n";//instrument will be active till the end of the notes +1 second QString instrInit = "i 99 0 " + QString::number(barStartInfo.at(barStartInfo.count() -1) +1) + "\ne\n";//instrument will be active till the end of the notes +1 second
// content += instrInit; // content += instrInit;
} }
...@@ -142,7 +144,7 @@ void CsoundSoundController::prepareFromExerciseOptions(QJsonArray selectedExerci ...@@ -142,7 +144,7 @@ void CsoundSoundController::prepareFromExerciseOptions(QJsonArray selectedExerci
QList<float> barStartInfo; QList<float> barStartInfo;
if (m_playMode == "rhythm") { if (m_playMode == "rhythm") {
for(int k = 0; k < 4; ++k) { for (int k = 0; k < 4; ++k) {
midiNotes.append(80); midiNotes.append(80);
barStartInfo.append(barStart++); barStartInfo.append(barStart++);
} }
...@@ -159,7 +161,7 @@ void CsoundSoundController::prepareFromExerciseOptions(QJsonArray selectedExerci ...@@ -159,7 +161,7 @@ void CsoundSoundController::prepareFromExerciseOptions(QJsonArray selectedExerci
unsigned int j = 1; unsigned int j = 1;
foreach(const QString &additionalNote, sequence.split(' ')) { foreach(const QString &additionalNote, sequence.split(' ')) {
midiNotes.append(chosenRootNote+additionalNote.toInt()); midiNotes.append(chosenRootNote + additionalNote.toInt());
barStartInfo.append((m_playMode == "scale") ? barStart+j:barStart); barStartInfo.append((m_playMode == "scale") ? barStart+j:barStart);
++j; ++j;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment