2 /*******************************************************************************/
3 /* Copyright (C) 2008 Jonathan Moore Liles */
5 /* This program is free software; you can redistribute it and/or modify it */
6 /* under the terms of the GNU General Public License as published by the */
7 /* Free Software Foundation; either version 2 of the License, or (at your */
8 /* option) any later version. */
10 /* This program is distributed in the hope that it will be useful, but WITHOUT */
11 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
12 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
15 /* You should have received a copy of the GNU General Public License along */
16 /* with This program; see the file COPYING. If not,write to the Free Software */
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 /*******************************************************************************/
24 #include <FL/Fl_Group.H>
25 #include <FL/Fl_Input.H>
26 #include <FL/Fl_Button.H>
27 #include <FL/Fl_Menu_Button.H>
28 #include <FL/Fl_Pack.H>
29 #include <FL/Fl_Box.H>
30 #include <FL/fl_draw.H>
34 /* TODO: rename this to Audio_Track or something since it's clearly audio specific. */
39 #include "JACK/Port.H"
43 class Control_Sequence;
44 class Annotation_Sequence;
51 //class Audio_Sequence;
53 #include "Audio_Sequence.H"
55 class Track : public Fl_Group, public Loggable
59 Track ( const Track &rhs );
60 Track & operator= ( const Track &rhs );
64 Track ( const char *L, int channels=1 );
67 static bool soloing ( void ) { return _soloing; }
69 static const char *capture_format;
73 Audio_File *audio_file;
83 Fl_Color color ( void ) const { return child(0)->color(); }
84 void color ( Fl_Color c ) { child(0)->color( c ); }
86 bool operator< ( const Track &rhs ) const
88 return _row < rhs._row;
105 enum { AUDIO } _type;
107 Audio_Sequence *_sequence;
109 bool configure_outputs ( int n );
110 bool configure_inputs ( int n );
112 void update_port_names ( void );
113 const char *name_for_port( JACK::Port::type_e type, int n );
114 void update_take_menu ( void );
122 void get ( Log_Entry &e ) const;
123 void get_unjournaled ( Log_Entry &e ) const;
124 void set ( Log_Entry &e );
128 virtual void log_children ( void ) const;
130 Fl_Input *name_field;
131 Fl_Button *record_button;
132 Fl_Button *mute_button;
133 Fl_Button *solo_button;
134 Fl_Menu_Button *take_menu;
143 vector<JACK::Port> input; /* input ports... */
144 vector<JACK::Port> output; /* output ports... */
146 Playback_DS *playback_ds;
147 Record_DS *record_ds;
150 LOG_CREATE_FUNC( Track );
152 void add ( Annotation_Sequence *t );
153 void remove ( Annotation_Sequence *t );
155 void add ( Control_Sequence *t );
156 void add ( Audio_Sequence *t );
157 void remove ( Audio_Sequence *t );
158 void remove ( Control_Sequence *t );
160 void select ( int X, int Y, int W, int H, bool include_control, bool merge_control );
162 int size ( void ) const { return _size; }
164 int ncontrols ( void ) { return control->children(); }
166 void adjust_size ( void );
169 int height ( void ) const
171 static int table[] = { 30, 80, 150, 300 };
173 return table[ _size ];
176 void show_all_takes ( bool b )
182 void name ( const char *name )
187 _name = strdup( name );
190 name_field->value( _name );
195 const char * name ( void ) const { return _name; }
196 bool mute ( void ) const { return mute_button->value(); }
197 void mute ( bool b ) { mute_button->value( b ); }
198 bool solo ( void ) const { return solo_button->value(); }
199 void solo ( bool b );
201 bool armed ( void ) const { return record_button->value(); }
202 void armed ( bool b ) { record_button->value( b ); }
204 bool selected ( void ) const { return _selected; }
206 int row ( void ) const;
209 static void cb_input_field ( Fl_Widget *w, void *v );
210 void cb_input_field ( void );
211 static void cb_button ( Fl_Widget *w, void *v );
212 void cb_button ( Fl_Widget *w );
215 static int width ( void ) { return 150; }
217 void sequence ( Audio_Sequence * t );
218 Audio_Sequence * sequence ( void ) const { return _sequence; }
221 Fl_Menu_Button & menu ( void ) const;
223 static void menu_cb ( Fl_Widget *w, void *v );
224 void menu_cb ( const Fl_Menu_ *m );
227 int handle ( int m );
230 const Audio_Region *capture_region ( void ) const;
231 Capture *capture ( void );
233 void resize_buffers ( nframes_t nframes );
234 nframes_t process_input ( nframes_t nframes );
235 nframes_t process_output ( nframes_t nframes );
236 void seek ( nframes_t frame );
237 void delay ( nframes_t frames );
239 void record ( Capture *c, nframes_t frame );
240 void write ( Capture *c, sample_t *buf, nframes_t nframes );
241 void finalize ( Capture *c, nframes_t frame );