Commit 0dfbd891 authored by Sandro Andrade's avatar Sandro Andrade

Refactor scale exercises to new architecture

parent a24c38a4
......@@ -2,6 +2,7 @@ set(minuet_DEFINITIONS
intervals-ascending-melodic-definitions.json
intervals-descending-melodic-definitions.json
chords-root-position-definitions.json
scales-major-and-its-modes-definitions.json
)
install(FILES ${minuet_DEFINITIONS} DESTINATION ${KDE_INSTALL_DATADIR}/minuet/definitions)
{
"definitions": [
{
"tags": ["scale", "ascending", "major"],
"name": "Ionian",
"sequence": "2 4 5 7 9 11 12"
},
{
"tags": ["scale", "ascending", "major"],
"name": "Dorian",
"sequence": "2 3 5 7 9 10 12"
},
{
"tags": ["scale", "ascending", "major"],
"name": "Phrygian",
"sequence": "1 3 5 7 8 10 12"
},
{
"tags": ["scale", "ascending", "major"],
"name": "Lydian",
"sequence": "2 4 6 7 9 11 12"
},
{
"tags": ["scale", "ascending", "major"],
"name": "Mixolydian",
"sequence": "2 4 5 7 9 10 12"
},
{
"tags": ["scale", "ascending", "major"],
"name": "Aeolian",
"sequence": "2 3 5 7 8 10 12"
},
{
"tags": ["scale", "ascending", "major"],
"name": "Locrian",
"sequence": "1 3 5 6 8 10 12"
}
]
}
......@@ -2,6 +2,7 @@ set(minuet_EXERCISES
intervals-ascending-melodic-exercises.json
intervals-descending-melodic-exercises.json
chords-root-position-exercises.json
scales-major-and-its-modes-exercises.json
)
install(FILES ${minuet_EXERCISES} DESTINATION ${KDE_INSTALL_DATADIR}/minuet/exercises)
{
"exercises": [
{
"name": "Scales",
"root": "21..104",
"playMode": "scale",
"userMessage": "the scale",
"children": [
{
"name": "Major Scale and its Modes",
"and-tags": ["scale", "major"]
}
]
}
]
}
{
"exercises": [
{
"name": "Scales",
"root": "21..104",
"playMode": "scale",
"userMessage": "the scale",
"children": [
{
"name": "Major Scale and its Modes",
"options": [
{
"name": "Ionian",
"sequence": "2 4 5 7 9 11 12"
},
{
"name": "Dorian",
"sequence": "2 3 5 7 9 10 12"
},
{
"name": "Phrygian",
"sequence": "1 3 5 7 8 10 12"
},
{
"name": "Lydian",
"sequence": "2 4 6 7 9 11 12"
},
{
"name": "Mixolydian",
"sequence": "2 4 5 7 9 10 12"
},
{
"name": "Aeolian",
"sequence": "2 3 5 7 8 10 12"
},
{
"name": "Locrian",
"sequence": "1 3 5 6 8 10 12"
}
]
}
]
}
]
}
......@@ -44,8 +44,7 @@ ExerciseController::ExerciseController(MidiSequencer *midiSequencer) :
m_maxRootNote(0),
m_playMode(ScalePlayMode),
m_answerLength(1),
m_chosenRootNote(0),
m_chosenExercise(0)
m_chosenRootNote(0)
{
m_exercises["exercises"] = QJsonArray();
m_exercises["definitions"] = QJsonArray();
......@@ -115,8 +114,8 @@ QStringList ExerciseController::randomlyChooseExercises()
}
for (unsigned int i = 0; i < m_answerLength; ++i) {
m_chosenExercise = qrand() % m_exerciseOptions.size();
QString sequence = m_exerciseOptions[m_chosenExercise].toObject()[QStringLiteral("sequence")].toString();
unsigned int chosenExercise = qrand() % m_exerciseOptions.size();
QString sequence = m_exerciseOptions[chosenExercise].toObject()[QStringLiteral("sequence")].toString();
if (m_playMode != RhythmPlayMode) {
int minNote = INT_MAX;
......@@ -163,7 +162,7 @@ QStringList ExerciseController::randomlyChooseExercises()
}
}
chosenExercises << m_exerciseOptions[m_chosenExercise].toObject()[QStringLiteral("name")].toString();
chosenExercises << m_exerciseOptions[chosenExercise].toObject()[QStringLiteral("name")].toString();
}
if (m_playMode == RhythmPlayMode) {
m_midiSequencer->appendEvent(m_midiSequencer->SMFNoteOn(9, 80, 120), barStart);
......
......@@ -84,7 +84,6 @@ private:
PlayMode m_playMode;
unsigned int m_answerLength;
unsigned int m_chosenRootNote;
unsigned int m_chosenExercise;
QString m_errorString;
};
......
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