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.

262 lines
7.0KB

  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. #include <FL/Fl.H>
  20. #include "Sequence.H"
  21. #include <FL/Fl_Group.H>
  22. #include <FL/Fl_Input.H>
  23. #include <FL/Fl_Button.H>
  24. #include <FL/Fl_Menu_Button.H>
  25. #include <FL/Fl_Pack.H>
  26. #include <FL/Fl_Box.H>
  27. #include <FL/fl_draw.H>
  28. #include "Loggable.H"
  29. /* TODO: rename this to Audio_Track or something since it's clearly audio specific. */
  30. #include <vector>
  31. using std::vector;
  32. #include "JACK/Port.H"
  33. #include "Timeline.H"
  34. class Control_Sequence;
  35. class Annotation_Sequence;
  36. class Playback_DS;
  37. class Record_DS;
  38. // class JACK::Port;
  39. class Audio_Region;
  40. class Audio_File;
  41. class Fl_Scalepack;
  42. class Fl_Sometimes_Pack;
  43. class Fl_Blink_Button;
  44. //class Audio_Sequence;
  45. #include "Audio_Sequence.H"
  46. class Track : public Fl_Group, public Loggable
  47. {
  48. /* not permitted */
  49. Track ( const Track &rhs );
  50. Track & operator= ( const Track &rhs );
  51. public:
  52. Track ( const char *L, int channels=1 );
  53. virtual ~Track ( );
  54. static bool soloing ( void ) { return _soloing; }
  55. static const char *capture_format;
  56. static bool colored_tracks;
  57. struct Capture
  58. {
  59. Audio_File *audio_file;
  60. Audio_Region *region;
  61. Capture ( )
  62. {
  63. region = 0;
  64. audio_file = 0;
  65. }
  66. };
  67. virtual Fl_Color color ( void ) const { return child(0)->color(); }
  68. virtual void color ( Fl_Color c ) { child(0)->color( c ); }
  69. bool operator< ( const Track &rhs ) const
  70. {
  71. return _row < rhs._row;
  72. }
  73. private:
  74. static int _soloing;
  75. char *_name;
  76. bool _selected;
  77. int _size;
  78. int _row;
  79. enum { AUDIO } _type;
  80. Audio_Sequence *_sequence;
  81. bool configure_outputs ( int n );
  82. bool configure_inputs ( int n );
  83. void command_configure_channels ( int n );
  84. void update_port_names ( void );
  85. const char *name_for_port( JACK::Port::type_e type, int n );
  86. Track ( );
  87. void init ( void );
  88. protected:
  89. void get ( Log_Entry &e ) const;
  90. void get_unjournaled ( Log_Entry &e ) const;
  91. void set ( Log_Entry &e );
  92. Fl_Scalepack *controls;
  93. Fl_Sometimes_Pack *control;
  94. Fl_Blink_Button *connected_indicator;
  95. Fl_Group *controls_heading;
  96. Fl_Group *takes_heading;
  97. public:
  98. virtual void log_children ( void ) const;
  99. Fl_Input *name_field;
  100. Fl_Button *record_button;
  101. Fl_Button *mute_button;
  102. Fl_Button *solo_button;
  103. Fl_Button *show_all_takes_button;
  104. Fl_Button *overlay_controls_button;
  105. Fl_Button *menu_button;
  106. Fl_Pack *pack;
  107. Fl_Pack *annotation;
  108. Fl_Pack *takes;
  109. vector<JACK::Port> input; /* input ports... */
  110. vector<JACK::Port> output; /* output ports... */
  111. Playback_DS *playback_ds;
  112. Record_DS *record_ds;
  113. /* for loggable */
  114. LOG_CREATE_FUNC( Track );
  115. Control_Sequence * control_by_name ( const char *name );
  116. char * get_unique_control_name ( const char *name );
  117. void add ( Annotation_Sequence *t );
  118. void remove ( Annotation_Sequence *t );
  119. void add ( Control_Sequence *t );
  120. void add ( Audio_Sequence *t );
  121. void remove ( Audio_Sequence *t );
  122. void remove ( Control_Sequence *t );
  123. void select ( int X, int Y, int W, int H, bool include_control, bool merge_control );
  124. int size ( void ) const { return _size; }
  125. int ncontrols ( void ) { return ((Fl_Group*)control)->children(); }
  126. void adjust_size ( void );
  127. void size ( int v );
  128. int height ( void ) const
  129. {
  130. static int table[] = { 25, 54, 80, 150, 300 };
  131. return table[ _size ];
  132. }
  133. void show_all_takes ( bool b )
  134. {
  135. show_all_takes_button->value( b );
  136. adjust_size();
  137. }
  138. bool show_all_takes ( void ) const
  139. {
  140. return show_all_takes_button->value();
  141. }
  142. void overlay_controls ( bool b )
  143. {
  144. overlay_controls_button->value( b );
  145. adjust_size();
  146. }
  147. bool overlay_controls ( void ) const
  148. {
  149. return overlay_controls_button->value();
  150. }
  151. void name ( const char *name );
  152. const char * name ( void ) const;
  153. bool mute ( void ) const { return mute_button->value(); }
  154. void mute ( bool b ) { mute_button->value( b ); }
  155. bool solo ( void ) const { return solo_button->value(); }
  156. void solo ( bool b );
  157. bool armed ( void ) const { return record_button->value(); }
  158. void armed ( bool b ) { record_button->value( b ); }
  159. bool selected ( void ) const { return _selected; }
  160. int row ( void ) const;
  161. void row ( int );
  162. static void cb_button ( Fl_Widget *w, void *v );
  163. void cb_button ( Fl_Widget *w );
  164. static int width ( void ) { return 200; }
  165. void sequence ( Audio_Sequence * t );
  166. Audio_Sequence * sequence ( void ) const { return _sequence; }
  167. Fl_Menu_Button & menu ( void ) const;
  168. static void menu_cb ( Fl_Widget *w, void *v );
  169. void menu_cb ( const Fl_Menu_ *m );
  170. void draw ( void );
  171. int handle ( int m );
  172. void process_osc ( void );
  173. void connect_osc ( void );
  174. void update_osc_connection_state ( void );
  175. /* Engine */
  176. const Audio_Region *capture_region ( void ) const;
  177. Capture *capture ( void );
  178. void resize_buffers ( nframes_t nframes );
  179. nframes_t process_input ( nframes_t nframes );
  180. nframes_t process_output ( nframes_t nframes );
  181. void seek ( nframes_t frame );
  182. void delay ( nframes_t frames );
  183. void record ( Capture *c, nframes_t frame );
  184. void write ( Capture *c, sample_t *buf, nframes_t nframes );
  185. void finalize ( Capture *c, nframes_t frame );
  186. };