TempoSyncKnobModel.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * TempoSyncKnobModel.h - adds bpm to ms conversion for knob class
  3. *
  4. * Copyright (c) 2005-2008 Danny McRae <khjklujn/at/yahoo.com>
  5. * Copyright (c) 2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  6. *
  7. * This file is part of LMMS - https://lmms.io
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2 of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public
  20. * License along with this program (see COPYING); if not, write to the
  21. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  22. * Boston, MA 02110-1301 USA.
  23. *
  24. */
  25. #ifndef TEMPO_SYNC_KNOB_MODEL_H
  26. #define TEMPO_SYNC_KNOB_MODEL_H
  27. #include "MeterModel.h"
  28. class QAction;
  29. class EXPORT TempoSyncKnobModel : public FloatModel
  30. {
  31. Q_OBJECT
  32. public:
  33. enum TempoSyncMode
  34. {
  35. SyncNone,
  36. SyncDoubleWholeNote,
  37. SyncWholeNote,
  38. SyncHalfNote,
  39. SyncQuarterNote,
  40. SyncEighthNote,
  41. SyncSixteenthNote,
  42. SyncThirtysecondNote,
  43. SyncCustom
  44. } ;
  45. TempoSyncKnobModel( const float _val, const float _min,
  46. const float _max, const float _step,
  47. const float _scale, Model * _parent,
  48. const QString & _display_name = QString() );
  49. virtual ~TempoSyncKnobModel();
  50. void saveSettings( QDomDocument & _doc, QDomElement & _this, const QString& name );
  51. void loadSettings( const QDomElement & _this, const QString& name );
  52. TempoSyncMode syncMode() const
  53. {
  54. return m_tempoSyncMode;
  55. }
  56. void setSyncMode( TempoSyncMode _new_mode );
  57. float scale() const
  58. {
  59. return m_scale;
  60. }
  61. void setScale( float _new_scale );
  62. signals:
  63. void syncModeChanged( TempoSyncMode _new_mode );
  64. void scaleChanged( float _new_scale );
  65. public slots:
  66. inline void disableSync()
  67. {
  68. setTempoSync( SyncNone );
  69. }
  70. void setTempoSync( int _note_type );
  71. void setTempoSync( QAction * _item );
  72. protected slots:
  73. void calculateTempoSyncTime( bpm_t _bpm );
  74. void updateCustom();
  75. private:
  76. TempoSyncMode m_tempoSyncMode;
  77. TempoSyncMode m_tempoLastSyncMode;
  78. float m_scale;
  79. MeterModel m_custom;
  80. friend class TempoSyncKnob;
  81. } ;
  82. #endif