Microtuner.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Microtuner.h - manage tuning and scale information of an instrument
  3. *
  4. * Copyright (c) 2020 Martin Pavelek <he29.HS/at/gmail.com>
  5. *
  6. * This file is part of LMMS - https://lmms.io
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public
  19. * License along with this program (see COPYING); if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301 USA.
  22. *
  23. */
  24. #ifndef MICROTUNER_H
  25. #define MICROTUNER_H
  26. #include "AutomatableModel.h"
  27. #include "ComboBoxModel.h"
  28. #include "JournallingObject.h"
  29. #include "lmms_constants.h"
  30. #include "Note.h"
  31. class LMMS_EXPORT Microtuner : public Model, public JournallingObject
  32. {
  33. Q_OBJECT
  34. public:
  35. explicit Microtuner();
  36. bool enabled() const {return m_enabledModel.value();}
  37. bool keyRangeImport() const {return enabled() && m_keyRangeImportModel.value();}
  38. int currentScale() const {return m_scaleModel.value();}
  39. int currentKeymap() const {return m_keymapModel.value();}
  40. BoolModel *enabledModel() {return &m_enabledModel;}
  41. ComboBoxModel *scaleModel() {return &m_scaleModel;}
  42. ComboBoxModel *keymapModel() {return &m_keymapModel;}
  43. BoolModel *keyRangeImportModel() {return &m_keyRangeImportModel;}
  44. int firstKey() const;
  45. int lastKey() const;
  46. int baseKey() const;
  47. float baseFreq() const;
  48. float keyToFreq(int key, int userBaseNote) const;
  49. QString nodeName() const override {return "microtuner";}
  50. void saveSettings(QDomDocument & document, QDomElement &element) override;
  51. void loadSettings(const QDomElement &element) override;
  52. protected slots:
  53. void updateScaleList(int index);
  54. void updateKeymapList(int index);
  55. private:
  56. BoolModel m_enabledModel; //!< Enable microtuner (otherwise using 12-TET @440 Hz)
  57. ComboBoxModel m_scaleModel;
  58. ComboBoxModel m_keymapModel;
  59. BoolModel m_keyRangeImportModel;
  60. };
  61. #endif