BeatSequencePlayer.h 910 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. Output* output;
  19. public:
  20. const BeatSequence* sequence;
  21. BeatSequencePlayer();
  22. BeatSequencePlayer(Output* output);
  23. BeatSequencePlayer(Output* output, const BeatSequence* sequence);
  24. Bpm getBpm();
  25. void setBpm(Bpm bpm);
  26. bool getLooping();
  27. void setLooping(bool looping);
  28. BeatIndex getNextBeat();
  29. void setNextBeat(BeatIndex nextBeat);
  30. void play();
  31. void loop();
  32. void start();
  33. void stop();
  34. bool isPlaying();
  35. private:
  36. static void beat(void* data);
  37. };
  38. } // namespace