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 nframes_t last_frame_drawn;
74 Audio_File *audio_file;
85 Fl_Color color ( void ) const { return child(0)->color(); }
86 void color ( Fl_Color c ) { child(0)->color( c ); }
100 enum { AUDIO } _type;
102 Audio_Sequence *_sequence;
104 bool configure_outputs ( int n );
105 bool configure_inputs ( int n );
107 void update_port_names ( void );
108 const char *name_for_port( JACK::Port::type_e type, int n );
109 void update_take_menu ( void );
117 void get ( Log_Entry &e ) const;
118 void get_unjournaled ( Log_Entry &e ) const;
119 void set ( Log_Entry &e );
123 virtual void log_children ( void ) const;
125 Fl_Input *name_field;
126 Fl_Button *record_button;
127 Fl_Button *mute_button;
128 Fl_Button *solo_button;
129 Fl_Menu_Button *take_menu;
138 vector<JACK::Port> input; /* input ports... */
139 vector<JACK::Port> output; /* output ports... */
141 Playback_DS *playback_ds;
142 Record_DS *record_ds;
145 LOG_CREATE_FUNC( Track );
147 void add ( Annotation_Sequence *t );
148 void remove ( Annotation_Sequence *t );
150 void add ( Control_Sequence *t );
151 void add ( Audio_Sequence *t );
152 void remove ( Audio_Sequence *t );
153 void remove ( Control_Sequence *t );
155 void select ( int X, int Y, int W, int H, bool include_control, bool merge_control );
157 int size ( void ) const { return _size; }
159 int ncontrols ( void ) { return control->children(); }
161 void adjust_size ( void );
164 int height ( void ) const
166 static int table[] = { 30, 80, 150, 300 };
168 return table[ _size ];
171 void show_all_takes ( bool b )
177 void name ( const char *name )
182 _name = strdup( name );
185 name_field->value( _name );
190 const char * name ( void ) const { return _name; }
191 bool mute ( void ) const { return mute_button->value(); }
192 void mute ( bool b ) { mute_button->value( b ); }
193 bool solo ( void ) const { return solo_button->value(); }
194 void solo ( bool b );
196 bool armed ( void ) const { return record_button->value(); }
197 void armed ( bool b ) { record_button->value( b ); }
199 bool selected ( void ) const { return _selected; }
202 static void cb_input_field ( Fl_Widget *w, void *v );
203 void cb_input_field ( void );
204 static void cb_button ( Fl_Widget *w, void *v );
205 void cb_button ( Fl_Widget *w );
208 static int width ( void ) { return 150; }
210 void sequence ( Audio_Sequence * t );
211 Audio_Sequence * sequence ( void ) const { return _sequence; }
214 Fl_Menu_Button & menu ( void ) const;
216 static void menu_cb ( Fl_Widget *w, void *v );
217 void menu_cb ( const Fl_Menu_ *m );
220 int handle ( int m );
223 const Audio_Region *capture_region ( void ) const;
224 Capture *capture ( void );
226 void resize_buffers ( nframes_t nframes );
227 nframes_t process_input ( nframes_t nframes );
228 nframes_t process_output ( nframes_t nframes );
229 void seek ( nframes_t frame );
230 void delay ( nframes_t frames );
232 void record ( Capture *c, nframes_t frame );
233 void write ( Capture *c, sample_t *buf, nframes_t nframes );
234 void finalize ( Capture *c, nframes_t frame );