BeatSequence.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 (*ReductionConflictCallback)(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, ReductionConflictCallback conflictCallback, void* conflictCallbackData);
  18. void reduceToNeighbour(BeatIndex factor);
  19. void reduceErasingConflicts(BeatIndex factor);
  20. void print(std::ostream& stream) const;
  21. private:
  22. static void eraseReductionConflict(BeatSequence& sequence, BeatIndex factor, BeatIndex beatIndex, void* data);
  23. static void moveReductionConflictToNextNeighbour(BeatSequence& sequence, BeatIndex factor, BeatIndex beatIndex, void* data);
  24. };
  25. class UnresolvedBeatSequenceReductionConflict : public std::runtime_error
  26. {
  27. typedef std::runtime_error parent;
  28. BeatSequence::BeatIndex beatIndex;
  29. public:
  30. UnresolvedBeatSequenceReductionConflict(BeatSequence::BeatIndex beatIndex);
  31. virtual const char* what() const throw();
  32. BeatSequence::BeatIndex getBeatIndex() const;
  33. };
  34. } // namespace