|
@@ -71,18 +71,11 @@ void PlaybackScreen::keyPressed(unsigned char x, unsigned char y)
|
|
} else {
|
|
} else {
|
|
Player::BeatIndex beatIndex = x + beatDisplayOffset;
|
|
Player::BeatIndex beatIndex = x + beatDisplayOffset;
|
|
if(beatIndex < sequencer.beats.size() && y < sequencer.messages.size()) {
|
|
if(beatIndex < sequencer.beats.size() && y < sequencer.messages.size()) {
|
|
- const midi::MessageList& beat = sequencer.beats[beatIndex];
|
|
|
|
- std::shared_ptr<midi::Message> msg_ptr = sequencer.messages[y];
|
|
|
|
- // msg_ptr->print(std::cout);
|
|
|
|
- midi::MessageList::const_iterator beat_msg_it = beat.find(*msg_ptr);
|
|
|
|
- if(beat_msg_it == beat.end()) {
|
|
|
|
- // insert message at beat
|
|
|
|
- sequencer.beats.pushBackMessage(beatIndex, msg_ptr);
|
|
|
|
- } else {
|
|
|
|
- // remove message from beat
|
|
|
|
- sequencer.beats.eraseMessage(beatIndex, beat_msg_it);
|
|
|
|
|
|
+ std::shared_ptr<midi::NoteOnMessage> noteOnMessage_ptr
|
|
|
|
+ = std::dynamic_pointer_cast<midi::NoteOnMessage>(sequencer.messages[y]);
|
|
|
|
+ if(noteOnMessage_ptr) {
|
|
|
|
+ toggleOnMessage(noteOnMessage_ptr, beatIndex);
|
|
}
|
|
}
|
|
- sequencer.beats.printRegistry(std::cout);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -149,3 +142,19 @@ void PlaybackScreen::refresh(unsigned char x, unsigned char y)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+void PlaybackScreen::toggleOnMessage(std::shared_ptr<midi::NoteOnMessage> noteOnMessage_ptr, Player::BeatIndex beatIndex)
|
|
|
|
+{
|
|
|
|
+ noteOnMessage_ptr->print(std::cout);
|
|
|
|
+
|
|
|
|
+ const midi::MessageList& beat = sequencer.beats[beatIndex];
|
|
|
|
+ midi::MessageList::const_iterator beat_msg_it = beat.find(*noteOnMessage_ptr);
|
|
|
|
+ if(beat_msg_it == beat.end()) {
|
|
|
|
+ // insert message at beat
|
|
|
|
+ sequencer.beats.pushBackMessage(beatIndex, std::dynamic_pointer_cast<midi::Message>(noteOnMessage_ptr));
|
|
|
|
+ } else {
|
|
|
|
+ // remove message from beat
|
|
|
|
+ sequencer.beats.eraseMessage(beatIndex, beat_msg_it);
|
|
|
|
+ }
|
|
|
|
+ sequencer.beats.printRegistry(std::cout);
|
|
|
|
+}
|