Commit 994c7b67 authored by Sandro Andrade's avatar Sandro Andrade

Clear pianoview note marks when starting/changing exercises

parent 8a0bd2fc
......@@ -94,11 +94,6 @@
"name": "Major 7(#5)",
"sequence": "4 8 10"
},
{
"tags": ["chord", "root-position", "major", "7", "9", "altered"],
"name": "Major 9",
"sequence": "4 7 10 14"
},
{
"tags": ["chord", "root-position", "major", "7", "9", "altered"],
"name": "Major 7(#9)",
......
......@@ -40,5 +40,10 @@ IExerciseController::~IExerciseController()
{
}
QJsonArray IExerciseController::selectedOptions() const
{
return m_selectedOptions;
}
}
......@@ -38,18 +38,23 @@ class MINUETINTERFACES_EXPORT IExerciseController : public QObject
Q_PROPERTY(quint8 minRootNote MEMBER m_minRootNote)
Q_PROPERTY(quint8 maxRootNote MEMBER m_maxRootNote)
Q_PROPERTY(QJsonArray exercises READ exercises)
Q_PROPERTY(QJsonObject currentExercise MEMBER m_currentExercise)
Q_PROPERTY(QJsonObject currentExercise MEMBER m_currentExercise NOTIFY currentExerciseChanged)
Q_PROPERTY(quint8 answerLength MEMBER m_answerLength)
Q_PROPERTY(QJsonArray selectedOptions MEMBER m_selectedOptions)
Q_PROPERTY(QJsonArray selectedOptions READ selectedOptions NOTIFY selectedOptionsChanged)
public:
virtual ~IExerciseController() override;
virtual QJsonArray exercises() const = 0;
QJsonArray selectedOptions() const;
public Q_SLOTS:
virtual void randomlySelectOptions() = 0;
Q_SIGNALS:
void currentExerciseChanged(QJsonObject newCurrentExercise);
void selectedOptionsChanged(QJsonArray newSelectedOptions);
protected:
explicit IExerciseController(QObject *parent = 0);
......
......@@ -129,7 +129,7 @@ void MidiSequencerOutputThread::setPitch(qint8 value)
stop();
unsigned int pos = m_Queue->getStatus().getTickTime();
m_Queue->clear();
allNotesOff();
mute();
setPosition(pos);
}
m_pitchShift = value;
......@@ -164,7 +164,7 @@ void MidiSequencerOutputThread::resetPosition()
}
}
void MidiSequencerOutputThread::allNotesOff()
void MidiSequencerOutputThread::mute()
{
for(int chan = 0; chan < MIDI_CHANNELS; ++chan) {
sendControllerEvent(chan, MIDI_CTL_ALL_NOTES_OFF, 0);
......
......@@ -54,7 +54,7 @@ public:
void resetPosition();
private:
void allNotesOff();
void mute();
void sendControllerEvent(int chan, int control, int value);
private:
......
......@@ -91,6 +91,7 @@ void ExerciseController::randomlySelectOptions()
exerciseOptions[chosenExerciseOption] = jsonObject;
m_selectedOptions.append(exerciseOptions[chosenExerciseOption]);
}
emit selectedOptionsChanged(m_selectedOptions);
}
unsigned int ExerciseController::chosenRootNote()
......
......@@ -258,7 +258,6 @@ Item {
name: "waitingForAnswer"
StateChangeScript {
script: {
// sequencer.allNotesOff()
for (var i = 0; i < answerGrid.children.length; ++i) {
answerGrid.children[i].opacity = 1
answerGrid.children[i].enabled = true
......
......@@ -45,9 +45,20 @@ Item {
width: menuBarWidth; height: parent.height - midiPlayer.height
anchors { left: parent.left; top: parent.top }
onCurrentExerciseChanged: { exerciseView.setCurrentExercise(currentExercise); rhythmAnswerView.resetAnswers() }
onBackPressed: { core.soundBackend.stop(); exerciseView.clearExerciseGrid() }
onUserMessageChanged: { exerciseView.changeUserMessage(message); mainItem.userMessageChanged(message) }
onCurrentExerciseChanged: {
exerciseView.setCurrentExercise(currentExercise)
rhythmAnswerView.resetAnswers()
core.exerciseController.currentExercise = currentExercise
}
onBackPressed: {
core.soundBackend.stop()
exerciseView.clearExerciseGrid()
pianoView.clearAllMarks()
}
onUserMessageChanged: {
exerciseView.changeUserMessage(message)
mainItem.userMessageChanged(message)
}
}
MidiPlayer {
id: midiPlayer
......@@ -98,11 +109,6 @@ Item {
onChosenExercisesChanged: rhythmAnswerView.fillCorrectAnswerGrid()
}
}
Binding {
target: core.exerciseController
property: "currentExercise"
value: minuetMenu.currentExercise
}
Binding {
target: core.soundBackend
property: "pitch"
......@@ -118,10 +124,9 @@ Item {
property: "tempo"
value: midiPlayer.tempo
}
// Connections {
// target: sequencer
// onNoteOn: pianoView.noteOn(chan, pitch, vel)
// onNoteOff: pianoView.noteOff(chan, pitch, vel)
// onAllNotesOff: pianoView.allNotesOff()
// }
Connections {
target: core.exerciseController
onSelectedOptionsChanged: pianoView.clearAllMarks()
onCurrentExerciseChanged: pianoView.clearAllMarks()
}
}
......@@ -30,7 +30,7 @@ Item {
id: minuetMenu
property string message
readonly property alias currentExercise: stackView.currentExercise
property var currentExercise
signal backPressed
signal userMessageChanged(string message)
......@@ -52,7 +52,6 @@ Item {
StackView {
id: stackView
property var currentExercise
property Item currentExerciseMenuItem
width: parent.width - breadcrumb.width; height: parent.height
......@@ -77,7 +76,7 @@ Item {
if (!children) {
if (stackView.currentExerciseMenuItem != undefined) stackView.currentExerciseMenuItem.checked = false
userMessageChanged(message)
stackView.currentExercise = delegateRect.ListView.view.model[index]
currentExercise = delegateRect.ListView.view.model[index]
stackView.currentExerciseMenuItem = delegateRect
}
else {
......
......@@ -43,7 +43,7 @@ Rectangle {
if (item != undefined)
item.destroy()
}
function allNotesOff() {
function clearAllMarks() {
for (var index = 21; index <= 108; ++index) {
noteOff(0, index, 0)
var markItem = itemForPitch(index).children[1]
......
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