]> git.tdb.fi Git - libs/demoscene.git/blob - source/sequencer.h
Move the Action class out of Sequencer
[libs/demoscene.git] / source / sequencer.h
1 #ifndef MSP_DEMOSCENE_SEQUENCER_H_
2 #define MSP_DEMOSCENE_SEQUENCER_H_
3
4 #include <vector>
5 #include <sigc++/signal.h>
6 #include <msp/time/timedelta.h>
7 #include <msp/time/timestamp.h>
8
9 class Action;
10
11 class Sequencer
12 {
13 private:
14         struct Segment
15         {
16                 Action *action;
17                 float start_beat;
18                 float end_beat;
19         };
20
21 public:
22         sigc::signal<void> signal_finished;
23
24 private:
25         Msp::Time::TimeDelta secs_per_beat;
26         std::vector<Action *> static_actions;
27         std::vector<Segment> segments;
28         std::vector<Segment>::const_iterator begin;
29         std::vector<Segment>::const_iterator end;
30         bool started;
31         float beat;
32         float next_event;
33
34 public:
35         Sequencer(float = 120.0f);
36
37         void set_beats_per_minute(float);
38         float get_beats_per_minute() const { return Msp::Time::min/secs_per_beat; }
39         void add_static_action(Action &);
40         void add_action(Action &, float, float);
41
42         void start();
43         void seek(float);
44         void tick(const Msp::Time::TimeDelta &);
45 private:
46         void advance_to(float);
47         void update_next_event();
48 public:
49         float get_current_beat() const { return beat; }
50 };
51
52 #endif