12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #pragma once
- #include "midi/BeatSequence.h"
- #include "multiset.h"
- #include <map>
- #include <ostream>
- class BeatSequenceNoteInformation
- {
- public:
- typedef multiset<midi::BeatSequence::BeatIndex> 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<midi::NoteMessage>& noteMsg_ptr);
- void unregisterMessage(midi::BeatSequence::BeatIndex beatIndex, const std::shared_ptr<midi::NoteMessage>& noteMsg_ptr);
- };
- class BeatSequence : public midi::BeatSequence
- {
- typedef midi::BeatSequence parent;
- typedef midi::ChannelMessage::Channel Channel;
- typedef midi::NoteMessage::Pitch Pitch;
- typedef std::pair<Channel, Pitch> ChannelPitchPair;
- typedef std::map<ChannelPitchPair, BeatSequenceNoteInformation> NoteInfoMap;
- typedef BeatSequenceNoteInformation::BeatIndexMultiset BeatIndexMultiset;
- NoteInfoMap noteInfos;
- public:
- void resize(BeatIndex size);
- void pushFrontMessage(BeatIndex beatIndex, std::shared_ptr<midi::Message> msg_ptr);
- void pushBackMessage(BeatIndex beatIndex, std::shared_ptr<midi::Message> 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<midi::Message>& msg_ptr);
- void unregisterMessage(BeatIndex beatIndex, const std::shared_ptr<midi::Message>& msg_ptr);
- };
|