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.

149 lines
4.9KB

  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. #pragma once
  19. // class Track;
  20. // #include "Waveform.H"
  21. #include "Audio_File.H"
  22. #include "Track.H"
  23. #include "Timeline.H"
  24. #include <algorithm>
  25. using namespace std;
  26. /* Regions are "virtual" FLTK widgets; this is necessary because the
  27. * dimensions of real FLTK widgets are limited to 16-bits, which is
  28. * far too little for our purposes */
  29. #include "Track_Widget.H"
  30. #include "Loggable.H"
  31. /* got I hate C++ */
  32. #define __CLASS__ "Region"
  33. class Region : public Track_Widget
  34. {
  35. Audio_File *_clip; /* clip this region represents */
  36. float _scale; /* amplitude adjustment */
  37. static Fl_Boxtype _box;
  38. static Fl_Color _selection_color;
  39. static Fl_Color selection_color ( void ) { return _selection_color; }
  40. static void selection_color ( Fl_Color v ) { _selection_color = v; }
  41. enum trim_e { NO, LEFT, RIGHT };
  42. void trim ( enum trim_e t, int X );
  43. void init ( void );
  44. protected:
  45. const char *class_name ( void ) { return "Region"; }
  46. char ** log_dump ( void )
  47. {
  48. // char *r;
  49. char **sa = (char**)malloc( sizeof( char* ) * 6 );
  50. sa[5] = NULL;
  51. asprintf( &sa[0], ":x %lu", _offset );
  52. asprintf( &sa[1], ":l %lu", _start );
  53. asprintf( &sa[2], ":r %lu", _end );
  54. asprintf( &sa[3], ":selected %d", _selected );
  55. asprintf( &sa[4], ":gain %f", _scale );
  56. // asprintf( &sa[4], ":track 0x%X", _track->id() );
  57. // asprintf( &r, ":x %lu\n:l %lu\n:r %lu\n:selected %d\n:gain %f", _offset, _start, _end, _selected, _scale );
  58. return sa;
  59. }
  60. void
  61. set ( char **sa )
  62. {
  63. for ( int i = 0; sa[i]; ++i )
  64. {
  65. char *s = sa[i];
  66. strtok( s, " " );
  67. char *v = s + strlen( s ) + 1;
  68. if ( ! strcmp( s, ":x" ) )
  69. _offset = atol( v );
  70. else
  71. if ( ! strcmp( s, ":l" ) )
  72. _start = atol( v );
  73. else
  74. if ( ! strcmp( s, ":r" ) )
  75. _end = atol( v );
  76. else
  77. if ( ! strcmp( s, ":selected" ) )
  78. _selected = atoi( v );
  79. else
  80. if ( ! strcmp( s, ":gain" ) )
  81. _scale = atof( v );
  82. /* else */
  83. /* if ( ! strcmp( s, ":track" ) ) */
  84. /* { */
  85. /* int i; */
  86. /* sscanf( v, "%X", &i ); */
  87. /* Track *t = (Track*)Loggable::find( i ); */
  88. /* assert( t ); */
  89. /* t->add( this ); */
  90. /* } */
  91. free( s );
  92. }
  93. free( sa );
  94. _track->redraw();
  95. }
  96. public:
  97. Fl_Boxtype box ( void ) const { return Region::_box; }
  98. Fl_Align align ( void ) const { return (Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_BOTTOM /*| FL_ALIGN_CLIP*/ | FL_ALIGN_INSIDE); }
  99. Region ( const Region & rhs );
  100. Region ( Audio_File *c );
  101. int handle ( int m );
  102. void draw_box( int X, int Y, int W, int H );
  103. void draw ( int X, int Y, int W, int H );
  104. void resize ( void );
  105. void normalize ( void );
  106. void dump ( void );
  107. };
  108. #undef __CLASS__