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.

108 lines
3.3KB

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