#pragma once #include #include #include #include "MessageList.h" namespace midi { class BeatSequence : public std::vector { typedef std::vector parent; public: typedef unsigned int BeatIndex; typedef void (*ReductionConflictCallback)(BeatSequence& sequence, BeatIndex factor, BeatIndex beatIndex, void* data); BeatSequence(); BeatSequence(BeatIndex size); void expand(BeatIndex factor); void reduce(BeatIndex factor); void reduce(BeatIndex factor, ReductionConflictCallback conflictCallback, void* conflictCallbackData); void reduceToNeighbour(BeatIndex factor); void reduceErasingConflicts(BeatIndex factor); void print(std::ostream& stream) const; private: static void eraseReductionConflict(BeatSequence& sequence, BeatIndex factor, BeatIndex beatIndex, void* data); static void moveReductionConflictToNextNeighbour(BeatSequence& sequence, BeatIndex factor, BeatIndex beatIndex, void* data); }; class UnresolvedBeatSequenceReductionConflict : public std::runtime_error { typedef std::runtime_error parent; BeatSequence::BeatIndex beatIndex; public: UnresolvedBeatSequenceReductionConflict(BeatSequence::BeatIndex beatIndex); virtual const char* what() const throw(); BeatSequence::BeatIndex getBeatIndex() const; }; } // namespace