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.

240 lines
6.6KB

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