Non reinvents the DAW. Powerful enough to form a complete studio, fast and light enough to run on low-end hardware like the eeePC or Raspberry Pi, and so reliable that it can be used live https://non.tuxfamily.org/
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.

228 lines
6.1KB

  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 Audio_Sequence;
  42. #include "Audio_Sequence.H"
  43. class Track : public Fl_Group, public Loggable
  44. {
  45. /* not permitted */
  46. Track ( const Track &rhs );
  47. Track & operator= ( const Track &rhs );
  48. public:
  49. Track ( const char *L, int channels=1 );
  50. virtual ~Track ( );
  51. static bool soloing ( void ) { return _soloing; }
  52. static const char *capture_format;
  53. struct Capture
  54. {
  55. Audio_File *audio_file;
  56. Audio_Region *region;
  57. };
  58. Fl_Color color ( void ) const { return child(0)->color(); }
  59. void color ( Fl_Color c ) { child(0)->color( c ); }
  60. private:
  61. static int _soloing;
  62. char *_name;
  63. bool _selected;
  64. bool _show_all_takes;
  65. int _size;
  66. enum { AUDIO } _type;
  67. Audio_Sequence *_sequence;
  68. bool configure_outputs ( int n );
  69. bool configure_inputs ( int n );
  70. void update_port_names ( void );
  71. const char *name_for_port( JACK::Port::type_e type, int n );
  72. void update_take_menu ( void );
  73. Track ( );
  74. void init ( void );
  75. protected:
  76. void get ( Log_Entry &e ) const;
  77. void get_unjournaled ( Log_Entry &e ) const;
  78. void set ( Log_Entry &e );
  79. public:
  80. virtual void log_children ( void ) const;
  81. Fl_Input *name_field;
  82. Fl_Button *record_button;
  83. Fl_Button *mute_button;
  84. Fl_Button *solo_button;
  85. Fl_Menu_Button *take_menu;
  86. Fl_Group *controls;
  87. Fl_Pack *pack;
  88. Fl_Pack *annotation;
  89. Fl_Pack *control;
  90. Fl_Pack *takes;
  91. vector<JACK::Port> input; /* input ports... */
  92. vector<JACK::Port> output; /* output ports... */
  93. Playback_DS *playback_ds;
  94. Record_DS *record_ds;
  95. /* for loggable */
  96. LOG_CREATE_FUNC( Track );
  97. void add ( Annotation_Sequence *t );
  98. void remove ( Annotation_Sequence *t );
  99. void add ( Control_Sequence *t );
  100. void add ( Audio_Sequence *t );
  101. void remove ( Audio_Sequence *t );
  102. void remove ( Control_Sequence *t );
  103. void select ( int X, int Y, int W, int H, bool include_control, bool merge_control );
  104. int size ( void ) const { return _size; }
  105. int ncontrols ( void ) { return control->children(); }
  106. void adjust_size ( void );
  107. void size ( int v );
  108. int height ( void ) const
  109. {
  110. static int table[] = { 30, 80, 150, 300 };
  111. return table[ _size ];
  112. }
  113. void show_all_takes ( bool b )
  114. {
  115. _show_all_takes = b;
  116. adjust_size();
  117. }
  118. void name ( const char *name )
  119. {
  120. if ( _name )
  121. free( _name );
  122. _name = strdup( name );
  123. if ( name_field )
  124. name_field->value( _name );
  125. update_port_names();
  126. }
  127. const char * name ( void ) const { return _name; }
  128. bool mute ( void ) const { return mute_button->value(); }
  129. void mute ( bool b ) { mute_button->value( b ); }
  130. bool solo ( void ) const { return solo_button->value(); }
  131. void solo ( bool b );
  132. bool armed ( void ) const { return record_button->value(); }
  133. void armed ( bool b ) { record_button->value( b ); }
  134. bool selected ( void ) const { return _selected; }
  135. static void cb_input_field ( Fl_Widget *w, void *v );
  136. void cb_input_field ( void );
  137. static void cb_button ( Fl_Widget *w, void *v );
  138. void cb_button ( Fl_Widget *w );
  139. static int width ( void ) { return 150; }
  140. void sequence ( Audio_Sequence * t );
  141. Audio_Sequence * sequence ( void ) const { return _sequence; }
  142. Fl_Menu_Button & menu ( void ) const;
  143. static void menu_cb ( Fl_Widget *w, void *v );
  144. void menu_cb ( const Fl_Menu_ *m );
  145. void draw ( void );
  146. int handle ( int m );
  147. /* Engine */
  148. const Audio_Region *capture_region ( void ) const;
  149. void resize_buffers ( nframes_t nframes );
  150. nframes_t process_input ( nframes_t nframes );
  151. nframes_t process_output ( nframes_t nframes );
  152. void seek ( nframes_t frame );
  153. void delay ( nframes_t frames );
  154. void record ( Capture *c, nframes_t frame );
  155. void write ( Capture *c, sample_t *buf, nframes_t nframes );
  156. void finalize ( Capture *c, nframes_t frame );
  157. };