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.

204 lines
5.4KB

  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 "Waveform.H"
  27. #include "Region.H"
  28. #include <stdio.h>
  29. #include <unistd.h>
  30. #include <sys/stat.h>
  31. #include <stdlib.h>
  32. #include <string.h>
  33. #include "Track.H"
  34. #include "Audio_Track.H"
  35. #include "Timeline.H"
  36. #include "const.h"
  37. Timeline timeline;
  38. void
  39. cb_zoom ( Fl_Widget *w, void *v )
  40. {
  41. timeline.fpp = ((Fl_Slider*)w)->value();
  42. /* for ( int i = timeline.tracks->children(); i-- ; ) */
  43. /* { */
  44. /* Fl_Group *track = (Fl_Group*)timeline.tracks->child( i ); */
  45. /* for ( int j = track->children(); j-- ; ) */
  46. /* ((Region*)(track->child( j )))->resize(); */
  47. /* } */
  48. timeline.scroll->redraw();
  49. if ( timeline.fpp < FRAMES_PER_PEAK )
  50. w->selection_color( FL_RED );
  51. else
  52. w->selection_color( FL_GRAY );
  53. printf( "%f\n", timeline.fpp );
  54. }
  55. void
  56. cb_scroll ( Fl_Widget *w, void *v )
  57. {
  58. timeline.xoffset = ((Fl_Slider*)w)->value();
  59. // timeline.tracks->redraw();
  60. timeline.scroll->redraw();
  61. printf( "%lu\n", timeline.xoffset );
  62. for ( int i = timeline.tracks->children(); i-- ; )
  63. {
  64. Fl_Group *track = (Fl_Group*)timeline.tracks->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. timeline.scroll = new Fl_Scroll( 0, 24, 800, 600 - (24 * 2) );
  76. timeline.scroll->type( Fl_Scroll::VERTICAL );
  77. timeline.fpp = 256;
  78. timeline._beats_per_minute = 120;
  79. timeline.beats_per_minute( 0, 120 );
  80. timeline.beats_per_minute( 48000, 250 );
  81. timeline.beats_per_minute( 48000 * 4, 60 );
  82. timeline.sample_rate = 44100;
  83. timeline.tracks = new Fl_Pack( 0, 0, 800, 5000 );
  84. timeline.tracks->type( Fl_Pack::VERTICAL );
  85. timeline.tracks->spacing( 20 );
  86. Fl::get_system_colors();
  87. Fl::scheme( "plastic" );
  88. // Fl_Group *pack = new Fl_Group( 0, 0, 5000, 600 );
  89. {
  90. Track *tempo_track = new Track( 100, 0, 800, 24 );
  91. tempo_track->label( "tempo map" );
  92. tempo_track->add( new Tempo_Point( 0, 120 ) );
  93. tempo_track->add( new Tempo_Point( 56000, 250 ) );
  94. tempo_track->end();
  95. }
  96. Track *track1 = new Audio_Track( 40, 0, 800, 100 );
  97. // pack->type( Fl_Pack::VERTICAL );
  98. // pack->box( FL_DOWN_BOX );
  99. // Region *wave = new Region( 0, 0, 5000, 100, "foo" );
  100. Region *wave = new Region( Clip::from_file( "streambass8.wav" ) );
  101. // wave->resize( 0, 0, 500, 100 );
  102. wave->offset( 1024 );
  103. wave->end( 3000 );
  104. /* wave->color( FL_CYAN ); */
  105. /* wave->selection_color( fl_darker( FL_GRAY ) ); */
  106. /* wave->selection_color( FL_GREEN ); */
  107. track1->add( wave );
  108. Region *wave3 = new Region( *wave );
  109. wave3->offset( 4000 );
  110. track1->add( wave3 );
  111. track1->end();
  112. Track *track2 = new Audio_Track( 40, 0, 5000, 100 );
  113. // Region *wave2 = new Region( 0, 0, 350, 100, "bar" );
  114. Region *wave2 = new Region( *wave );
  115. /* wave2->peaks( peaks ); */
  116. /* wave2->start( 300 ); */
  117. /* wave2->end( len ); */
  118. track2->add( wave2 );
  119. track2->end();
  120. track1->next( track2 );
  121. track2->prev( track1 );
  122. timeline.tracks->end();
  123. timeline.scroll->end();
  124. Fl_Slider *zoom_slider = new Fl_Slider( 0, 0, 800, 24 );
  125. zoom_slider->type( FL_HOR_SLIDER );
  126. zoom_slider->callback( cb_zoom, 0 );
  127. zoom_slider->range( 2, 4096 );
  128. zoom_slider->step( 1 );
  129. zoom_slider->value( 256 );
  130. timeline.scrollbar = new Fl_Scrollbar( 0, 600 - 24, 800, 24 );
  131. timeline.scrollbar->range( 0, 48000 * 2 );
  132. timeline.scrollbar->type( 1 );
  133. timeline.scrollbar->step( 1 );
  134. timeline.scrollbar->callback( cb_scroll, 0 );
  135. main_window->end();
  136. main_window->show();
  137. /* wave->redraw(); */
  138. Fl::run();
  139. }