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.

233 lines
6.3KB

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