Browse Source

Bypass magnetic snap for loop points.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
7dc9a475e9
3 changed files with 19 additions and 7 deletions
  1. +1
    -1
      Timeline/Audio_Region.C
  2. +17
    -5
      Timeline/Timeline.C
  3. +1
    -1
      Timeline/Timeline.H

+ 1
- 1
Timeline/Audio_Region.C View File

@@ -253,7 +253,7 @@ Audio_Region::menu_cb ( const Fl_Menu_ *m )
{
nframes_t f = offset + _r->start;

if ( timeline->nearest_line( &f ) )
if ( timeline->nearest_line( &f, false ) )
_loop = f - _r->start;
else
_loop = offset;


+ 17
- 5
Timeline/Timeline.C View File

@@ -503,7 +503,7 @@ abs_diff ( nframes_t n1, nframes_t n2 )
}

static void
nearest_line_cb ( nframes_t frame, const BBT &bbt, void *arg )
nearest_line_snap_cb ( nframes_t frame, const BBT &bbt, void *arg )
{
nearest_line_arg *n = (nearest_line_arg *)arg;

@@ -518,6 +518,18 @@ nearest_line_cb ( nframes_t frame, const BBT &bbt, void *arg )
n->closest = frame;
}

static void
nearest_line_cb ( nframes_t frame, const BBT &bbt, void *arg )
{
nearest_line_arg *n = (nearest_line_arg *)arg;

if ( n->bar && bbt.beat )
return;

if ( abs_diff( frame, n->original ) < abs_diff( n->original, n->closest ) )
n->closest = frame;
}

static void
prev_next_line_cb ( nframes_t frame, const BBT &bbt, void *arg )
{
@@ -534,17 +546,17 @@ prev_next_line_cb ( nframes_t frame, const BBT &bbt, void *arg )
the nearest measure line to /when/. Returns true if the new value of
*frame is valid, false otherwise. */
bool
Timeline::nearest_line ( nframes_t *frame ) const
Timeline::nearest_line ( nframes_t *frame, bool snap ) const
{
if ( None == Timeline::snap_to )
if ( snap && None == Timeline::snap_to )
return false;

nframes_t when = *frame;

nearest_line_arg n = { when, -1, Timeline::Bars == Timeline::snap_to };
nearest_line_arg n = { when, -1, snap && Timeline::Bars == Timeline::snap_to };

render_tempomap( when > x_to_ts( w() >> 1 ) ? when - x_to_ts( w() >> 1 ) : 0,
when + x_to_ts( w() >> 1 ), nearest_line_cb, &n );
when + x_to_ts( w() >> 1 ), snap ? nearest_line_snap_cb : nearest_line_cb, &n );

if ( n.closest == (nframes_t)-1 )
return false;


+ 1
- 1
Timeline/Timeline.H View File

@@ -156,7 +156,7 @@ public:
int beats_per_bar ( nframes_t when ) const;
void beats_per_minute ( nframes_t when, float bpm );
void time ( nframes_t when, int bpb, int beat_type );
bool nearest_line ( nframes_t *f ) const;
bool nearest_line ( nframes_t *f, bool snap=true ) const;
bool next_line ( nframes_t *f, bool bar=false ) const;
bool prev_line ( nframes_t *f, bool bar=false ) const;



Loading…
Cancel
Save