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.

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