BeatSequence.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #include <vector>
  3. #include <ostream>
  4. #include <stdexcept>
  5. #include "MessageList.h"
  6. namespace midi {
  7. class BeatSequence : public std::vector<MessageList>
  8. {
  9. typedef std::vector<MessageList> parent;
  10. public:
  11. typedef unsigned int BeatIndex;
  12. typedef void (*ReducationConflictCallback)(BeatSequence& sequence, BeatIndex factor, BeatIndex beatIndex, void* data);
  13. BeatSequence();
  14. BeatSequence(BeatIndex size);
  15. void expand(BeatIndex factor);
  16. void reduce(BeatIndex factor);
  17. void reduce(BeatIndex factor, ReducationConflictCallback conflictCallback, void* conflictCallbackData);
  18. void reduceToNeighbour(BeatIndex factor);
  19. void print(std::ostream& stream) const;
  20. private:
  21. static void moveReducationConflictToNextNeighbour(BeatSequence& sequence, BeatIndex factor, BeatIndex beatIndex, void* data);
  22. };
  23. class UnresolvedBeatSequenceReducationConflict : public std::runtime_error
  24. {
  25. typedef std::runtime_error parent;
  26. BeatSequence::BeatIndex beatIndex;
  27. public:
  28. UnresolvedBeatSequenceReducationConflict(BeatSequence::BeatIndex beatIndex);
  29. virtual const char* what() const throw();
  30. BeatSequence::BeatIndex getBeatIndex() const;
  31. };
  32. } // namespace