BeatSequence.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "midi/BeatSequence.h"
  2. #include <set>
  3. #include <map>
  4. #include <ostream>
  5. class BeatSequenceNoteInformation
  6. {
  7. typedef std::multiset<midi::BeatSequence::BeatIndex> BeatIndexMultiset;
  8. public:
  9. BeatIndexMultiset onBeatIndices, offBeatIndices;
  10. void print(std::ostream& stream, std::size_t indent = 0) const;
  11. void registerMessage(midi::BeatSequence::BeatIndex beatIndex, const std::shared_ptr<midi::NoteMessage>& noteMsg_ptr);
  12. void unregisterMessage(midi::BeatSequence::BeatIndex beatIndex, const std::shared_ptr<midi::NoteMessage>& noteMsg_ptr);
  13. };
  14. class BeatSequence : public midi::BeatSequence
  15. {
  16. typedef midi::BeatSequence parent;
  17. typedef midi::ChannelMessage::Channel Channel;
  18. typedef midi::NoteMessage::Pitch Pitch;
  19. typedef std::pair<Channel, Pitch> ChannelPitchPair;
  20. typedef std::map<ChannelPitchPair, BeatSequenceNoteInformation> NoteInfoMap;
  21. NoteInfoMap noteInfos;
  22. public:
  23. const midi::MessageList& at(BeatIndex beatIndex) const;
  24. const midi::MessageList& operator[](BeatIndex beatIndex) const;
  25. void resize(BeatIndex size);
  26. void pushBackMessage(BeatIndex beatIndex, std::shared_ptr<midi::Message>& msg_ptr);
  27. void eraseMessage(BeatIndex beatIndex, midi::MessageList::const_iterator msg_it);
  28. void expand(BeatIndex factor);
  29. void reduceToNeighbour(BeatIndex factor);
  30. void reduceErasingConflicts(BeatIndex factor);
  31. void printRegistry(std::ostream& stream) const;
  32. private:
  33. BeatSequenceNoteInformation& getNoteInfo(Channel channel, Pitch pitch);
  34. void refreshRegistry();
  35. void registerMessage(BeatIndex beatIndex, const std::shared_ptr<midi::Message>& msg_ptr);
  36. void unregisterMessage(BeatIndex beatIndex, const std::shared_ptr<midi::Message>& msg_ptr);
  37. };