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.

186 lines
5.0KB

  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 "const.h"
  39. Timeline timeline;
  40. void
  41. cb_scroll ( Fl_Widget *w, void *v )
  42. {
  43. Scalebar *sb = (Scalebar*)w;
  44. timeline.fpp = sb->zoom() * 256;
  45. timeline.fpp = max( min( timeline.fpp, 4096.0f ), (float)2 );
  46. int maxx = timeline.ts_to_x( timeline.length );
  47. sb->range( 0, maxx );
  48. // sb->value( sb->value(), maxx
  49. // sb->slider_size( sb->w() / maxx );
  50. // ((Fl_Scrollbar*)sb)->value( sb->value(), 60, 10, maxx );
  51. timeline.xoffset = timeline.x_to_ts( sb->value() );
  52. // timeline.tracks->redraw();
  53. timeline.scroll->redraw();
  54. printf( "%lu\n", timeline.xoffset );
  55. for ( int i = timeline.tracks->children(); i-- ; )
  56. {
  57. Fl_Group *track = (Fl_Group*)timeline.tracks->child( i );
  58. track->damage( FL_DAMAGE_SCROLL );
  59. }
  60. /* /\* for ( int j = track->children(); j-- ; ) *\/ */
  61. /* /\* ((Region*)(track->child( j )))->resize(); *\/ */
  62. /* /\* } *\/ */
  63. }
  64. int
  65. main ( int argc, char **argv )
  66. {
  67. Fl_Double_Window *main_window = new Fl_Double_Window( 0, 0, 800, 600 );
  68. timeline.scroll = new Fl_Scroll( 0, 0, 800, 600 - 24 );
  69. timeline.scroll->type( Fl_Scroll::VERTICAL );
  70. timeline.fpp = 256;
  71. timeline._beats_per_minute = 120;
  72. timeline.length = 48000 * 60 * 2;
  73. timeline.sample_rate = 44100;
  74. timeline.tracks = new Fl_Pack( 0, 0, 800, 5000 );
  75. timeline.tracks->type( Fl_Pack::VERTICAL );
  76. timeline.tracks->spacing( 20 );
  77. Fl::get_system_colors();
  78. Fl::scheme( "plastic" );
  79. // Fl_Group *pack = new Fl_Group( 0, 0, 5000, 600 );
  80. {
  81. Tempo_Track *tempo_track = new Tempo_Track( 100, 0, 800, 24 );
  82. tempo_track->label( "tempo map" );
  83. tempo_track->add( new Tempo_Point( 0, 120 ) );
  84. tempo_track->add( new Tempo_Point( 56000, 250 ) );
  85. tempo_track->end();
  86. timeline.tempo_track = tempo_track;
  87. }
  88. Track *track1 = new Audio_Track( 40, 0, 800, 100 );
  89. // pack->type( Fl_Pack::VERTICAL );
  90. // pack->box( FL_DOWN_BOX );
  91. // Region *wave = new Region( 0, 0, 5000, 100, "foo" );
  92. Region *wave = new Region( Clip::from_file( "streambass8.wav" ) );
  93. // wave->resize( 0, 0, 500, 100 );
  94. wave->offset( 1024 );
  95. wave->end( 3000 );
  96. /* wave->color( FL_CYAN ); */
  97. /* wave->selection_color( fl_darker( FL_GRAY ) ); */
  98. /* wave->selection_color( FL_GREEN ); */
  99. track1->add( wave );
  100. Region *wave3 = new Region( *wave );
  101. wave3->offset( 4000 );
  102. track1->add( wave3 );
  103. track1->end();
  104. Track *track2 = new Audio_Track( 40, 0, 5000, 100 );
  105. // Region *wave2 = new Region( 0, 0, 350, 100, "bar" );
  106. Region *wave2 = new Region( *wave );
  107. /* wave2->peaks( peaks ); */
  108. /* wave2->start( 300 ); */
  109. /* wave2->end( len ); */
  110. track2->add( wave2 );
  111. track2->end();
  112. track1->next( track2 );
  113. track2->prev( track1 );
  114. timeline.tracks->end();
  115. timeline.scroll->end();
  116. timeline.scrollbar = new Scalebar( 0, 600 - 24, 800, 24 );
  117. timeline.scrollbar->range( 0, 48000 * 2 );
  118. timeline.scrollbar->type( 1 );
  119. timeline.scrollbar->callback( cb_scroll, 0 );
  120. main_window->end();
  121. main_window->show();
  122. /* wave->redraw(); */
  123. Fl::run();
  124. }