non/Timeline/Audio_Region.C

684 lines
18 KiB
C++
Raw Normal View History

2008-02-14 08:40:47 +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 <FL/fl_draw.H>
#include <FL/Fl.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Widget.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Menu_Item.H>
#include <FL/fl_show_colormap.H>
#include <stdio.h>
2008-02-14 08:40:47 +01:00
#include "Sequence.H"
#include "Audio_Region.H"
#include "Timeline.H"
#include "Waveform.H"
#include "Audio_Sequence.H"
#include "Track.H"
#include "Engine/Audio_File.H"
#include <algorithm>
2008-05-22 22:58:36 +02:00
using std::min;
using std::max;
2008-05-26 07:46:37 +02:00
2008-02-21 17:20:36 +01:00
extern Timeline *timeline;
2008-05-05 02:04:20 +02:00
bool Audio_Region::inherit_track_color = true;
2008-04-14 10:55:22 +02:00
2008-05-05 02:04:20 +02:00
Fl_Boxtype Audio_Region::_box = FL_UP_BOX;
2008-02-20 13:45:02 +01:00
2008-05-05 02:04:20 +02:00
Fl_Color Audio_Region::_selection_color = FL_MAGENTA;
2008-02-21 08:38:31 +01:00
2008-05-26 07:46:37 +02:00
2008-02-21 10:48:53 +01:00
static Fl_Color fl_invert_color ( Fl_Color c )
{
unsigned char r, g, b;
Fl::get_color( c, r, g, b );
return fl_rgb_color( 255 - r, 255 - g, 255 - b );
}
void
Audio_Region::get ( Log_Entry &e ) const
2008-02-26 02:03:59 +01:00
{
e.add( ":source", _clip ? _clip->name() : "" );
e.add( ":gain", _scale );
e.add( ":fade-in-type", _fade_in.type );
e.add( ":fade-in-duration", _fade_in.length );
e.add( ":fade-out-type", _fade_out.type );
e.add( ":fade-out-duration", _fade_out.length );
2008-02-26 02:03:59 +01:00
Sequence_Region::get( e );
2008-02-26 02:03:59 +01:00
e.add( ":offset", _r->offset );
}
2008-02-26 02:03:59 +01:00
void
Audio_Region::set ( Log_Entry &e )
{
for ( int i = 0; i < e.size(); ++i )
{
const char *s, *v;
e.get( i, &s, &v );
if ( ! strcmp( s, ":gain" ) )
_scale = atof( v );
else if ( ! strcmp( s, ":color" ) )
_box_color = (Fl_Color)atoi( v );
else if ( ! strcmp( s, ":fade-in-type" ) )
_fade_in.type = (Fade::fade_type_e)atoi( v );
else if ( ! strcmp( s, ":fade-in-duration" ) )
_fade_in.length = atoll( v );
else if ( ! strcmp( s, ":fade-out-type" ) )
_fade_out.type = (Fade::fade_type_e)atoi( v );
else if ( ! strcmp( s, ":fade-out-duration" ) )
_fade_out.length = atoll( v );
else if ( ! strcmp( s, ":offset" ) )
_r->offset = atoll( v );
else if ( ! strcmp( s, ":source" ) )
{
if ( ! ( _clip = Audio_File::from_file( v ) ) )
{
printf( "Grave error: could not open source \"%s\"\n", v );
}
}
}
2008-02-26 02:03:59 +01:00
Sequence_Region::set( e );
2008-02-26 02:03:59 +01:00
}
void
2008-05-05 02:04:20 +02:00
Audio_Region::init ( void )
2008-02-14 08:40:47 +01:00
{
2008-05-07 18:42:31 +02:00
_sequence = NULL;
_scale = 1.0f;
_clip = NULL;
2008-02-20 08:53:54 +01:00
_box_color = FL_CYAN;
_color = FL_BLUE;
_fade_in.length = 256;
_fade_in.type = Fade::Sigmoid;
_fade_out = _fade_in;
2008-02-14 08:40:47 +01:00
}
2008-02-28 13:51:51 +01:00
/* copy constructor */
Audio_Region::Audio_Region ( const Audio_Region & rhs ) : Sequence_Region( rhs )
2008-02-16 08:46:43 +01:00
{
// *((Sequence_Region*)this) = (Sequence_Region &)rhs;
2008-03-01 16:25:27 +01:00
_clip = rhs._clip;
_scale = rhs._scale;
_fade_in = rhs._fade_in;
_fade_out = rhs._fade_out;
log_create();
2008-02-16 08:46:43 +01:00
}
2008-02-28 13:51:51 +01:00
/* */
2008-05-05 02:04:20 +02:00
Audio_Region::Audio_Region ( Audio_File *c )
{
init();
_clip = c;
_r->length = _clip->length();
log_create();
}
2008-02-18 02:13:20 +01:00
2008-02-28 13:51:51 +01:00
/* used when DND importing */
2008-05-05 02:04:20 +02:00
Audio_Region::Audio_Region ( Audio_File *c, Sequence *t, nframes_t o )
2008-02-28 13:51:51 +01:00
{
init();
_clip = c;
2008-05-07 18:42:31 +02:00
_sequence = t;
_r->offset = 0;
_r->start = o;
_r->length = _clip->length();
2008-02-28 13:51:51 +01:00
2008-05-07 18:42:31 +02:00
sequence()->add( this );
2008-02-28 13:51:51 +01:00
2008-03-01 16:25:27 +01:00
int sum = 0;
const char *s = rindex( _clip->name(), '/' );
if ( ! s )
s = _clip->name();
2008-03-01 16:25:27 +01:00
for ( int i = strlen( s ); i--; )
sum += s[ i ];
while ( sum >> 8 )
sum = (sum & 0xFF) + (sum >> 8);
_color = (Fl_Color)sum;
/* _color = fl_color_average( FL_YELLOW, (Fl_Color)sum, 0.80 ); */
// _color = FL_YELLOW;
_box_color = FL_WHITE;
2008-02-28 13:51:51 +01:00
log_create();
}
const char *
Audio_Region::source_name ( void ) const
{
return _clip->name();
}
void
Audio_Region::menu_cb ( Fl_Widget *w, void *v )
{
((Audio_Region*)v)->menu_cb( (Fl_Menu_*) w );
}
void
Audio_Region::menu_cb ( const Fl_Menu_ *m )
{
char picked[256];
m->item_pathname( picked, sizeof( picked ) );
Logger log( this );
if ( ! strcmp( picked, "Fade/In/Linear" ) )
_fade_in.type = Fade::Linear;
else if ( ! strcmp( picked, "Fade/In/Sigmoid" ) )
_fade_in.type = Fade::Sigmoid;
else if ( ! strcmp( picked, "Fade/In/Logarithmic" ) )
_fade_in.type = Fade::Logarithmic;
else if ( ! strcmp( picked, "Fade/In/Parabolic" ) )
_fade_in.type = Fade::Parabolic;
else if ( ! strcmp( picked, "Fade/Out/Linear" ) )
_fade_out.type = Fade::Linear;
else if ( ! strcmp( picked, "Fade/Out/Sigmoid" ) )
_fade_out.type = Fade::Sigmoid;
else if ( ! strcmp( picked, "Fade/Out/Logarithmic" ) )
_fade_out.type = Fade::Logarithmic;
else if ( ! strcmp( picked, "Fade/Out/Parabolic" ) )
_fade_out.type = Fade::Parabolic;
else if ( ! strcmp( picked, "/Color" ) )
box_color( fl_show_colormap( box_color() ) );
else if ( ! strcmp( picked, "/Fade in to mouse" ) )
{
nframes_t offset = x_to_offset( Fl::event_x() );
if ( offset < length() )
_fade_in.length = offset;
DMESSAGE( "set fade in duration" );
}
else if ( ! strcmp( picked, "/Fade out to mouse" ) )
{
long offset = length() - x_to_offset( Fl::event_x() );
if ( offset > 0 )
_fade_out.length = offset;
}
else
FATAL( "Unknown menu choice \"%s\"", picked );
redraw();
}
#include "FL/test_press.H"
#include "FL/menu_popup.H"
/** build the context menu for this region */
2008-05-30 05:34:42 +02:00
Fl_Menu_Button &
Audio_Region::menu ( void )
{
2008-05-30 05:34:42 +02:00
static Fl_Menu_Button m( 0, 0, 0, 0, "Region" );
Fade::fade_type_e it = _fade_in.type;
Fade::fade_type_e ot = _fade_out.type;
Fl_Menu_Item items[] =
{
{ "Fade", 0, 0, 0, FL_SUBMENU },
{ "In", 0, 0, 0, FL_SUBMENU },
{ "Linear", 0, 0, 0, FL_MENU_RADIO | ( it == Fade::Linear ? FL_MENU_VALUE : 0 ) },
{ "Sigmoid", 0, 0, 0, FL_MENU_RADIO | ( it == Fade::Sigmoid ? FL_MENU_VALUE : 0 ) },
{ "Logarithmic", 0, 0, 0, FL_MENU_RADIO | ( it == Fade::Logarithmic ? FL_MENU_VALUE : 0 ) },
{ "Parabolic", 0, 0, 0, FL_MENU_RADIO | ( it == Fade::Parabolic ? FL_MENU_VALUE : 0 ) },
{ 0 },
{ "Out", 0, 0, 0, FL_SUBMENU },
{ "Linear", 0, 0, 0, FL_MENU_RADIO | ( ot == Fade::Linear ? FL_MENU_VALUE : 0 ) },
{ "Sigmoid", 0, 0, 0, FL_MENU_RADIO | ( ot == Fade::Sigmoid ? FL_MENU_VALUE : 0 ) },
{ "Logarothmic", 0, 0, 0, FL_MENU_RADIO | ( ot == Fade::Logarithmic ? FL_MENU_VALUE : 0 ) },
{ "Parabolic", 0, 0, 0, FL_MENU_RADIO | ( ot == Fade::Parabolic ? FL_MENU_VALUE : 0 ) },
{ 0 },
{ 0 },
{ "Color", 0, 0, 0, inherit_track_color ? FL_MENU_INACTIVE : 0 },
{ "Fade in to mouse", FL_F + 3, 0, 0 },
{ "Fade out to mouse", FL_F + 4, 0, 0 },
{ 0 },
};
menu_set_callback( items, &Audio_Region::menu_cb, (void*)this );
2008-05-30 05:34:42 +02:00
m.copy( items, (void*)this );
return m;
}
int
2008-05-05 02:04:20 +02:00
Audio_Region::handle ( int m )
2008-02-20 07:35:29 +01:00
{
static int ox, oy;
2008-02-20 07:35:29 +01:00
static bool copied = false;
static nframes_t os;
2008-03-05 03:12:54 +01:00
int X = Fl::event_x();
2008-02-20 07:35:29 +01:00
int Y = Fl::event_y();
2008-02-24 14:28:55 +01:00
Logger _log( this );
2008-02-21 03:06:39 +01:00
2008-02-20 07:35:29 +01:00
switch ( m )
{
case FL_FOCUS:
case FL_UNFOCUS:
return 1;
case FL_KEYBOARD:
2008-05-30 05:34:42 +02:00
return menu().test_shortcut() != 0;
case FL_ENTER:
return Sequence_Region::handle( m );
case FL_LEAVE:
return Sequence_Region::handle( m );
2008-02-20 07:35:29 +01:00
case FL_PUSH:
{
/* splitting */
if ( test_press( FL_BUTTON2 | FL_SHIFT ) )
2008-02-20 07:35:29 +01:00
{
2008-05-26 04:22:52 +02:00
/* split */
if ( ! copied )
2008-02-20 07:35:29 +01:00
{
2008-05-26 04:22:52 +02:00
Loggable::block_start();
2008-05-26 04:22:52 +02:00
Audio_Region *copy = new Audio_Region( *this );
2008-02-24 08:48:07 +01:00
2008-05-26 04:22:52 +02:00
trim( RIGHT, X );
copy->trim( LEFT, X );
2008-02-24 08:48:07 +01:00
2008-05-26 04:22:52 +02:00
sequence()->add( copy );
2008-05-26 04:22:52 +02:00
log_end();
2008-05-26 04:22:52 +02:00
Loggable::block_end();
2008-02-20 07:35:29 +01:00
}
2008-02-24 08:42:41 +01:00
2008-05-26 04:22:52 +02:00
return 0;
2008-02-20 07:35:29 +01:00
}
else
{
ox = x() - X;
oy = y() - Y;
/* for panning */
os = _r->offset;
if ( test_press( FL_BUTTON2 | FL_CTRL ) )
2008-02-21 03:10:44 +01:00
{
2008-05-26 04:22:52 +02:00
normalize();
2008-02-22 05:53:39 +01:00
redraw();
return 1;
2008-02-21 03:10:44 +01:00
}
else if ( test_press( FL_BUTTON3 ) )
{
/* context menu */
2008-05-30 05:34:42 +02:00
menu_popup( &menu() );
2008-05-26 04:22:52 +02:00
return 1;
}
2008-03-05 23:51:04 +01:00
else
2008-05-08 02:25:12 +02:00
return Sequence_Region::handle( m );
2008-02-20 07:35:29 +01:00
}
2008-05-26 04:22:52 +02:00
2008-02-20 07:35:29 +01:00
break;
}
case FL_RELEASE:
2008-03-05 03:12:54 +01:00
{
2008-05-08 02:25:12 +02:00
Sequence_Region::handle( m );
2008-03-05 03:12:54 +01:00
2008-02-20 07:35:29 +01:00
copied = false;
2008-03-05 03:12:54 +01:00
return 1;
2008-03-05 03:12:54 +01:00
}
2008-02-20 07:35:29 +01:00
case FL_DRAG:
2008-03-05 03:12:54 +01:00
if ( ! _drag )
2008-02-24 14:28:55 +01:00
{
2008-05-02 07:52:50 +02:00
begin_drag( Drag( x() - X, y() - Y, x_to_offset( X ) ) );
2008-02-24 14:28:55 +01:00
_log.hold();
}
2008-05-26 04:22:52 +02:00
if ( test_press( FL_BUTTON1 | FL_SHIFT | FL_CTRL ) )
2008-02-20 07:35:29 +01:00
{
2008-05-26 04:22:52 +02:00
/* panning */
int d = (ox + X) - x();
long td = timeline->x_to_ts( d );
2008-02-20 12:48:42 +01:00
2008-05-26 04:22:52 +02:00
if ( td > 0 && os < (nframes_t)td )
_r->offset = 0;
else
_r->offset = os - td;
2008-05-26 04:22:52 +02:00
redraw();
return 1;
2008-02-20 07:35:29 +01:00
}
2008-05-26 04:22:52 +02:00
return Sequence_Region::handle( m );
2008-02-20 07:35:29 +01:00
default:
2008-05-08 02:25:12 +02:00
return Sequence_Region::handle( m );
2008-02-20 07:35:29 +01:00
break;
}
return 0;
2008-02-20 07:35:29 +01:00
}
2008-02-14 08:40:47 +01:00
/** Draws the curve for a single fade. /X/ and /W/ repersent the
2008-04-16 07:50:32 +02:00
portion of the region covered by this draw, which may or may not
cover the fade in question. */
void
2008-05-05 02:04:20 +02:00
Audio_Region::draw_fade ( const Fade &fade, Fade::fade_dir_e dir, bool line, int X, int W )
{
const int dy = y() + Fl::box_dy( box() );
const int dh = h() - Fl::box_dh( box() );
const int height = dh;
const int width = timeline->ts_to_x( fade.length );
2008-04-02 08:49:24 +02:00
fl_color( fl_lighter( FL_BLACK ) );
2008-02-14 08:40:47 +01:00
fl_push_matrix();
2008-02-21 08:38:31 +01:00
if ( dir == Fade::In )
fl_translate( line_x(), dy );
2008-02-21 08:38:31 +01:00
else
{
fl_translate( line_x() + abs_w(), dy );
/* flip */
fl_scale( -1.0, 1.0 );
}
2008-04-15 10:53:36 +02:00
fl_scale( width, height );
if ( line )
fl_begin_line();
2008-04-15 10:53:36 +02:00
else
fl_begin_polygon();
fl_vertex( 0.0, 0.0 );
fl_vertex( 0.0, 1.0 );
2008-04-16 07:50:32 +02:00
// if ( draw_real_fade_curve )
{
nframes_t tsx = timeline->x_to_ts( 1 );
nframes_t ts = 0;
for ( int i = 0; i < width; ++i, ts += tsx )
fl_vertex( i / (float)width, 1.0f - fade.gain( ts / (float)fade.length ) );
}
2008-04-15 16:01:21 +02:00
fl_vertex( 1.0, 0.0 );
2008-04-15 10:53:36 +02:00
if ( line )
fl_end_line();
2008-04-15 10:53:36 +02:00
else
fl_end_polygon();
fl_pop_matrix();
}
2008-05-11 19:18:51 +02:00
struct Peaks_Redraw_Request {
Audio_Region *region;
nframes_t start;
nframes_t end;
Peaks_Redraw_Request ( Audio_Region *region, nframes_t start, nframes_t end ) : region( region ), start( start), end( end )
{
}
};
/* static wrapper */
void
Audio_Region::peaks_pending_cb ( void *v )
{
Peaks_Redraw_Request *r = (Peaks_Redraw_Request*)v;
r->region->peaks_pending_cb( r );
}
void
Audio_Region::peaks_pending_cb ( Peaks_Redraw_Request *r )
{
2008-05-11 19:18:51 +02:00
int npeaks = timeline->ts_to_x( r->end - r->start );
2008-05-11 19:18:51 +02:00
if ( _clip->peaks()->ready( r->start, npeaks, timeline->fpp() ) )
{
printf( "damaging from timeout\n" );
/* FIXME: only need to damage the affected area! */
timeline->damage( FL_DAMAGE_ALL, x(), y(), w(), h() );
2008-05-11 19:18:51 +02:00
delete r;
}
else
Fl::repeat_timeout( 0.1f, &Audio_Region::peaks_pending_cb, (void*)r );
}
2008-04-25 09:35:55 +02:00
void
2008-05-05 02:04:20 +02:00
Audio_Region::draw_box( void )
{
/* dirty hack to keep the box from flipping to vertical at small sizes */
fl_push_clip( x(), y(), w(), h() );
Fl_Color selection_color = _selection_color;
2008-04-26 11:01:54 +02:00
2008-05-07 18:42:31 +02:00
Fl_Color color = Audio_Region::inherit_track_color ? sequence()->track()->color() : _box_color;
2008-05-07 18:42:31 +02:00
color = fl_color_average( color, sequence()->color(), 0.75f );
2008-04-25 09:35:55 +02:00
2008-05-23 04:23:41 +02:00
if ( this == ((Audio_Sequence*)sequence())->capture_region() )
2008-04-25 09:07:18 +02:00
{
color = FL_RED;
}
else if ( ! active_r() )
{
color = fl_inactive( color );
selection_color = fl_inactive( selection_color );
}
if ( selected() )
2008-05-30 06:17:41 +02:00
fl_draw_box( fl_down( box() ), x() - ( h() >> 1 ), y(), w() + ( h() >> 1 ) + 50, h(), selection_color );
else
2008-05-30 06:17:41 +02:00
fl_draw_box( box(), x() - ( h() >> 1 ), y(), w() + ( h() >> 1 ) + 50, h(), color );
/* draw fades */
draw_fade( _fade_in, Fade::In, false, x(), w() );
draw_fade( _fade_out, Fade::Out, false, x(), w() );
fl_pop_clip();
}
2008-04-17 15:27:35 +02:00
/** Draw (part of) region. X, Y, W and H are the rectangle we're clipped to. */
2008-02-14 08:40:47 +01:00
void
2008-05-05 02:04:20 +02:00
Audio_Region::draw ( void )
2008-02-14 08:40:47 +01:00
{
2008-04-17 17:19:04 +02:00
/* intersect clip with region */
int X, Y, W, H;
2008-04-17 17:19:04 +02:00
fl_clip_box( x(), y(), w(), h(), X, Y, W, H );
2008-02-20 11:45:10 +01:00
if ( ! ( W > 0 && H > 0 ) )
/* no coverage */
2008-02-20 11:45:10 +01:00
return;
/* account for waveform outlines... */
X -= 2;
W += 4;
int OX = scroll_x();
int ox = timeline->ts_to_x( _r->start );
2008-02-21 01:25:21 +01:00
2008-05-07 18:42:31 +02:00
if ( ox > OX + sequence()->w() ||
ox < OX && ox + abs_w() < OX )
2008-04-17 15:27:35 +02:00
/* not in viewport */
2008-02-20 11:45:10 +01:00
return;
int rw = timeline->ts_to_x( _r->length );
2008-02-20 11:45:10 +01:00
/* calculate waveform offset due to scrolling */
nframes_t offset = 0;
2008-02-21 01:25:21 +01:00
if ( ox < OX )
2008-02-20 11:45:10 +01:00
{
2008-02-21 17:20:36 +01:00
offset = timeline->x_to_ts( OX - ox );
2008-02-20 11:45:10 +01:00
2008-04-17 17:19:04 +02:00
rw -= OX - ox;
2008-02-20 11:45:10 +01:00
}
2008-05-07 18:42:31 +02:00
rw = min( rw, sequence()->w() );
2008-02-20 11:45:10 +01:00
int rx = x();
fl_push_clip( rx, Y, rw, H );
2008-02-20 08:53:54 +01:00
/* get actual peak data */
int channels;
int peaks;
Peak *pbuf;
2008-02-20 13:45:02 +01:00
2008-02-14 08:40:47 +01:00
2008-04-17 15:27:35 +02:00
// const nframes_t start = _r->start + offset + timeline->x_to_ts( X - rx );
// nframes_t start = _r->start + offset;
nframes_t start = _r->offset + offset;
2008-02-16 05:23:58 +01:00
2008-04-17 17:19:04 +02:00
/* compensate for ??? */
if ( X - rx > 0 )
start += timeline->x_to_ts( X - rx );
2008-04-30 08:40:33 +02:00
const int peaks_needed = min( timeline->ts_to_x( _clip->length() - start ), W );
2008-05-11 19:18:51 +02:00
const nframes_t end = start + timeline->x_to_ts( peaks_needed );
2008-04-17 15:27:35 +02:00
if ( _clip->read_peaks( timeline->fpp(),
start,
2008-05-11 19:18:51 +02:00
end,
&peaks, &pbuf, &channels ) &&
peaks )
{
2008-04-17 15:27:35 +02:00
assert( pbuf );
/* draw fade curve outlines--this is only here because of crossfades */
draw_fade( _fade_in, Fade::In, true, X, W );
draw_fade( _fade_out, Fade::Out, true, X, W );
int ch = (h() - Fl::box_dh( box() )) / channels;
Waveform::scale( pbuf, peaks * channels, _scale );
2008-04-17 15:27:35 +02:00
2008-04-17 18:12:22 +02:00
for ( int i = 0; i < channels; ++i )
{
// Peak *pb = pbuf + (peaks * i);
/* int fw = timeline->ts_to_x( fade.length ); */
/* /\* if ( draw_fade_waveform ) *\/ */
/* for ( int j = min( fw, peaks ); j--; ) */
/* { */
/* const float g = fade.gain( j * timeline->fpp() ); */
/* pb[ j ].min *= g; */
/* pb[ j ].max *= g; */
/* } */
Waveform::draw( X,
2008-04-17 17:19:04 +02:00
(y() + Fl::box_dy( box() )) + (i * ch),
W,
2008-04-17 17:19:04 +02:00
ch,
2008-04-17 18:12:22 +02:00
pbuf + i, peaks, channels,
2008-04-17 15:27:35 +02:00
selected() ? fl_invert_color( _color ) : _color );
}
}
2008-04-14 10:55:22 +02:00
2008-04-30 08:40:33 +02:00
if ( peaks < peaks_needed )
{
/* couldn't read peaks--perhaps they're being generated. Try again later. */
2008-05-11 19:18:51 +02:00
Fl::add_timeout( 0.1f, &Audio_Region::peaks_pending_cb,
new Peaks_Redraw_Request( this, start + timeline->x_to_ts( peaks ), end ) );
}
timeline->draw_measure_lines( X, Y, W, H, _box_color );
2008-02-20 13:45:02 +01:00
/* fl_color( FL_BLACK ); */
/* fl_line( rx, Y, rx, Y + H ); */
/* fl_line( rx + rw - 1, Y, rx + rw - 1, Y + H ); */
2008-02-16 05:23:58 +01:00
2008-05-21 02:46:02 +02:00
if ( _clip->dummy() )
{
char pat[256];
snprintf( pat, sizeof( pat ), "Missing Source!: %s", _clip->name() );
draw_label( pat, align() );
}
else
draw_label( _clip->name(), align() );
2008-04-28 08:34:33 +02:00
/* if ( current() ) */
/* { */
/* /\* draw length bubble *\/ */
2008-04-28 08:34:33 +02:00
/* char pat[40]; */
2008-04-28 08:34:33 +02:00
/* snprintf( pat, sizeof( pat ), "%dm:%.1fs", (int)(length() / timeline->sample_rate()) / 60, (double)length() / timeline->sample_rate() ); */
2008-02-20 11:45:10 +01:00
2008-04-28 08:34:33 +02:00
/* draw_label( pat, (Fl_Align)(FL_ALIGN_INSIDE | FL_ALIGN_CENTER), FL_GREEN ); */
/* } */
2008-02-21 08:38:31 +01:00
fl_pop_clip();
2008-02-20 11:45:10 +01:00
2008-02-14 08:40:47 +01:00
}
2008-02-21 03:10:44 +01:00
void
2008-05-05 02:04:20 +02:00
Audio_Region::normalize ( void )
2008-02-21 03:10:44 +01:00
{
int peaks, channels;
Peak *pbuf;
if ( _clip->read_peaks( length(), offset(), offset() + length(), &peaks, &pbuf, &channels ) &&
peaks )
_scale = pbuf->normalization_factor();
2008-02-21 13:57:33 +01:00
}