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.

116 lines
3.2KB

  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 <stdio.h>
  19. #include <FL/Enumerations.H>
  20. #include <FL/Fl.H>
  21. #include <FL/fl_draw.H>
  22. #include "Timeline.H"
  23. // #include "Waveform.H"
  24. #include "Clip.H"
  25. // extern Timeline timeline;
  26. // #include "Timeline.H"
  27. #include <math.h>
  28. /* void */
  29. /* Waveform::draw ( void ) */
  30. /* { */
  31. /* int X, Y, W, H; */
  32. /* fl_clip_box( x(), y(), w(), h(), X, Y, W, H ); */
  33. /* draw( X, y(), W, h() ); */
  34. /* } */
  35. /** draw a portion of /clip/'s waveform. coordinates are the portion to draw */
  36. void
  37. draw_waveform ( int X, int Y, int W, int H, Clip *_clip, nframes_t _start, nframes_t _end, float _scale, Fl_Color color )
  38. {
  39. fl_push_clip( X, Y, W, H );
  40. int j;
  41. int start = timeline->ts_to_x( _start );
  42. {
  43. _clip->peaks()->fill_buffer( _start,
  44. _start + timeline->x_to_ts( W ) );
  45. }
  46. j = start;
  47. for ( int x = X; x < X + W; ++x, ++j )
  48. {
  49. Peak p = (*_clip->peaks())[ j ];
  50. int mid = Y + (H / 2);
  51. // FIXME: cache this stuff.
  52. fl_color( fl_color_average( FL_RED, color, fabs( p.max - p.min ) ) );
  53. p.max *= _scale;
  54. p.min *= _scale;
  55. if ( p.min < -1.0 || p.max > 1.0 )
  56. fl_color( FL_RED );
  57. fl_line( x, mid + (H / 2 * p.min), x, mid + (H / 2 * p.max) );
  58. }
  59. fl_color( fl_darker( fl_darker( color ) ) );
  60. fl_line_style( FL_SOLID, 2 );
  61. fl_begin_line();
  62. j = start;
  63. for ( int x = X; x < X + W; ++x, ++j )
  64. {
  65. Peak p = (*_clip->peaks())[ j ];
  66. p.min *= _scale;
  67. fl_vertex( x, Y + (H / 2) + ((float)H / 2 * p.min ));
  68. }
  69. fl_end_line();
  70. fl_begin_line();
  71. j = start;
  72. for ( int x = X; x < X + W; ++x, ++j )
  73. {
  74. Peak p = (*_clip->peaks())[ j ];
  75. p.max *= _scale;
  76. fl_vertex( x, Y + (H / 2) + ((float)H / 2 * p.max ));
  77. }
  78. fl_end_line();
  79. fl_line_style( FL_SOLID, 0 );
  80. fl_pop_clip();
  81. }