PatternStore.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * PatternStore.h - model-component of Pattern Editor
  3. *
  4. * Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  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 PATTERN_STORE_H
  25. #define PATTERN_STORE_H
  26. #include "TrackContainer.h"
  27. #include "ComboBoxModel.h"
  28. /*
  29. * PatternStore is the backend of Pattern Editor:
  30. *
  31. * +----------------------------------+
  32. * | PatternStore (TrackContainer) |
  33. * | |
  34. * | +------------------------------+ |
  35. * | | Track 1 [Clip A] [Clip B] | |
  36. * | +------------------------------+ |
  37. * | |
  38. * | +------------------------------+ |
  39. * | | Track 2 [Clip C] [Clip D] | |
  40. * | +------------------------------+ |
  41. * +----------------------------------+
  42. *
  43. * There is only one PatternStore which holds all patterns, and it's very similar to the Song Editor.
  44. * Think of it as a table - tracks are rows, bars are columns and clips are cells.
  45. * With this logic a "pattern" is a column, i.e. all clips on the same bar.
  46. * In the Pattern Editor you can select which pattern (column) you want to see, using the combo box at the top.
  47. * In the illustration above, Clip A and Clip C start on bar 1, thus they are "Pattern 1".
  48. *
  49. * Do not confuse tracks and clips in the PatternStore with PatternTracks and PatternClips.
  50. * - PatternTracks are used in the Song Editor. Each one reference a "pattern" in the PatternStore.
  51. * - PatternClips are stored inside PatternTracks. They are just empty placeholders.
  52. */
  53. class LMMS_EXPORT PatternStore : public TrackContainer
  54. {
  55. Q_OBJECT
  56. mapPropertyFromModel(int, currentPattern, setCurrentPattern, m_patternComboBoxModel);
  57. public:
  58. PatternStore();
  59. virtual ~PatternStore();
  60. virtual bool play(TimePos start, const fpp_t frames, const f_cnt_t frameBase, int clipNum = -1);
  61. void updateAfterTrackAdd() override;
  62. inline QString nodeName() const override
  63. {
  64. return "patternstore";
  65. }
  66. bar_t lengthOfPattern(int pattern) const;
  67. inline bar_t lengthOfCurrentPattern()
  68. {
  69. return lengthOfPattern(currentPattern());
  70. }
  71. int numOfPatterns() const;
  72. void removePattern(int pattern);
  73. void swapPattern(int p1, int p2);
  74. void updatePatternTrack(Clip* clip);
  75. void fixIncorrectPositions();
  76. void createClipsForPattern(int pattern);
  77. AutomatedValueMap automatedValuesAt(TimePos time, int clipNum) const override;
  78. public slots:
  79. void play();
  80. void stop();
  81. void updateComboBox();
  82. void currentPatternChanged();
  83. private:
  84. ComboBoxModel m_patternComboBoxModel;
  85. // Where the pattern selection combo box is
  86. friend class PatternEditorWindow;
  87. } ;
  88. #endif