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.

245 lines
6.7KB

  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 "Port.H"
  33. #include "Timeline.H"
  34. #include "Control_Sequence.H"
  35. class Playback_DS;
  36. class Record_DS;
  37. class Port;
  38. class Region;
  39. class Track : public Fl_Group, public Loggable
  40. {
  41. public:
  42. Track ( const char *L, int channels=1 );
  43. ~Track ( );
  44. static bool soloing ( void ) { return _soloing; }
  45. static const char *capture_format;
  46. private:
  47. static int _soloing;
  48. char *_name;
  49. bool _selected;
  50. bool _show_all_takes;
  51. int _size;
  52. enum { AUDIO } _type;
  53. Sequence *_track;
  54. Region *_capture; /* capture region */
  55. bool configure_outputs ( int n );
  56. bool configure_inputs ( int n );
  57. void update_port_names ( void );
  58. const char *name_for_port( Port::type_e type, int n );
  59. Track ( ) : Fl_Group( 0, 0, 1, 1 )
  60. {
  61. init();
  62. timeline->add_track( this );
  63. }
  64. void init ( void );
  65. public:
  66. Fl_Input *name_field;
  67. Fl_Button *record_button;
  68. Fl_Button *mute_button;
  69. Fl_Button *solo_button;
  70. Fl_Menu_Button *take_menu;
  71. Fl_Group *controls;
  72. Fl_Pack *pack;
  73. Fl_Pack *control;
  74. Fl_Pack *takes;
  75. vector<Port> input; /* input ports... */
  76. vector<Port> output; /* output ports... */
  77. Playback_DS *playback_ds;
  78. Record_DS *record_ds;
  79. // const char *class_name ( void ) { return "Track"; }
  80. void
  81. set ( Log_Entry &e )
  82. {
  83. for ( int i = 0; i < e.size(); ++i )
  84. {
  85. const char *s, *v;
  86. e.get( i, &s, &v );
  87. if ( ! strcmp( s, ":h" ) )
  88. {
  89. size( atoi( v ) );
  90. // Fl_Widget::size( w(), height() );
  91. resize();
  92. }
  93. else if ( ! strcmp( s, ":s" ) )
  94. _selected = atoi( v );
  95. // else if ( ! strcmp( s, ":armed"
  96. else if ( ! strcmp( s, ":n" ) )
  97. name( v );
  98. else if ( ! strcmp( s, ":i" ) )
  99. configure_inputs( atoi( v ) );
  100. else if ( ! strcmp( s, ":o" ) )
  101. configure_outputs( atoi( v ) );
  102. else if ( ! strcmp( s, ":t" ) )
  103. {
  104. int i;
  105. sscanf( v, "%X", &i );
  106. if ( i )
  107. {
  108. Sequence *t = (Sequence*)Loggable::find( i );
  109. /* FIXME: our track might not have been
  110. * defined yet... what should we do about this
  111. * chicken/egg problem? */
  112. if ( t )
  113. {
  114. // assert( t );
  115. track( t );
  116. }
  117. }
  118. }
  119. }
  120. }
  121. virtual void get ( Log_Entry &e ) const
  122. {
  123. e.add( ":n", _name );
  124. e.add( ":t", track() );
  125. e.add( ":s", _selected );
  126. e.add( ":h", size() );
  127. e.add( ":i", input.size() );
  128. e.add( ":o", output.size() );
  129. }
  130. /* for loggable */
  131. LOG_CREATE_FUNC( Track );
  132. void add ( Control_Sequence *t );
  133. void add ( Sequence *t );
  134. void remove ( Sequence *t );
  135. void remove ( Control_Sequence *t );
  136. int size ( void ) const { return _size; }
  137. void resize ( void );
  138. void size ( int v );
  139. int height ( void ) const
  140. {
  141. static int table[] = { 30, 80, 150, 300 };
  142. return table[ _size ];
  143. }
  144. void show_all_takes ( bool b )
  145. {
  146. _show_all_takes = b;
  147. resize();
  148. }
  149. void name ( const char *name )
  150. {
  151. if ( _name )
  152. free( _name );
  153. _name = strdup( name );
  154. if ( name_field )
  155. name_field->value( _name );
  156. update_port_names();
  157. }
  158. const char * name ( void ) const { return _name; }
  159. bool mute ( void ) const { return mute_button->value(); }
  160. bool solo ( void ) const { return solo_button->value(); }
  161. bool armed ( void ) const { return record_button->value(); }
  162. bool selected ( void ) const { return _selected; }
  163. static void cb_input_field ( Fl_Widget *w, void *v );
  164. void cb_input_field ( void );
  165. static void cb_button ( Fl_Widget *w, void *v );
  166. void cb_button ( Fl_Widget *w );
  167. static int width ( void ) { return 150; }
  168. void track( Sequence * t );
  169. Sequence * track ( void ) const { return _track; }
  170. void draw ( void );
  171. int handle ( int m );
  172. const Region *capture ( void ) const { return _capture; }
  173. /* Engine */
  174. nframes_t process ( nframes_t nframes );
  175. void seek ( nframes_t frame );
  176. void record ( nframes_t nframes );
  177. void write ( sample_t *buf, nframes_t nframes );
  178. void stop ( nframes_t nframes );
  179. };