Beast - Music Synthesizer and Composer  0.11.1+10.g2da35
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  static void reap_thread ();
23  void sequencer_thread ();
24  bool pool_poll_Lm (int timeout_ms);
25  void process_part_SL (BseSong *song, BsePart *part, double start_stamp, uint start_tick,
26  uint tick_bound, /* start_tick + n_ticks */
27  double stamps_per_tick, BseMidiReceiver *midi_receiver, uint midi_channel);
28  void process_track_SL (BseSong *song, BseTrack *track, double start_stamp, uint start_tick,
29  uint bound, /* start_tick + n_ticks */
30  double stamps_per_tick, BseMidiReceiver *midi_receiver);
31  void process_song_SL (BseSong *song, uint n_ticks);
32  bool process_song_unlooped_SL (BseSong *song, uint n_ticks, bool force_active_tracks);
33  explicit Sequencer ();
34 protected:
35  static void _init_threaded ();
36 public:
37  void add_io_watch (uint n_pfds, const GPollFD *pfds, BseIOWatch watch_func, void *watch_data);
38  void remove_io_watch (BseIOWatch watch_func, void *watch_data);
39  void start_song (BseSong *song, uint64 start_stamp);
40  void remove_song (BseSong *song);
41  bool thread_lagging (uint n_blocks);
42  void wakeup () { event_fd_.wakeup(); }
43  static Mutex& sequencer_mutex () { return sequencer_mutex_; }
44  static Sequencer& instance () { return *singleton_; }
45 };
46 
47 #define BSE_SEQUENCER_LOCK() (Bse::Sequencer::sequencer_mutex().lock())
48 #define BSE_SEQUENCER_UNLOCK() (Bse::Sequencer::sequencer_mutex().unlock())
49 
50 } // Bse
51 
52 #endif // __BSE_SSEQUENCER_HH__
Definition: bsetrack.hh:22
The Bse namespace contains all functions of the synthesis engine.
Definition: bstbseutils.cc:91
Note and MIDI sequencer.
Definition: bsesequencer.hh:11
Definition: sfiring.hh:21
Definition: bsesong.hh:23
uint64_t uint64
Definition: bsepart.hh:24
STL class.