Draw crossfade waveforms in x-ray style.
This commit is contained in:
parent
35fc23bec8
commit
8a467843d0
2
Region.C
2
Region.C
|
@ -459,7 +459,7 @@ Region::draw ( int X, int Y, int W, int H )
|
||||||
|
|
||||||
int ch = (h() - Fl::box_dh( box() )) / _clip->channels();
|
int ch = (h() - Fl::box_dh( box() )) / _clip->channels();
|
||||||
for ( int i = _clip->channels(); i--; )
|
for ( int i = _clip->channels(); i--; )
|
||||||
draw_waveform( rx, X, (y() + Fl::box_dy( box() )) + (i * ch), W, ch, _clip, i, timeline->fpp(),
|
Waveform::draw( rx, X, (y() + Fl::box_dy( box() )) + (i * ch), W, ch, _clip, i, timeline->fpp(),
|
||||||
_start + offset, min( (_end - _start) - offset, _end),
|
_start + offset, min( (_end - _start) - offset, _end),
|
||||||
_scale, selected() ? fl_invert_color( _color ) : _color );
|
_scale, selected() ? fl_invert_color( _color ) : _color );
|
||||||
|
|
||||||
|
|
29
Track.C
29
Track.C
|
@ -49,6 +49,9 @@ Track::overlaps ( Track_Widget *r )
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "Waveform.H"
|
||||||
|
|
||||||
void
|
void
|
||||||
Track::draw ( void )
|
Track::draw ( void )
|
||||||
{
|
{
|
||||||
|
@ -69,6 +72,10 @@ Track::draw ( void )
|
||||||
for ( list <Track_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
|
for ( list <Track_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
|
||||||
(*r)->draw_box( X, Y, W, H );
|
(*r)->draw_box( X, Y, W, H );
|
||||||
|
|
||||||
|
for ( list <Track_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
|
||||||
|
(*r)->draw( X, Y, W, H );
|
||||||
|
|
||||||
|
|
||||||
/* draw crossfades */
|
/* draw crossfades */
|
||||||
for ( list <Track_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
|
for ( list <Track_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
|
||||||
{
|
{
|
||||||
|
@ -88,6 +95,25 @@ Track::draw ( void )
|
||||||
draw_box( FL_FLAT_BOX, b.x - 100, b.y, b.w + 200, b.h, c );
|
draw_box( FL_FLAT_BOX, b.x - 100, b.y, b.w + 200, b.h, c );
|
||||||
draw_box( FL_UP_FRAME, b.x - 100, b.y, b.w + 200, b.h, c );
|
draw_box( FL_UP_FRAME, b.x - 100, b.y, b.w + 200, b.h, c );
|
||||||
|
|
||||||
|
|
||||||
|
/* draw overlapping waveforms in X-ray style. */
|
||||||
|
Waveform::fill = false;
|
||||||
|
|
||||||
|
/* Fl_Color oc = o->color(); */
|
||||||
|
/* Fl_Color rc = (*r)->color(); */
|
||||||
|
|
||||||
|
/* /\* give each region a different color *\/ */
|
||||||
|
/* o->color( FL_RED ); */
|
||||||
|
/* (*r)->color( FL_GREEN ); */
|
||||||
|
|
||||||
|
o->draw( b.x, b.y, b.w, b.h );
|
||||||
|
(*r)->draw( b.x, b.y, b.w, b.h );
|
||||||
|
Waveform::fill = true;
|
||||||
|
|
||||||
|
|
||||||
|
/* o->color( oc ); */
|
||||||
|
/* (*r)->color( rc ); */
|
||||||
|
|
||||||
/* fl_color( FL_BLACK ); */
|
/* fl_color( FL_BLACK ); */
|
||||||
/* fl_line_style( FL_DOT, 4 ); */
|
/* fl_line_style( FL_DOT, 4 ); */
|
||||||
|
|
||||||
|
@ -106,9 +132,6 @@ Track::draw ( void )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( list <Track_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
|
|
||||||
(*r)->draw( X, Y, W, H );
|
|
||||||
|
|
||||||
timeline->draw_measure_lines( x(), y(), w(), h(), color() );
|
timeline->draw_measure_lines( x(), y(), w(), h(), color() );
|
||||||
|
|
||||||
fl_pop_clip();
|
fl_pop_clip();
|
||||||
|
|
|
@ -173,6 +173,7 @@ public:
|
||||||
virtual int abs_w ( void ) const { return timeline->ts_to_x( _end - _start ); }
|
virtual int abs_w ( void ) const { return timeline->ts_to_x( _end - _start ); }
|
||||||
|
|
||||||
Fl_Color color ( void ) { return _color; }
|
Fl_Color color ( void ) { return _color; }
|
||||||
|
void color ( Fl_Color v ) { _color = v; }
|
||||||
Fl_Color box_color ( void ) { return _box_color; }
|
Fl_Color box_color ( void ) { return _box_color; }
|
||||||
|
|
||||||
Track * track ( void ) const { return _track; }
|
Track * track ( void ) const { return _track; }
|
||||||
|
|
22
Waveform.C
22
Waveform.C
|
@ -26,15 +26,21 @@
|
||||||
#include "Timeline.H"
|
#include "Timeline.H"
|
||||||
#include "Audio_File.H"
|
#include "Audio_File.H"
|
||||||
|
|
||||||
|
#include "Waveform.H"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
const bool outline = true;
|
|
||||||
const bool vary_color = true;
|
bool Waveform::fill = true;
|
||||||
|
bool Waveform::outline = true;
|
||||||
|
bool Waveform::vary_color = true;
|
||||||
|
|
||||||
|
/* TODO: split the variations into separate functions. eg, plain,
|
||||||
|
* outlined, filled, polygonal, rectified. */
|
||||||
|
|
||||||
/** draw a portion of /clip/'s waveform. coordinates are the portion to draw */
|
/** draw a portion of /clip/'s waveform. coordinates are the portion to draw */
|
||||||
void
|
void
|
||||||
draw_waveform ( int ox, int X, int Y, int W, int H, Audio_File *_clip, int channel, float fpp, nframes_t _start, nframes_t _end, float _scale, Fl_Color color )
|
Waveform::draw ( int ox, int X, int Y, int W, int H, Audio_File *_clip, int channel, float fpp, nframes_t _start, nframes_t _end, float _scale, Fl_Color color )
|
||||||
{
|
{
|
||||||
fl_push_clip( X, Y, W, H );
|
fl_push_clip( X, Y, W, H );
|
||||||
|
|
||||||
|
@ -52,8 +58,8 @@ draw_waveform ( int ox, int X, int Y, int W, int H, Audio_File *_clip, int chann
|
||||||
const int halfheight = H / 2;
|
const int halfheight = H / 2;
|
||||||
const int mid = Y + halfheight;
|
const int mid = Y + halfheight;
|
||||||
|
|
||||||
fl_line_style( FL_SOLID, 1 );
|
if ( Waveform::fill )
|
||||||
|
{
|
||||||
j = start;
|
j = start;
|
||||||
for ( int x = X; x <= X + W; ++x, ++j )
|
for ( int x = X; x <= X + W; ++x, ++j )
|
||||||
{
|
{
|
||||||
|
@ -64,7 +70,7 @@ draw_waveform ( int ox, int X, int Y, int W, int H, Audio_File *_clip, int chann
|
||||||
|
|
||||||
const float diff = fabs( p.max - p.min );
|
const float diff = fabs( p.max - p.min );
|
||||||
|
|
||||||
if ( vary_color )
|
if ( Waveform::vary_color )
|
||||||
fl_color( fl_color_average( FL_WHITE, color, min( 1.0f, diff ) ) );
|
fl_color( fl_color_average( FL_WHITE, color, min( 1.0f, diff ) ) );
|
||||||
else
|
else
|
||||||
fl_color( color );
|
fl_color( color );
|
||||||
|
@ -84,10 +90,10 @@ draw_waveform ( int ox, int X, int Y, int W, int H, Audio_File *_clip, int chann
|
||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fl_line_style( FL_SOLID, 0 );
|
|
||||||
|
|
||||||
if ( outline )
|
if ( Waveform::outline )
|
||||||
{
|
{
|
||||||
|
|
||||||
fl_color( fl_darker( fl_darker( color ) ) );
|
fl_color( fl_darker( fl_darker( color ) ) );
|
||||||
|
|
13
Waveform.H
13
Waveform.H
|
@ -26,4 +26,15 @@
|
||||||
|
|
||||||
#include "Audio_File.H"
|
#include "Audio_File.H"
|
||||||
|
|
||||||
void draw_waveform ( int rx, int X, int Y, int W, int H, Audio_File *_clip, int channel, float fpp, nframes_t _start, nframes_t _end, float _scale, Fl_Color color );
|
|
||||||
|
class Waveform {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
static bool fill;
|
||||||
|
static bool outline;
|
||||||
|
static bool vary_color;
|
||||||
|
|
||||||
|
static void draw ( int rx, int X, int Y, int W, int H, Audio_File *_clip, int channel, float fpp, nframes_t _start, nframes_t _end, float _scale, Fl_Color color );
|
||||||
|
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue