Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

235 lines
6.8KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2008 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. #pragma once
  19. /* FIXME: this class needs a lot of cleaning up. Too many public
  20. * members etc. */
  21. /* #include "Audio_File.H" // just for nframes_t */
  22. #include "types.h"
  23. #include <math.h>
  24. #include <assert.h>
  25. #include <list>
  26. class Fl_Scroll;
  27. class Fl_Pack;
  28. class Fl_Scrollbar;
  29. class Fl_Widget;
  30. class Fl_Menu_Button;
  31. class Fl_Menu_;
  32. class Timeline;
  33. extern Timeline *timeline;
  34. struct BBT;
  35. class Tempo_Sequence;
  36. class Time_Sequence;
  37. class Annotation_Sequence;
  38. class Track;
  39. class Scalebar;
  40. class Sequence;
  41. class Sequence_Widget;
  42. #ifndef USE_SINGLEBUFFERED_TIMELINE
  43. #include <Fl/Fl_Overlay_Window.H>
  44. #else
  45. #include <FL/Fl_Single_Window.H>
  46. #endif
  47. struct position_info;
  48. struct Rectangle
  49. {
  50. int x;
  51. int y;
  52. int w;
  53. int h;
  54. Rectangle ( ) : x( 0 ), y( 0 ), w( 0 ), h( 0 ) {}
  55. Rectangle ( int X, int Y, int W, int H ) : x( X ), y( Y ), w( W ), h( H ) {}
  56. };
  57. #include "RWLock.H"
  58. #ifdef USE_WIDGET_FOR_TIMELINE
  59. class Timeline : public Fl_Group, public RWLock
  60. #else
  61. #ifndef USE_SINGLEBUFFERED_TIMELINE
  62. class Timeline : public Fl_Overlay_Window, public RWLock
  63. #else
  64. class Timeline : public Fl_Single_Window, public RWLock
  65. #endif
  66. #endif
  67. {
  68. static void draw_clip ( void * v, int X, int Y, int W, int H );
  69. int _old_xposition;
  70. int _old_yposition;
  71. Rectangle _selection;
  72. Fl_Scroll *scroll;
  73. Fl_Pack *tracks;
  74. Fl_Pack *rulers;
  75. Scalebar *hscroll;
  76. Fl_Scrollbar *vscroll;
  77. void adjust_vscroll ( void );
  78. void adjust_hscroll ( void );
  79. static void cb_scroll ( Fl_Widget *w, void *v );
  80. void cb_scroll ( Fl_Widget *w );
  81. static void menu_cb ( Fl_Widget *w, void *v );
  82. void menu_cb ( Fl_Menu_ *m );
  83. void fix_range ( void );
  84. int _fpp; /* frames per pixel, power of two */
  85. nframes_t p1, p2; /* cursors */
  86. /* not permitted */
  87. Timeline ( const Timeline &rhs );
  88. Timeline & operator = ( const Timeline &rhs );
  89. std::list <const Sequence_Widget*> _tempomap;
  90. public:
  91. enum snap_e {
  92. Bars,
  93. Beats,
  94. None
  95. };
  96. static bool draw_with_measure_lines;
  97. static snap_e snap_to;
  98. static bool snapping_on_hold;
  99. static bool snap_magnetic;
  100. static bool follow_playhead;
  101. static bool center_playhead;
  102. Tempo_Sequence *tempo_track;
  103. Time_Sequence *time_track;
  104. Annotation_Sequence *ruler_track;
  105. Fl_Menu_Button *menu;
  106. nframes_t xoffset;
  107. int _yposition;
  108. nframes_t _sample_rate;
  109. Timeline ( int X, int Y, int W, int H, const char *L=0 );
  110. void update_tempomap ( void );
  111. const char *session_manager_name ( void ) { return NULL; }
  112. nframes_t fpp ( void ) const { return 1 << _fpp; }
  113. void range ( nframes_t start, nframes_t length );
  114. nframes_t length ( void ) const;
  115. void sample_rate ( nframes_t r ) { _sample_rate = r; }
  116. nframes_t sample_rate ( void ) const { return _sample_rate; }
  117. int ts_to_x( nframes_t ts ) const { return ts >> _fpp; }
  118. nframes_t x_to_ts ( int x ) const { return x << _fpp; }
  119. nframes_t x_to_offset ( int x ) const;
  120. float beats_per_minute ( nframes_t when ) const;
  121. int beats_per_bar ( nframes_t when ) const;
  122. void beats_per_minute ( nframes_t when, float bpm );
  123. void time ( nframes_t when, int bpb, int beat_type );
  124. bool nearest_line ( nframes_t *f, bool snap=true ) const;
  125. bool next_line ( nframes_t *f, bool bar=false ) const;
  126. bool prev_line ( nframes_t *f, bool bar=false ) const;
  127. typedef void (measure_line_callback)( nframes_t frame, const BBT & bbt, void *arg );
  128. position_info solve_tempomap ( nframes_t when ) const;
  129. void draw_measure_lines ( int X, int Y, int W, int H, Fl_Color color );
  130. void draw_measure_BBT ( int X, int Y, int W, int H, Fl_Color color );
  131. position_info render_tempomap ( nframes_t start, nframes_t length, measure_line_callback *cb, void *arg ) const;
  132. void xposition ( int X );
  133. void yposition ( int Y );
  134. void draw_cursor ( nframes_t frame, Fl_Color color, void (*symbol)(Fl_Color) ) const;
  135. void draw_cursors ( void ) const;
  136. void draw_playhead ( void );
  137. void redraw_playhead ( void );
  138. void resize ( int X, int Y, int W, int H );
  139. void draw ( void );
  140. void draw_overlay ( void );
  141. int handle_scroll ( int m );
  142. int handle ( int m );
  143. static void update_cb ( void *arg );
  144. void select( const Rectangle &r );
  145. Track * track_under ( int Y );
  146. int nselected ( void ) const;
  147. void delete_selected ( void );
  148. void select_none ( void );
  149. void add_track ( Track *track );
  150. void remove_track ( Track *track );
  151. int ntracks ( void ) const;
  152. void zoom ( float secs );
  153. void zoom_in ( void );
  154. void zoom_out ( void );
  155. void zoom_fit ( void );
  156. /* Engine */
  157. int total_input_buffer_percent ( void );
  158. int total_output_buffer_percent ( void );
  159. int total_playback_xruns ( void );
  160. int total_capture_xruns ( void );
  161. nframes_t total_output_latency ( void ) const;
  162. bool record ( void );
  163. void stop ( void );
  164. void wait_for_buffers ( void );
  165. bool seek_pending ( void );
  166. private:
  167. static void snapshot ( void *v ) { ((Timeline*)v)->snapshot(); }
  168. void snapshot ( void );
  169. friend class Engine; // FIXME: only Engine::process() needs to be friended.x
  170. Track * track_by_name ( const char *name );
  171. char * get_unique_track_name ( const char *name );
  172. /* Engine */
  173. void resize_buffers ( nframes_t nframes );
  174. nframes_t process ( nframes_t nframes );
  175. void seek ( nframes_t frame );
  176. };