BEAST/BSE - Better Audio System and Sound Engine  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bsesequencer.hh
Go to the documentation of this file.
1  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
2 #ifndef __BSE_SSEQUENCER_HH__
3 #define __BSE_SSEQUENCER_HH__
4 #include <bse/bsesong.hh>
5 
6 namespace Bse {
7 
11 class Sequencer {
12  static Sequencer *singleton_;
13  static Mutex sequencer_mutex_;
14  struct PollPool;
15  uint64 stamp_; // sequencer time (ahead of real time)
16  SfiRing *songs_;
17  Cond watch_cond_;
18  PollPool *poll_pool_;
19  EventFd event_fd_;
20  std::thread thread_;
21 private:
22  void sequencer_thread ();
23  bool pool_poll_Lm (int timeout_ms);
24  void process_part_SL (BsePart *part, double start_stamp, uint start_tick,
25  uint tick_bound, /* start_tick + n_ticks */
26  double stamps_per_tick, BseMidiReceiver *midi_receiver, uint midi_channel);
27  void process_track_SL (BseTrack *track, double start_stamp, uint start_tick,
28  uint bound, /* start_tick + n_ticks */
29  double stamps_per_tick, BseMidiReceiver *midi_receiver);
30  void process_song_SL (BseSong *song, uint n_ticks);
31  bool process_song_unlooped_SL (BseSong *song, uint n_ticks, bool force_active_tracks);
32  explicit Sequencer ();
33 protected:
34  static void _init_threaded ();
35 public:
36  void add_io_watch (uint n_pfds, const GPollFD *pfds, BseIOWatch watch_func, void *watch_data);
37  void remove_io_watch (BseIOWatch watch_func, void *watch_data);
38  void start_song (BseSong *song, uint64 start_stamp);
39  void remove_song (BseSong *song);
40  bool thread_lagging (uint n_blocks);
41  void wakeup () { event_fd_.wakeup(); }
42  static Mutex& sequencer_mutex () { return sequencer_mutex_; }
43  static Sequencer& instance () { return *singleton_; }
44 };
45 
46 #define BSE_SEQUENCER_LOCK() (Bse::Sequencer::sequencer_mutex().lock())
47 #define BSE_SEQUENCER_UNLOCK() (Bse::Sequencer::sequencer_mutex().unlock())
48 
49 } // Bse
50 
51 #endif // __BSE_SSEQUENCER_HH__
Definition: bsetrack.hh:24
Note and MIDI sequencer.
Definition: bsesequencer.hh:11
Definition: sfiring.hh:23
Definition: bsesong.hh:25
uint64_t uint64
Definition: bsepart.hh:26