Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

905 lines
21KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2008 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. #include "Timeline.H"
  19. #include "Tempo_Sequence.H"
  20. #include "Time_Sequence.H"
  21. #include "Audio_Sequence.H"
  22. #include "Control_Sequence.H"
  23. #include <FL/Fl_Scrollbar.H>
  24. #include "Ruler_Sequence.H"
  25. // #include <FL/Fl_Image.H>
  26. // #include <FL/Fl_RGB_Image.H> // needed for alpha blending
  27. #include "Track.H"
  28. const float UPDATE_FREQ = 0.02f;
  29. #include "Playback_DS.H"
  30. #include "Transport.H"
  31. void
  32. Timeline::cb_scroll ( Fl_Widget *w, void *v )
  33. {
  34. ((Timeline*)v)->cb_scroll( w );
  35. }
  36. void
  37. Timeline::cb_scroll ( Fl_Widget *w )
  38. {
  39. if ( w == vscroll )
  40. {
  41. tracks->position( tracks->x(), (rulers->y() + rulers->h()) - vscroll->value() );
  42. yposition( vscroll->value() );
  43. int rh = h() - rulers->h();
  44. vscroll->value( vscroll->value(), 30, 0, max( tracks->h() - rh, rh) );
  45. }
  46. else
  47. {
  48. if ( hscroll->zoom_changed() )
  49. {
  50. _fpp = hscroll->zoom() * 1;
  51. int maxx = ts_to_x( _length );
  52. hscroll->range( 0, maxx );
  53. redraw();
  54. }
  55. else
  56. {
  57. xposition( hscroll->value() );
  58. }
  59. }
  60. }
  61. Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : Fl_Overlay_Window( X, Y, W, H, L )
  62. {
  63. box( FL_FLAT_BOX );
  64. xoffset = 0;
  65. _enable_measure_lines = true;
  66. X = Y = 0;
  67. {
  68. Scalebar *o = new Scalebar( X, Y + H - 18, W - 18, 18 );
  69. o->range( 0, 48000 * 300 );
  70. o->zoom_range( 2, 8192 );
  71. o->zoom( 256 );
  72. o->type( FL_HORIZONTAL );
  73. o->callback( cb_scroll, this );
  74. hscroll = o;
  75. }
  76. {
  77. Fl_Scrollbar *o = new Fl_Scrollbar( X + W - 18, Y, 18, H - 18 );
  78. o->type( FL_VERTICAL );
  79. o->callback( cb_scroll, this );
  80. vscroll = o;
  81. }
  82. {
  83. Fl_Pack *o = new Fl_Pack( X + Track::width(), Y, (W - Track::width()) - vscroll->w(), H - hscroll->h(), "rulers" );
  84. o->type( Fl_Pack::VERTICAL );
  85. {
  86. Tempo_Sequence *o = new Tempo_Sequence( 0, 0, 800, 24 );
  87. o->color( FL_RED );
  88. o->label( "Tempo" );
  89. o->align( FL_ALIGN_LEFT );
  90. tempo_track = o;
  91. }
  92. {
  93. Time_Sequence *o = new Time_Sequence( 0, 24, 800, 24 );
  94. o->color( fl_color_average( FL_RED, FL_WHITE, 0.50f ) );
  95. o->label( "Time" );
  96. o->align( FL_ALIGN_LEFT );
  97. time_track = o;
  98. }
  99. {
  100. Ruler_Sequence *o = new Ruler_Sequence( 0, 24, 800, 24 );
  101. o->color( FL_GREEN );
  102. o->label( "Ruler" );
  103. o->align( FL_ALIGN_LEFT );
  104. ruler_track = o;
  105. }
  106. o->size( o->w(), o->child( 0 )->h() * o->children() );
  107. rulers = o;
  108. o->end();
  109. }
  110. {
  111. _sample_rate = 44100;
  112. _fpp = 256;
  113. _length = _sample_rate * 60 * 2;
  114. {
  115. Fl_Pack *o = new Fl_Pack( X, rulers->y() + rulers->h(), W - vscroll->w(), 5000 );
  116. o->type( Fl_Pack::VERTICAL );
  117. o->spacing( 0 );
  118. tracks = o;
  119. o->end();
  120. resizable( o );
  121. }
  122. }
  123. /* make sure scrollbars are on top */
  124. add( vscroll );
  125. add( hscroll );
  126. vscroll->range( 0, tracks->h() );
  127. redraw();
  128. end();
  129. Fl::add_timeout( UPDATE_FREQ, update_cb, this );
  130. }
  131. float
  132. Timeline::beats_per_minute ( nframes_t when ) const
  133. {
  134. return tempo_track->beats_per_minute( when );
  135. }
  136. int
  137. Timeline::beats_per_bar ( nframes_t when ) const
  138. {
  139. time_sig t = time_track->time( when );
  140. return t.beats_per_bar;
  141. }
  142. void
  143. Timeline::beats_per_minute ( nframes_t when, float bpm )
  144. {
  145. tempo_track->add( new Tempo_Point( when, bpm ) );
  146. }
  147. #if 0
  148. struct BBT
  149. {
  150. int bar, beat, tick;
  151. BBT ( int bar, int beat, int tick ) : bar( bar ), beat( beat ), tick( tick )
  152. {
  153. }
  154. };
  155. /** returns the BBT value for timestamp /when/ by examining the tempo/time maps */
  156. BBT
  157. Timeline::bbt ( nframes_t when )
  158. {
  159. Tempo_Sequence *tempo = (Tempo_Sequence*)rulers->child( 0 );
  160. BBT bbt;
  161. for ( list <Sequence_Widget *>::const_iterator i = tempo.widgets.begin();
  162. i != tempo.widgets.end(); ++i )
  163. {
  164. Tempo_Point *p = *i;
  165. }
  166. };
  167. #endif
  168. /** return the absolute pixel of the nearest measure line to /x/ */
  169. int
  170. Timeline::nearest_line ( int ix )
  171. {
  172. for ( int x = ix - 10; x < ix + 10; ++x )
  173. {
  174. const int measure = ts_to_x( (double)(_sample_rate * 60) / beats_per_minute( x_to_ts( x - Track::width() ) + xoffset ));
  175. // const int abs_x = ts_to_x( xoffset ) + x;
  176. if ( 0 == x % measure )
  177. return x;
  178. }
  179. return -1;
  180. }
  181. /** draw appropriate measure lines inside the given bounding box */
  182. /* FIXME: this function *really* needs to be optimized. Currently it
  183. searched both the time and tempo lists once for every horiontal
  184. pixel and performs a number of calculations--this is slow. */
  185. void
  186. Timeline::draw_measure ( int X, int Y, int W, int H, Fl_Color color, bool BBT )
  187. {
  188. if ( ! _enable_measure_lines )
  189. return;
  190. // fl_line_style( FL_DASH, 2 );
  191. fl_line_style( FL_DASH, 0 );
  192. Fl_Color beat = fl_color_average( FL_BLACK, color, 0.65f );
  193. Fl_Color bar = fl_color_average( FL_RED, color, 0.65f );
  194. int measure;
  195. for ( int x = X; x < X + W; ++x )
  196. {
  197. measure = ts_to_x( (double)(_sample_rate * 60) / beats_per_minute( x_to_ts( x - Track::width() ) + xoffset ) );
  198. const int abs_x = ts_to_x( xoffset ) + x - Track::width();
  199. if ( 0 == abs_x % measure )
  200. {
  201. int bpb = beats_per_bar( x_to_ts( x -Track::width() ) + xoffset );
  202. if ( 0 == (abs_x / measure) % bpb )
  203. {
  204. if ( measure * bpb < 8 )
  205. break;
  206. if ( BBT )
  207. {
  208. fl_font( FL_HELVETICA, 14 );
  209. fl_color( fl_lighter( color ) );
  210. char pat[40];
  211. const nframes_t ts = x_to_ts( abs_x );
  212. // if ( draw_hms )
  213. {
  214. const double seconds = (double)ts / _sample_rate;
  215. int S = (int)seconds;
  216. int M = S / 60; S -= M * 60;
  217. int H = M / 60; M -= H * 60;
  218. snprintf( pat, sizeof( pat ), "%d:%d:%d", H, M, S );
  219. }
  220. // else if ( draw_bbt )
  221. {
  222. /* const int bar = */
  223. /* const int beat; */
  224. /* const int tick = 0; */
  225. /* snprintf( pat, sizeof( pat ), "%d:%d:%d", bar, beat, tick ); */
  226. }
  227. fl_draw( pat, x, Y + 14 );
  228. }
  229. fl_color( bar );
  230. }
  231. else
  232. {
  233. if ( measure < 8 )
  234. continue;
  235. fl_color( beat );
  236. }
  237. fl_line( x, Y, x, Y + H );
  238. }
  239. }
  240. fl_line_style( FL_SOLID, 0 );
  241. }
  242. void
  243. Timeline::draw_measure_lines ( int X, int Y, int W, int H, Fl_Color color )
  244. {
  245. draw_measure( X, Y, W, H, color, false );
  246. }
  247. /** just like draw mesure lines except that it also draws the BBT values. */
  248. void
  249. Timeline::draw_measure_BBT ( int X, int Y, int W, int H, Fl_Color color )
  250. {
  251. draw_measure( X, Y, W, H, color, true );
  252. }
  253. void
  254. Timeline::xposition ( int X )
  255. {
  256. // _old_xposition = xoffset;
  257. xoffset = x_to_ts( X );
  258. damage( FL_DAMAGE_SCROLL );
  259. }
  260. void
  261. Timeline::yposition ( int Y )
  262. {
  263. // _old_yposition = _yposition;
  264. _yposition = Y;
  265. damage( FL_DAMAGE_SCROLL );
  266. }
  267. void
  268. Timeline::draw_clip ( void * v, int X, int Y, int W, int H )
  269. {
  270. Timeline *tl = (Timeline *)v;
  271. // printf( "draw_clip: %d,%d %dx%d\n", X, Y, W, H );
  272. fl_push_clip( X, Y, W, H );
  273. fl_color( rand() );
  274. fl_rectf( X, Y, X + W, Y + H );
  275. tl->draw_child( *tl->rulers );
  276. /* headers */
  277. fl_push_clip( tl->tracks->x(), tl->rulers->y() + tl->rulers->h(), Track::width(), tl->h() - tl->rulers->h() - tl->hscroll->h() );
  278. tl->draw_child( *tl->tracks );
  279. fl_pop_clip();
  280. /* track bodies */
  281. fl_push_clip( tl->tracks->x() + Track::width(), tl->rulers->y() + tl->rulers->h(), tl->tracks->w() - Track::width(), tl->h() - tl->rulers->h() - tl->hscroll->h() );
  282. tl->draw_child( *tl->tracks );
  283. fl_pop_clip();
  284. // tl->draw_child( *tl->tracks );
  285. fl_pop_clip();
  286. }
  287. // static unsigned char *rect_image;
  288. void
  289. Timeline::resize ( int X, int Y, int W, int H )
  290. {
  291. Fl_Overlay_Window::resize( X, Y, W, H );
  292. /* why is this necessary? */
  293. rulers->resize( Track::width(), 0, W, rulers->h() );
  294. }
  295. void
  296. Timeline::draw ( void )
  297. {
  298. int X, Y, W, H;
  299. int bdx = 0;
  300. int bdw = 0;
  301. /* FIXME: hack to avoid clobbering the box corners of tracks. */
  302. if ( tracks->children() )
  303. {
  304. bdx = Fl::box_dx( tracks->child( 0 )->box() );
  305. bdw = Fl::box_dw( tracks->child( 0 )->box() );
  306. }
  307. X = tracks->x() + bdx + 1;
  308. Y = tracks->y();
  309. W = tracks->w() - bdw - 1;
  310. H = tracks->h();
  311. /* if ( damage() & FL_DAMAGE_USER1 ) */
  312. /* { */
  313. /* /\* save the rectangle so we can draw it (darkened) in the overlay *\/ */
  314. /* Rectangle &r = _selection; */
  315. /* make_current(); */
  316. /* rect_image = fl_read_image( NULL, r.x, r.y, r.w, r.h, 0 ); */
  317. /* return; */
  318. /* } */
  319. if ( (damage() & FL_DAMAGE_ALL)
  320. ||
  321. damage() & FL_DAMAGE_EXPOSE )
  322. {
  323. draw_box( box(), 0, 0, w(), h(), color() );
  324. fl_push_clip( 0, rulers->y(), w(), rulers->h() );
  325. draw_child( *rulers );
  326. fl_pop_clip();
  327. fl_push_clip( tracks->x(), rulers->y() + rulers->h(), tracks->w(), hscroll->y() - (rulers->y() + rulers->h()) );
  328. draw_child( *tracks );
  329. fl_pop_clip();
  330. draw_child( *hscroll );
  331. draw_child( *vscroll );
  332. redraw_overlay();
  333. /* Rectangle &r = _selection; */
  334. /* unsigned char *data = fl_read_image( NULL, r.x, r.y, r.w, r.h, 0 ); */
  335. /* Fl_RGB_Image bi( data, r.w, r.h, 3 ); */
  336. /* bi.color_average( FL_BLACK, 0.50f ); */
  337. /* bi.draw( r.x, r.y ); */
  338. /* delete[] data; */
  339. /* if ( r.w && r.h ) */
  340. /* { */
  341. /* const unsigned char data[] = { 0, 127, 0, 96, */
  342. /* 0, 96, 0, 127 }; */
  343. /* Fl_RGB_Image bi( data, 2, 2, 2 ); */
  344. /* Fl_Image *bi2 = bi.copy( r.w, r.h ); */
  345. /* bi2->draw( r.x, r.y ); */
  346. /* delete bi2; */
  347. /* } */
  348. return;
  349. }
  350. if ( damage() & FL_DAMAGE_CHILD )
  351. {
  352. // draw_box( box(), 0, 0, w(), h(), color() );
  353. fl_push_clip( rulers->x(), rulers->y(), rulers->w() - vscroll->w(), rulers->h() );
  354. update_child( *rulers );
  355. fl_pop_clip();
  356. fl_push_clip( tracks->x(), rulers->y() + rulers->h(), tracks->w(), hscroll->y() - (rulers->y() + rulers->h()) );
  357. update_child( *tracks );
  358. fl_pop_clip();
  359. update_child( *hscroll );
  360. update_child( *vscroll );
  361. }
  362. if ( damage() & FL_DAMAGE_SCROLL )
  363. {
  364. int dx = ts_to_x( _old_xposition ) - ts_to_x( xoffset );
  365. int dy = _old_yposition - _yposition;
  366. if ( ! dy )
  367. fl_scroll( X + Track::width(), rulers->y(), rulers->w() - Fl::box_dw( rulers->child(0)->box() ), rulers->h(), dx, 0, draw_clip, this );
  368. Y = rulers->y() + rulers->h();
  369. H = h() - rulers->h() - hscroll->h();
  370. if ( dy == 0 )
  371. fl_scroll( X + Track::width(), Y, W - Track::width(), H, dx, dy, draw_clip, this );
  372. else
  373. fl_scroll( X, Y, W, H, dx, dy, draw_clip, this );
  374. _old_xposition = xoffset;
  375. _old_yposition = _yposition;
  376. }
  377. }
  378. void
  379. Timeline::draw_playhead ( void )
  380. {
  381. int x = ( ts_to_x( transport->frame ) - ts_to_x( xoffset ) ) + tracks->x() + Track::width();
  382. if ( x < tracks->x() + Track::width() || x > tracks->x() + tracks->w() )
  383. return;
  384. fl_color( FL_RED );
  385. int y = rulers->y() + rulers->h();
  386. int h = this->h() - hscroll->h();
  387. fl_rectf( x - 2, y, 5, 2 );
  388. fl_line( x, y, x, h );
  389. fl_color( fl_darker( FL_RED ) );
  390. fl_line( x - 1, y, x - 1, h );
  391. fl_color( FL_BLACK );
  392. fl_line( x + 1, y, x + 1, h );
  393. }
  394. void
  395. Timeline::redraw_playhead ( void )
  396. {
  397. static nframes_t last_playhead = -1;
  398. if ( last_playhead != transport->frame )
  399. {
  400. redraw_overlay();
  401. last_playhead = transport->frame;
  402. }
  403. }
  404. /** called so many times a second to redraw the playhead etc. */
  405. void
  406. Timeline::update_cb ( void *arg )
  407. {
  408. Fl::repeat_timeout( UPDATE_FREQ, update_cb, arg );
  409. Timeline *tl = (Timeline *)arg;
  410. tl->redraw_playhead();
  411. }
  412. void
  413. Timeline::draw_overlay ( void )
  414. {
  415. draw_playhead();
  416. if ( ! ( _selection.w && _selection.h ) )
  417. return;
  418. fl_push_clip( tracks->x() + Track::width(), rulers->y() + rulers->h(), tracks->w() - Track::width(), h() - rulers->h() - hscroll->h() );
  419. const Rectangle &r = _selection;
  420. fl_color( FL_BLACK );
  421. fl_line_style( FL_SOLID, 2 );
  422. fl_rect( r.x + 2, r.y + 2, r.w, r.h );
  423. fl_color( FL_MAGENTA );
  424. fl_line_style( FL_DASH, 2 );
  425. fl_rect( r.x, r.y, r.w, r.h );
  426. fl_line( r.x, r.y, r.x + r.w, r.y + r.h );
  427. fl_line( r.x + r.w, r.y, r.x, r.y + r.h );
  428. /* fl_overlay_rect( r.x, r.y, r.w, r.h ); */
  429. fl_line_style( FL_SOLID, 0 );
  430. /* const unsigned char data[] = { 127, 127, 127, 96, */
  431. /* 127, 96, 127, 40 }; */
  432. /* Fl_RGB_Image bi( data, 2, 2, 2 ); */
  433. /* Fl_Image *bi2 = bi.copy( r.w, r.h ); */
  434. /* bi2->draw( r.x, r.y ); */
  435. /* delete bi2; */
  436. /* unsigned char *data = fl_read_image( NULL, r.x, r.y, r.w, r.h, 0 ); */
  437. /* Fl_RGB_Image bi( rect_image, r.w, r.h, 3 ); */
  438. /* bi.color_average( FL_BLACK, 0.50f ); */
  439. /* bi.draw( r.x, r.y ); */
  440. /* delete[] rect_image; */
  441. /* rect_image = NULL; */
  442. fl_pop_clip();
  443. }
  444. // #include "Sequence_Widget.H"
  445. /** select all widgets in inside rectangle /r/ */
  446. void
  447. Timeline::select( const Rectangle &r )
  448. {
  449. const int Y = r.y;
  450. for ( int i = tracks->children(); i-- ; )
  451. {
  452. Track *t = (Track*)tracks->child( i );
  453. if ( ! ( t->y() > Y + r.h || t->y() + t->h() < Y ) )
  454. t->track()->select_range( r.x, r.w );
  455. }
  456. }
  457. int
  458. Timeline::handle ( int m )
  459. {
  460. static Drag *drag = NULL;
  461. switch ( m )
  462. {
  463. case FL_KEYBOARD:
  464. {
  465. switch ( Fl::event_key() )
  466. {
  467. case FL_Delete:
  468. {
  469. Sequence_Widget::delete_selected();
  470. return 1;
  471. }
  472. /* case FL_Home: */
  473. /* transport->locate( 0 ); */
  474. /* return 1; */
  475. /* case ' ': */
  476. /* transport->toggle(); */
  477. /* return 1; */
  478. case 'p':
  479. {
  480. int X = Fl::event_x() - Track::width();
  481. if ( X > 0 )
  482. {
  483. transport->locate( xoffset + x_to_ts( X ) );
  484. }
  485. return 1;
  486. }
  487. default:
  488. return Fl_Overlay_Window::handle( m );
  489. }
  490. return 0;
  491. }
  492. default:
  493. {
  494. int r = Fl_Overlay_Window::handle( m );
  495. if ( m != FL_RELEASE && r )
  496. return r;
  497. const int X = Fl::event_x();
  498. const int Y = Fl::event_y();
  499. switch ( m )
  500. {
  501. case FL_PUSH:
  502. {
  503. take_focus();
  504. if ( Fl::event_button1() )
  505. {
  506. assert( ! drag );
  507. drag = new Drag( X - x(), Y - y() );
  508. _selection.x = drag->x;
  509. _selection.y = drag->y;
  510. }
  511. else if ( Fl::event_button3() )
  512. {
  513. Fl_Menu_Item menu[] =
  514. {
  515. { "Add Track", 0, 0, 0, FL_SUBMENU },
  516. { "Audio", 0, 0, 0 },
  517. { 0 },
  518. { 0 },
  519. };
  520. const Fl_Menu_Item *r = menu->popup( X, Y, "Timeline" );
  521. if ( r == &menu[1] )
  522. {
  523. /* FIXME: prompt for I/O config? */
  524. Loggable::block_start();
  525. /* add audio track */
  526. char *name = get_unique_track_name( "Audio" );
  527. Track *t = new Track( name );
  528. add_track( t );
  529. Sequence *o = new Audio_Sequence( t );
  530. new Control_Sequence( t );
  531. t->track( o );
  532. /* t->add( new Control_Sequence( t ); */
  533. t->color( (Fl_Color)rand() );
  534. Loggable::block_end();
  535. }
  536. }
  537. else
  538. return 0;
  539. break;
  540. }
  541. case FL_DRAG:
  542. {
  543. int ox = X - drag->x;
  544. int oy = Y - drag->y;
  545. if ( ox < 0 )
  546. _selection.x = X;
  547. if ( oy < 0 )
  548. _selection.y = Y;
  549. _selection.w = abs( ox );
  550. _selection.h = abs( oy );
  551. break;
  552. }
  553. case FL_RELEASE:
  554. {
  555. delete drag;
  556. drag = NULL;
  557. select( _selection );
  558. _selection.w = _selection.h = 0;
  559. break;
  560. }
  561. default:
  562. return 0;
  563. break;
  564. }
  565. redraw_overlay();
  566. return 1;
  567. }
  568. }
  569. }
  570. Track *
  571. Timeline::track_by_name ( const char *name )
  572. {
  573. for ( int i = tracks->children(); i-- ; )
  574. {
  575. Track *t = (Track*)tracks->child( i );
  576. if ( ! strcmp( name, t->name() ) )
  577. return t;
  578. }
  579. return NULL;
  580. }
  581. char *
  582. Timeline::get_unique_track_name ( const char *name )
  583. {
  584. char pat[256];
  585. strcpy( pat, name );
  586. for ( int i = 1; track_by_name( pat ); ++i )
  587. snprintf( pat, sizeof( pat ), "%s.%d", name, i );
  588. return strdup( pat );
  589. }
  590. void
  591. Timeline::add_track ( Track *track )
  592. {
  593. printf( "added new track to the timeline\n" );
  594. /* FIXME: do locking */
  595. tracks->add( track );
  596. /* FIXME: why is this necessary? doesn't the above add do DAMAGE_CHILD? */
  597. redraw();
  598. }
  599. void
  600. Timeline::remove_track ( Track *track )
  601. {
  602. printf( "removed track from the timeline\n" );
  603. /* FIXME: do locking */
  604. /* FIXME: what to do about track contents? */
  605. tracks->remove( track );
  606. /* FIXME: why is this necessary? doesn't the above add do DAMAGE_CHILD? */
  607. redraw();
  608. }
  609. /**********/
  610. /* Engine */
  611. /**********/
  612. /** call process() on each track header */
  613. nframes_t
  614. Timeline::process ( nframes_t nframes )
  615. {
  616. for ( int i = tracks->children(); i-- ; )
  617. {
  618. Track *t = (Track*)tracks->child( i );
  619. t->process( nframes );
  620. }
  621. /* FIXME: BOGUS */
  622. return nframes;
  623. }
  624. /* THREAD: RT */
  625. void
  626. Timeline::seek ( nframes_t frame )
  627. {
  628. for ( int i = tracks->children(); i-- ; )
  629. {
  630. Track *t = (Track*)tracks->child( i );
  631. t->seek( frame );
  632. }
  633. }
  634. /* THREAD: RT */
  635. int
  636. Timeline::seek_pending ( void )
  637. {
  638. int r = 0;
  639. for ( int i = tracks->children(); i-- ; )
  640. {
  641. Track *t = (Track*)tracks->child( i );
  642. if ( t->playback_ds )
  643. r += t->playback_ds->buffer_percent() < 50;
  644. }
  645. }