#pragma once #include "midi/BeatSequence.h" #include "multiset.h" #include #include class BeatSequenceNoteInformation { public: typedef multiset BeatIndexMultiset; BeatIndexMultiset onBeatIndices, offBeatIndices; void print(std::ostream& stream, std::size_t indent = 0) const; void registerMessage(midi::BeatSequence::BeatIndex beatIndex, const std::shared_ptr& noteMsg_ptr); void unregisterMessage(midi::BeatSequence::BeatIndex beatIndex, const std::shared_ptr& noteMsg_ptr); }; class BeatSequence : public midi::BeatSequence { typedef midi::BeatSequence parent; typedef midi::ChannelMessage::Channel Channel; typedef midi::NoteMessage::Pitch Pitch; typedef std::pair ChannelPitchPair; typedef std::map NoteInfoMap; typedef BeatSequenceNoteInformation::BeatIndexMultiset BeatIndexMultiset; NoteInfoMap noteInfos; public: void resize(BeatIndex size); void pushFrontMessage(BeatIndex beatIndex, std::shared_ptr msg_ptr); void pushBackMessage(BeatIndex beatIndex, std::shared_ptr msg_ptr); void eraseMessage(BeatIndex beatIndex, midi::MessageList::iterator msg_it); void expand(BeatIndex factor); void reduceToNeighbour(BeatIndex factor); void reduceErasingConflicts(BeatIndex factor); const BeatIndexMultiset& getNoteOnBeatIndices(Channel channel, Pitch pitch); const BeatIndexMultiset& getNoteOffBeatIndices(Channel channel, Pitch pitch); const BeatSequenceNoteInformation& getNoteInfo(Channel channel, Pitch pitch); void printRegistry(std::ostream& stream) const; private: BeatSequenceNoteInformation& getMutableNoteInfo(Channel channel, Pitch pitch); void refreshRegistry(); void registerMessage(BeatIndex beatIndex, const std::shared_ptr& msg_ptr); void unregisterMessage(BeatIndex beatIndex, const std::shared_ptr& msg_ptr); };