TempoSyncKnobModel.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 LMMS_EXPORT TempoSyncKnobModel : public FloatModel
  30. {
  31. Q_OBJECT
  32. MODEL_IS_VISITABLE
  33. public:
  34. enum TempoSyncMode
  35. {
  36. SyncNone,
  37. SyncDoubleWholeNote,
  38. SyncWholeNote,
  39. SyncHalfNote,
  40. SyncQuarterNote,
  41. SyncEighthNote,
  42. SyncSixteenthNote,
  43. SyncThirtysecondNote,
  44. SyncCustom
  45. } ;
  46. TempoSyncKnobModel( const float _val, const float _min,
  47. const float _max, const float _step,
  48. const float _scale, Model * _parent,
  49. const QString & _display_name = QString() );
  50. ~TempoSyncKnobModel() override;
  51. void saveSettings( QDomDocument & _doc, QDomElement & _this, const QString& name ) override;
  52. void loadSettings( const QDomElement & _this, const QString& name ) override;
  53. TempoSyncMode syncMode() const
  54. {
  55. return m_tempoSyncMode;
  56. }
  57. void setSyncMode( TempoSyncMode _new_mode );
  58. float scale() const
  59. {
  60. return m_scale;
  61. }
  62. void setScale( float _new_scale );
  63. signals:
  64. void syncModeChanged( TempoSyncMode _new_mode );
  65. void scaleChanged( float _new_scale );
  66. public slots:
  67. inline void disableSync()
  68. {
  69. setTempoSync( SyncNone );
  70. }
  71. void setTempoSync( int _note_type );
  72. void setTempoSync( QAction * _item );
  73. protected slots:
  74. void calculateTempoSyncTime( bpm_t _bpm );
  75. void updateCustom();
  76. private:
  77. TempoSyncMode m_tempoSyncMode;
  78. TempoSyncMode m_tempoLastSyncMode;
  79. float m_scale;
  80. MeterModel m_custom;
  81. friend class TempoSyncKnob;
  82. } ;
  83. #endif