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.

223 lines
5.7KB

  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 <FL/Fl.H>
  19. #include <FL/Fl_Window.H>
  20. #include <FL/Fl_Double_Window.H>
  21. #include <FL/Fl_Scroll.H>
  22. // #include <FL/Fl_Scrollbar.H>
  23. #include <FL/Fl_Pack.H>
  24. #include <FL/Fl_Group.H>
  25. #include <FL/Fl_Slider.H>
  26. #include "Scalebar.H"
  27. // #include "Waveform.H"
  28. #include "Region.H"
  29. #include <stdio.h>
  30. #include <unistd.h>
  31. #include <sys/stat.h>
  32. #include <stdlib.h>
  33. #include <string.h>
  34. #include "Track.H"
  35. #include "Audio_Track.H"
  36. #include "Timeline.H"
  37. #include "Tempo_Track.H"
  38. #include "Time_Track.H"
  39. #include "const.h"
  40. Timeline timeline;
  41. void
  42. cb_scroll ( Fl_Widget *w, void *v )
  43. {
  44. Scalebar *sb = (Scalebar*)w;
  45. timeline.fpp = sb->zoom() * 256;
  46. timeline.fpp = max( min( timeline.fpp, 4096.0f ), (float)2 );
  47. int maxx = timeline.ts_to_x( timeline.length );
  48. sb->range( 0, maxx );
  49. // sb->value( sb->value(), maxx
  50. // sb->slider_size( sb->w() / maxx );
  51. // ((Fl_Scrollbar*)sb)->value( sb->value(), 60, 10, maxx );
  52. timeline.position( sb->value() );
  53. /* timeline.xoffset = timeline.x_to_ts( sb->value() ); */
  54. /* // timeline.tracks->redraw(); */
  55. /* timeline.scroll->redraw(); */
  56. printf( "%lu\n", timeline.xoffset );
  57. for ( int i = timeline.tracks->children(); i-- ; )
  58. {
  59. Fl_Group *track = (Fl_Group*)timeline.tracks->child( i );
  60. track->damage( FL_DAMAGE_SCROLL );
  61. }
  62. for ( int i = timeline.rulers->children(); i-- ; )
  63. {
  64. Fl_Group *track = (Fl_Group*)timeline.rulers->child( i );
  65. track->damage( FL_DAMAGE_SCROLL );
  66. }
  67. /* /\* for ( int j = track->children(); j-- ; ) *\/ */
  68. /* /\* ((Region*)(track->child( j )))->resize(); *\/ */
  69. /* /\* } *\/ */
  70. }
  71. int
  72. main ( int argc, char **argv )
  73. {
  74. Fl_Double_Window *main_window = new Fl_Double_Window( 0, 0, 800, 600 );
  75. Fl::get_system_colors();
  76. Fl::scheme( "plastic" );
  77. {
  78. Fl_Pack *o = new Fl_Pack( 0, 0, 800, 24 * 2, "rulers" );
  79. o->type( Fl_Pack::VERTICAL );
  80. {
  81. Tempo_Track *o = new Tempo_Track( 0, 0, 800, 24 );
  82. o->color( FL_RED );
  83. // tempo_track->label( "tempo map" );
  84. o->add( new Tempo_Point( 0, 120 ) );
  85. o->add( new Tempo_Point( 56000, 250 ) );
  86. o->end();
  87. timeline.tempo_track = o;
  88. }
  89. {
  90. Time_Track *o = new Time_Track( 0, 24, 800, 24 );
  91. o->color( fl_color_average( FL_RED, FL_WHITE, 0.50f ) );
  92. o->add( new Time_Point( 0, 4, 4 ) );
  93. o->add( new Time_Point( 345344, 6, 8 ) );
  94. o->end();
  95. timeline.time_track = o;
  96. }
  97. timeline.rulers = o;
  98. o->end();
  99. }
  100. timeline.scroll = new Fl_Scroll( 0, 24 * 2, 800, 600 - (24 * 3) );
  101. timeline.scroll->type( Fl_Scroll::VERTICAL );
  102. timeline.fpp = 256;
  103. timeline._beats_per_minute = 120;
  104. timeline.length = 48000 * 60 * 2;
  105. timeline.sample_rate = 44100;
  106. timeline.tracks = new Fl_Pack( 0, 0, 800, 5000 );
  107. timeline.tracks->type( Fl_Pack::VERTICAL );
  108. timeline.tracks->spacing( 20 );
  109. // Fl_Group *pack = new Fl_Group( 0, 0, 5000, 600 );
  110. Track *track1 = new Audio_Track( 40, 0, 800, 100 );
  111. // pack->type( Fl_Pack::VERTICAL );
  112. // pack->box( FL_DOWN_BOX );
  113. // Region *wave = new Region( 0, 0, 5000, 100, "foo" );
  114. Region *wave = new Region( Clip::from_file( "streambass8.wav" ) );
  115. // wave->resize( 0, 0, 500, 100 );
  116. wave->offset( 1024 );
  117. wave->end( 3000 );
  118. /* wave->color( FL_CYAN ); */
  119. /* wave->selection_color( fl_darker( FL_GRAY ) ); */
  120. /* wave->selection_color( FL_GREEN ); */
  121. track1->add( wave );
  122. Region *wave3 = new Region( *wave );
  123. wave3->offset( 4000 );
  124. track1->add( wave3 );
  125. track1->end();
  126. Track *track2 = new Audio_Track( 40, 0, 5000, 100 );
  127. // Region *wave2 = new Region( 0, 0, 350, 100, "bar" );
  128. Region *wave2 = new Region( *wave );
  129. /* wave2->peaks( peaks ); */
  130. /* wave2->start( 300 ); */
  131. /* wave2->end( len ); */
  132. track2->add( wave2 );
  133. track2->end();
  134. track1->next( track2 );
  135. track2->prev( track1 );
  136. timeline.tracks->end();
  137. timeline.scroll->end();
  138. timeline.scrollbar = new Scalebar( 0, 600 - 24, 800, 24 );
  139. timeline.scrollbar->range( 0, 48000 * 2 );
  140. timeline.scrollbar->type( 1 );
  141. timeline.scrollbar->callback( cb_scroll, 0 );
  142. main_window->end();
  143. main_window->show();
  144. /* wave->redraw(); */
  145. Fl::run();
  146. }