BeatSequencePlayer.h 834 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #include <mutex>
  3. #include "Output.h"
  4. #include "BeatSequence.h"
  5. #include "CallbackClock.h"
  6. namespace midi {
  7. class BeatSequencePlayer
  8. {
  9. public:
  10. typedef BeatSequence::BeatIndex BeatIndex;
  11. typedef CallbackClock::bpm_type Bpm;
  12. private:
  13. bool looping;
  14. std::mutex looping_mutex;
  15. BeatIndex nextBeat;
  16. std::mutex nextBeat_mutex;
  17. CallbackClock clock;
  18. public:
  19. const BeatSequence* sequence;
  20. BeatSequencePlayer();
  21. BeatSequencePlayer(const BeatSequence* sequence);
  22. Bpm getBpm();
  23. void setBpm(Bpm bpm);
  24. bool getLooping();
  25. void setLooping(bool looping);
  26. BeatIndex getNextBeat();
  27. void setNextBeat(BeatIndex nextBeat);
  28. void play();
  29. void loop();
  30. void start();
  31. void stop();
  32. bool isPlaying();
  33. private:
  34. static void beat(void* data);
  35. };
  36. } // namespace