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.

191 lines
5.1KB

  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. Fl_Color velocity_colors[128];
  34. #include "Track.H"
  35. #include "Timeline.H"
  36. #include "const.h"
  37. void
  38. init_colors ( void )
  39. {
  40. for ( int i = 128; i--; )
  41. velocity_colors[i] = fl_rgb_color( 23, 255 - i * 2, 32 );
  42. }
  43. Timeline timeline;
  44. void
  45. cb_zoom ( Fl_Widget *w, void *v )
  46. {
  47. timeline.fpp = ((Fl_Slider*)w)->value();
  48. /* for ( int i = timeline.tracks->children(); i-- ; ) */
  49. /* { */
  50. /* Fl_Group *track = (Fl_Group*)timeline.tracks->child( i ); */
  51. /* for ( int j = track->children(); j-- ; ) */
  52. /* ((Region*)(track->child( j )))->resize(); */
  53. /* } */
  54. timeline.scroll->redraw();
  55. if ( timeline.fpp < FRAMES_PER_PEAK )
  56. w->selection_color( FL_RED );
  57. else
  58. w->selection_color( FL_GRAY );
  59. printf( "%f\n", timeline.fpp );
  60. }
  61. void
  62. cb_scroll ( Fl_Widget *w, void *v )
  63. {
  64. timeline.xoffset = ((Fl_Scrollbar*)w)->value();
  65. timeline.tracks->redraw();
  66. timeline.scroll->redraw();
  67. /* for ( int i = timeline.tracks->children(); i-- ; ) */
  68. /* { */
  69. /* Fl_Group *track = (Fl_Group*)timeline.tracks->child( i ); */
  70. /* track-> */
  71. /* } */
  72. /* /\* for ( int j = track->children(); j-- ; ) *\/ */
  73. /* /\* ((Region*)(track->child( j )))->resize(); *\/ */
  74. /* /\* } *\/ */
  75. }
  76. int
  77. main ( int argc, char **argv )
  78. {
  79. init_colors();
  80. Fl_Double_Window *main_window = new Fl_Double_Window( 0, 0, 800, 600 );
  81. timeline.scroll = new Fl_Scroll( 0, 24, 800, 600 - (24 * 2) );
  82. timeline.scroll->type( Fl_Scroll::VERTICAL );
  83. timeline.fpp = 256;
  84. timeline.sample_rate = 44100;
  85. timeline.tracks = new Fl_Pack( 0, 0, 800, 5000 );
  86. timeline.tracks->type( Fl_Pack::VERTICAL );
  87. timeline.tracks->spacing( 20 );
  88. Fl::get_system_colors();
  89. Fl::scheme( "plastic" );
  90. // Fl_Group *pack = new Fl_Group( 0, 0, 5000, 600 );
  91. Track *track1 = new Track( 40, 0, 800, 100 );
  92. // pack->type( Fl_Pack::VERTICAL );
  93. // pack->box( FL_DOWN_BOX );
  94. // Region *wave = new Region( 0, 0, 5000, 100, "foo" );
  95. Region *wave = new Region( Clip::from_file( "streambass8.wav" ) );
  96. // wave->resize( 0, 0, 500, 100 );
  97. wave->offset( 1024 );
  98. wave->end( 3000 );
  99. /* wave->color( FL_CYAN ); */
  100. /* wave->selection_color( fl_darker( FL_GRAY ) ); */
  101. /* wave->selection_color( FL_GREEN ); */
  102. track1->add( wave );
  103. Region *wave3 = new Region( *wave );
  104. wave3->offset( 4000 );
  105. track1->add( wave3 );
  106. track1->end();
  107. Track *track2 = new Track( 40, 0, 5000, 100 );
  108. // Region *wave2 = new Region( 0, 0, 350, 100, "bar" );
  109. Region *wave2 = new Region( *wave );
  110. /* wave2->peaks( peaks ); */
  111. /* wave2->start( 300 ); */
  112. /* wave2->end( len ); */
  113. track2->add( wave2 );
  114. track2->end();
  115. track1->next( track2 );
  116. track2->prev( track1 );
  117. timeline.tracks->end();
  118. timeline.scroll->end();
  119. Fl_Slider *zoom_slider = new Fl_Slider( 0, 0, 800, 24 );
  120. zoom_slider->type( FL_HOR_SLIDER );
  121. zoom_slider->callback( cb_zoom, 0 );
  122. zoom_slider->range( 2, 4096 );
  123. zoom_slider->step( 1 );
  124. zoom_slider->value( 256 );
  125. timeline.scrollbar = new Fl_Scrollbar( 0, 600 - 24, 800, 24 );
  126. timeline.scrollbar->range( 0, 293847234 );
  127. timeline.scrollbar->type( 1 );
  128. timeline.scrollbar->step( 1 );
  129. timeline.scrollbar->callback( cb_scroll, 0 );
  130. main_window->end();
  131. main_window->show();
  132. /* wave->redraw(); */
  133. Fl::run();
  134. }