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.

102 lines
3.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. #pragma once
  19. #include "Sequence.H"
  20. #include "Tempo_Point.H"
  21. #include <list>
  22. class Tempo_Sequence : public Sequence
  23. {
  24. public:
  25. Fl_Cursor cursor ( void ) const { return FL_CURSOR_DEFAULT; }
  26. Tempo_Sequence ( int X, int Y, int W, int H ) : Sequence ( X, Y, W, H )
  27. {
  28. // box( FL_DOWN_BOX );
  29. }
  30. /** return a pointer to the closest tempo point *before* /when/ */
  31. Tempo_Point *
  32. at ( nframes_t when )
  33. {
  34. for ( std::list <Sequence_Widget *>::const_reverse_iterator i = _widgets.rbegin();
  35. i != _widgets.rend(); i++ )
  36. if ( (*i)->offset() < when )
  37. return ((Tempo_Point*)(*i));
  38. return NULL;
  39. }
  40. float
  41. beats_per_minute ( nframes_t when )
  42. {
  43. // sort();
  44. Tempo_Point *p = at( when );
  45. if ( p )
  46. return p->tempo();
  47. else
  48. return 120.0;
  49. }
  50. void
  51. beats_per_minute ( nframes_t when, float bpm )
  52. {
  53. add( new Tempo_Point( when, bpm ) );
  54. sort();
  55. }
  56. int
  57. handle ( int m )
  58. {
  59. int r = Sequence::handle( m );
  60. if ( r )
  61. return r;
  62. switch ( m )
  63. {
  64. case FL_PUSH:
  65. if ( Fl::event_button1() )
  66. {
  67. static float t = 120.0f;
  68. if ( Tempo_Point::edit( &t ) )
  69. {
  70. add( new Tempo_Point( timeline->x_to_offset( Fl::event_x() ), t ) );
  71. timeline->redraw();
  72. }
  73. return 0;
  74. }
  75. default:
  76. return 0;
  77. }
  78. }
  79. };