2008-03-01 01:06:05 +01:00
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
/* Copyright (C) 2008 Jonathan Moore Liles */
|
|
|
|
/* */
|
|
|
|
/* This program is free software; you can redistribute it and/or modify it */
|
|
|
|
/* under the terms of the GNU General Public License as published by the */
|
|
|
|
/* Free Software Foundation; either version 2 of the License, or (at your */
|
|
|
|
/* option) any later version. */
|
|
|
|
/* */
|
|
|
|
/* This program is distributed in the hope that it will be useful, but WITHOUT */
|
|
|
|
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
|
|
|
|
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
|
|
|
|
/* more details. */
|
|
|
|
/* */
|
|
|
|
/* You should have received a copy of the GNU General Public License along */
|
|
|
|
/* with This program; see the file COPYING. If not,write to the Free Software */
|
|
|
|
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
|
|
|
#include "Track_Header.H"
|
|
|
|
|
2008-04-16 17:35:25 +02:00
|
|
|
#include "Transport.H"
|
2008-04-16 10:44:31 +02:00
|
|
|
#include "Playback_DS.H"
|
|
|
|
#include "Record_DS.H"
|
|
|
|
|
2008-04-09 02:05:15 +02:00
|
|
|
#include "Engine.H"
|
|
|
|
|
2008-04-16 10:44:31 +02:00
|
|
|
#include "Port.H"
|
|
|
|
|
2008-03-01 02:30:20 +01:00
|
|
|
void
|
|
|
|
Track_Header::cb_input_field ( Fl_Widget *w, void *v )
|
|
|
|
{
|
|
|
|
((Track_Header*)v)->cb_input_field();
|
|
|
|
}
|
|
|
|
|
2008-03-05 07:23:00 +01:00
|
|
|
void
|
|
|
|
Track_Header::cb_button ( Fl_Widget *w, void *v )
|
|
|
|
{
|
|
|
|
((Track_Header*)v)->cb_button( w );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-01 02:30:20 +01:00
|
|
|
void
|
|
|
|
Track_Header::cb_input_field ( void )
|
|
|
|
{
|
|
|
|
log_start();
|
|
|
|
|
|
|
|
if ( _name )
|
|
|
|
free( _name );
|
|
|
|
|
|
|
|
_name = strdup( name_field->value() );
|
|
|
|
|
|
|
|
log_end();
|
|
|
|
}
|
|
|
|
|
2008-03-05 07:23:00 +01:00
|
|
|
void
|
|
|
|
Track_Header::cb_button ( Fl_Widget *w )
|
|
|
|
{
|
|
|
|
|
|
|
|
printf( "FIXME: inform mixer here\n" );
|
|
|
|
if ( w == record_button )
|
|
|
|
{
|
2008-04-16 17:35:25 +02:00
|
|
|
/* FIXME: wrong place for this! */
|
|
|
|
if ( record_button->value() )
|
|
|
|
record_ds->start( transport.frame );
|
|
|
|
else
|
|
|
|
record_ds->stop( transport.frame );
|
2008-03-05 07:23:00 +01:00
|
|
|
}
|
2008-03-08 05:31:38 +01:00
|
|
|
else
|
2008-03-08 22:48:06 +01:00
|
|
|
if ( w == take_menu )
|
2008-03-08 20:04:26 +01:00
|
|
|
{
|
2008-03-08 22:48:06 +01:00
|
|
|
int v = take_menu->value();
|
2008-03-08 20:04:26 +01:00
|
|
|
|
2008-03-09 18:56:17 +01:00
|
|
|
switch ( v )
|
2008-03-08 22:48:06 +01:00
|
|
|
{
|
2008-03-09 18:56:17 +01:00
|
|
|
case 0: /* show all takes */
|
|
|
|
show_all_takes( take_menu->menu()[ v ].value() );
|
|
|
|
return;
|
|
|
|
case 1: /* new */
|
|
|
|
track( track()->clone_empty() );
|
|
|
|
return;
|
2008-03-08 22:48:06 +01:00
|
|
|
}
|
2008-03-08 05:31:38 +01:00
|
|
|
|
2008-03-08 22:48:06 +01:00
|
|
|
const char *s = take_menu->menu()[ v ].text;
|
|
|
|
|
|
|
|
for ( int i = takes->children(); i--; )
|
2008-03-08 05:31:38 +01:00
|
|
|
{
|
2008-03-08 22:48:06 +01:00
|
|
|
Track *t = (Track*)takes->child( i );
|
|
|
|
if ( ! strcmp( s, t->name() ) )
|
|
|
|
{
|
|
|
|
track( t );
|
|
|
|
redraw();
|
|
|
|
break;
|
|
|
|
}
|
2008-03-08 05:31:38 +01:00
|
|
|
}
|
|
|
|
}
|
2008-03-05 07:23:00 +01:00
|
|
|
}
|
|
|
|
|
2008-03-01 01:06:05 +01:00
|
|
|
Track_Header::Track_Header ( int X, int Y, int W, int H, const char *L ) :
|
|
|
|
Fl_Group ( X, Y, W, H, L )
|
|
|
|
{
|
2008-03-01 15:23:59 +01:00
|
|
|
|
2008-03-08 22:48:06 +01:00
|
|
|
_track = NULL;
|
2008-03-01 15:23:59 +01:00
|
|
|
_name = NULL;
|
|
|
|
_selected = false;
|
2008-03-08 05:31:38 +01:00
|
|
|
_show_all_takes = false;
|
2008-03-01 16:25:27 +01:00
|
|
|
_size = 1;
|
2008-03-01 15:23:59 +01:00
|
|
|
|
2008-04-12 21:13:30 +02:00
|
|
|
{
|
|
|
|
char pname[40];
|
2008-04-16 10:44:31 +02:00
|
|
|
static int no = 0, ni = 0;
|
|
|
|
|
|
|
|
snprintf( pname, sizeof( pname ), "out-%d", no++ );
|
|
|
|
|
|
|
|
output.push_back( Port( strdup( pname ), Port::Output ) );
|
|
|
|
|
|
|
|
snprintf( pname, sizeof( pname ), "in-%d", ni++ );
|
|
|
|
|
|
|
|
input.push_back( Port( strdup( pname ), Port::Input ) );
|
2008-04-12 21:13:30 +02:00
|
|
|
|
2008-04-16 17:35:25 +02:00
|
|
|
snprintf( pname, sizeof( pname ), "in-%d", ni++ );
|
|
|
|
|
|
|
|
input.push_back( Port( strdup( pname ), Port::Input ) );
|
|
|
|
|
2008-04-12 21:13:30 +02:00
|
|
|
}
|
2008-04-09 02:05:15 +02:00
|
|
|
|
2008-04-16 10:44:31 +02:00
|
|
|
playback_ds = new Playback_DS( this, engine->frame_rate(), engine->nframes(), 1 );
|
2008-04-16 17:35:25 +02:00
|
|
|
record_ds = new Record_DS( this, engine->frame_rate(), engine->nframes(), 2 );
|
2008-04-08 22:06:38 +02:00
|
|
|
|
2008-03-01 15:23:59 +01:00
|
|
|
Fl_Group::size( w(), height() );
|
|
|
|
|
2008-03-01 01:06:05 +01:00
|
|
|
Track_Header *o = this;
|
|
|
|
o->box( FL_THIN_UP_BOX );
|
|
|
|
{
|
2008-03-01 15:23:59 +01:00
|
|
|
Fl_Group *o = new Fl_Group( 2, 2, 149, 70 );
|
2008-03-01 01:06:05 +01:00
|
|
|
o->color( ( Fl_Color ) 53 );
|
|
|
|
{
|
2008-03-01 15:23:59 +01:00
|
|
|
Fl_Input *o = name_field = new Fl_Input( 2, 2, 144, 24 );
|
|
|
|
o->color( ( Fl_Color ) 33 );
|
|
|
|
o->labeltype( FL_NO_LABEL );
|
|
|
|
o->labelcolor( FL_GRAY0 );
|
|
|
|
o->textcolor( 32 );
|
|
|
|
|
|
|
|
o->callback( cb_input_field, (void*)this );
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
Fl_Group *o = controls = new Fl_Group( 2, 28, 149, 24 );
|
2008-03-01 02:30:20 +01:00
|
|
|
|
2008-03-01 01:06:05 +01:00
|
|
|
{
|
|
|
|
Fl_Button *o = record_button =
|
2008-03-01 15:23:59 +01:00
|
|
|
new Fl_Button( 6, 28, 26, 24, "@circle" );
|
2008-03-01 01:06:05 +01:00
|
|
|
o->type( 1 );
|
2008-03-01 05:38:24 +01:00
|
|
|
o->box( FL_THIN_UP_BOX );
|
2008-03-01 01:06:05 +01:00
|
|
|
o->color( FL_LIGHT1 );
|
2008-03-01 05:38:24 +01:00
|
|
|
o->selection_color( FL_RED );
|
2008-03-01 01:06:05 +01:00
|
|
|
o->labelsize( 8 );
|
2008-03-05 07:23:00 +01:00
|
|
|
o->callback( cb_button, this );
|
2008-03-01 01:06:05 +01:00
|
|
|
}
|
|
|
|
{
|
|
|
|
Fl_Button *o = mute_button =
|
2008-03-01 15:23:59 +01:00
|
|
|
new Fl_Button( 35, 28, 26, 24, "m" );
|
2008-03-01 01:06:05 +01:00
|
|
|
o->type( 1 );
|
2008-03-01 05:38:24 +01:00
|
|
|
o->box( FL_THIN_UP_BOX );
|
2008-03-01 01:06:05 +01:00
|
|
|
o->color( FL_LIGHT1 );
|
|
|
|
o->labelsize( 11 );
|
2008-03-05 07:23:00 +01:00
|
|
|
o->callback( cb_button, this );
|
2008-03-01 01:06:05 +01:00
|
|
|
}
|
|
|
|
{
|
|
|
|
Fl_Button *o = solo_button =
|
2008-03-01 15:23:59 +01:00
|
|
|
new Fl_Button( 66, 28, 26, 24, "s" );
|
2008-03-01 01:06:05 +01:00
|
|
|
o->type( 1 );
|
2008-03-01 05:38:24 +01:00
|
|
|
o->box( FL_THIN_UP_BOX );
|
2008-03-01 01:06:05 +01:00
|
|
|
o->color( FL_LIGHT1 );
|
|
|
|
o->labelsize( 11 );
|
2008-03-05 07:23:00 +01:00
|
|
|
o->callback( cb_button, this );
|
2008-03-01 01:06:05 +01:00
|
|
|
}
|
|
|
|
{
|
|
|
|
Fl_Menu_Button *o = take_menu =
|
2008-03-01 15:23:59 +01:00
|
|
|
new Fl_Menu_Button( 97, 28, 47, 24, "T" );
|
2008-03-01 05:38:24 +01:00
|
|
|
o->box( FL_THIN_UP_BOX );
|
2008-03-01 01:06:05 +01:00
|
|
|
o->color( FL_LIGHT1 );
|
|
|
|
o->align( FL_ALIGN_LEFT | FL_ALIGN_INSIDE );
|
2008-03-08 05:31:38 +01:00
|
|
|
o->callback( cb_button, this );
|
2008-03-09 18:56:17 +01:00
|
|
|
|
2008-03-08 20:04:26 +01:00
|
|
|
o->add( "Show all takes", 0, 0, 0, FL_MENU_TOGGLE );
|
2008-03-09 18:56:17 +01:00
|
|
|
o->add( "New", 0, 0, 0, FL_MENU_DIVIDER );
|
|
|
|
|
2008-03-01 01:06:05 +01:00
|
|
|
}
|
|
|
|
o->end();
|
|
|
|
}
|
2008-03-01 15:23:59 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
Fl_Box *o = new Fl_Box( 0, 76, 149, 38 );
|
|
|
|
o->box( FL_FLAT_BOX );
|
|
|
|
Fl_Group::current()->resizable( o );
|
|
|
|
}
|
|
|
|
|
|
|
|
o->size( Track_Header::width(), h() );
|
2008-03-01 01:06:05 +01:00
|
|
|
o->end();
|
|
|
|
}
|
|
|
|
{
|
2008-03-08 22:48:06 +01:00
|
|
|
Fl_Pack *o = pack = new Fl_Pack( width(), 0, 1006, 115 );
|
2008-03-01 01:06:05 +01:00
|
|
|
o->labeltype( FL_NO_LABEL );
|
|
|
|
o->resize( x() + width(), y(), w() - width(), h() );
|
|
|
|
Fl_Group::current()->resizable( o );
|
2008-03-08 22:48:06 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
Fl_Pack *o = control = new Fl_Pack( width(), 0, pack->w(), 115 );
|
|
|
|
o->end();
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
Fl_Pack *o = takes = new Fl_Pack( width(), 0, pack->w(), 115 );
|
|
|
|
o->end();
|
|
|
|
o->hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
o->end();
|
2008-03-01 01:06:05 +01:00
|
|
|
}
|
|
|
|
end();
|
2008-03-01 02:30:20 +01:00
|
|
|
|
|
|
|
log_create();
|
|
|
|
}
|
|
|
|
|
|
|
|
Track_Header::~Track_Header ( )
|
|
|
|
{
|
|
|
|
log_destroy();
|
2008-03-01 01:06:05 +01:00
|
|
|
}
|
|
|
|
|
2008-03-08 22:48:06 +01:00
|
|
|
|
|
|
|
static int pack_visible( Fl_Pack *p )
|
2008-03-01 01:06:05 +01:00
|
|
|
{
|
2008-03-08 22:48:06 +01:00
|
|
|
int v = 0;
|
|
|
|
for ( int i = p->children(); i--; )
|
|
|
|
if ( p->child( i )->visible() )
|
|
|
|
v++;
|
|
|
|
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* adjust size of widget and children */
|
|
|
|
void
|
|
|
|
Track_Header::resize ( void )
|
|
|
|
{
|
|
|
|
for ( int i = takes->children(); i--; )
|
|
|
|
takes->child( i )->size( w(), height() );
|
|
|
|
|
|
|
|
for ( int i = control->children(); i--; )
|
|
|
|
control->child( i )->size( w(), height() );
|
|
|
|
|
|
|
|
if ( _show_all_takes )
|
|
|
|
{
|
|
|
|
takes->show();
|
|
|
|
Fl_Group::size( w(), height() * ( 1 + takes->children() + pack_visible( control ) ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
takes->hide();
|
|
|
|
Fl_Group::size( w(), height() * ( 1 + pack_visible( control ) ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( track() )
|
|
|
|
track()->size( w(), height() );
|
|
|
|
|
|
|
|
|
|
|
|
if ( controls->y() + controls->h() > y() + h() )
|
|
|
|
controls->hide();
|
|
|
|
else
|
|
|
|
controls->show();
|
|
|
|
|
|
|
|
parent()->redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Track_Header::size ( int v )
|
|
|
|
{
|
|
|
|
if ( v < 0 || v > 3 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
_size = v;
|
|
|
|
|
|
|
|
resize();
|
2008-03-01 01:06:05 +01:00
|
|
|
}
|
|
|
|
|
2008-03-09 22:18:22 +01:00
|
|
|
|
|
|
|
|
2008-03-01 01:06:05 +01:00
|
|
|
void
|
|
|
|
Track_Header::track( Track * t )
|
|
|
|
{
|
2008-03-08 20:04:26 +01:00
|
|
|
// t->size( 1, h() );
|
2008-03-08 22:48:06 +01:00
|
|
|
if ( track() )
|
|
|
|
add( track() );
|
|
|
|
|
|
|
|
// takes->insert( *track(), 0 );
|
|
|
|
|
|
|
|
_track = t;
|
|
|
|
pack->insert( *t, 0 );
|
|
|
|
|
|
|
|
resize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Track_Header::add_control( Track *t )
|
|
|
|
{
|
|
|
|
control->add( t );
|
|
|
|
|
|
|
|
resize();
|
2008-03-01 01:06:05 +01:00
|
|
|
}
|
2008-04-08 22:06:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**********/
|
|
|
|
/* Engine */
|
|
|
|
/**********/
|
|
|
|
|
2008-04-09 02:05:15 +02:00
|
|
|
/* THREAD: RT */
|
2008-04-08 22:06:38 +02:00
|
|
|
nframes_t
|
|
|
|
Track_Header::process ( nframes_t nframes )
|
|
|
|
{
|
2008-04-16 10:44:31 +02:00
|
|
|
if ( playback_ds )
|
|
|
|
{
|
|
|
|
record_ds->process( nframes );
|
|
|
|
return playback_ds->process( nframes );
|
|
|
|
}
|
2008-04-09 02:05:15 +02:00
|
|
|
else
|
|
|
|
return 0;
|
2008-04-08 22:06:38 +02:00
|
|
|
}
|
2008-04-12 21:13:30 +02:00
|
|
|
|
|
|
|
/* THREAD: RT */
|
|
|
|
void
|
|
|
|
Track_Header::seek ( nframes_t frame )
|
|
|
|
{
|
2008-04-16 10:44:31 +02:00
|
|
|
if ( playback_ds )
|
|
|
|
return playback_ds->seek( frame );
|
2008-04-12 21:13:30 +02:00
|
|
|
}
|