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.

113 lines
2.8KB

  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 "Tempo_Point.H"
  19. #include "Tempo_Track.H"
  20. #include "Timeline.H" // for timeline->tempo_track
  21. char **
  22. Tempo_Point::get ( void )
  23. {
  24. char **sa = (char**)malloc( sizeof( char* ) * 4 );
  25. int i = 0;
  26. asprintf( &sa[i++], ":x %lu", _r->offset );
  27. asprintf( &sa[i++], ":tempo %.2f", _tempo );
  28. sa[i] = NULL;
  29. return sa;
  30. }
  31. void
  32. Tempo_Point::set ( char **sa )
  33. {
  34. for ( int i = 0; sa[i]; ++i )
  35. {
  36. char *s = sa[i];
  37. strtok( s, " " );
  38. char *v = s + strlen( s ) + 1;
  39. if ( ! strcmp( s, ":x" ) )
  40. _r->offset = atol( v );
  41. else if ( ! strcmp( s, ":tempo" ) )
  42. _tempo = atof( v );
  43. /* FIXME: we need to add this to the time track on creation!!! */
  44. timeline->tempo_track->add( this );
  45. free( s );
  46. }
  47. free( sa );
  48. timeline->redraw();
  49. _make_label();
  50. }
  51. /* for loggable */
  52. Loggable *
  53. Tempo_Point::create ( char **sa )
  54. {
  55. Tempo_Point *r = new Tempo_Point;
  56. r->set( sa );
  57. return (Loggable *)r;
  58. }
  59. Tempo_Point::Tempo_Point ( nframes_t when, float bpm )
  60. {
  61. _tempo = bpm;
  62. _r->offset = when;
  63. _make_label();
  64. log_create();
  65. }
  66. Tempo_Point::~Tempo_Point ( )
  67. {
  68. if ( _label ) delete[] _label;
  69. log_destroy();
  70. }
  71. int
  72. Tempo_Point::handle ( int m )
  73. {
  74. int r = Track_Widget::handle( m );
  75. if ( m == FL_RELEASE )
  76. {
  77. _track->sort();
  78. timeline->redraw();
  79. }
  80. return r;
  81. }