MidiClip.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * MidiClip.h - declaration of class MidiClip, which contains all information
  3. * about a clip
  4. *
  5. * Copyright (c) 2004-2014 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 MIDI_CLIP_H
  26. #define MIDI_CLIP_H
  27. #include <QStaticText>
  28. #include "Note.h"
  29. #include "MidiClipView.h"
  30. #include "ClipView.h"
  31. class InstrumentTrack;
  32. class LMMS_EXPORT MidiClip : public Clip
  33. {
  34. Q_OBJECT
  35. public:
  36. enum MidiClipTypes
  37. {
  38. BeatClip,
  39. MelodyClip
  40. } ;
  41. MidiClip( InstrumentTrack* instrumentTrack );
  42. MidiClip( const MidiClip& other );
  43. virtual ~MidiClip();
  44. void init();
  45. void updateLength();
  46. // note management
  47. Note * addNote( const Note & _new_note, const bool _quant_pos = true );
  48. void removeNote( Note * _note_to_del );
  49. Note * noteAtStep( int _step );
  50. void rearrangeAllNotes();
  51. void clearNotes();
  52. inline const NoteVector & notes() const
  53. {
  54. return m_notes;
  55. }
  56. Note * addStepNote( int step );
  57. void setStep( int step, bool enabled );
  58. // Split the list of notes on the given position
  59. void splitNotes(NoteVector notes, TimePos pos);
  60. // clip-type stuff
  61. inline MidiClipTypes type() const
  62. {
  63. return m_clipType;
  64. }
  65. // next/previous track based on position in the containing track
  66. MidiClip * previousMidiClip() const;
  67. MidiClip * nextMidiClip() const;
  68. // settings-management
  69. void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override;
  70. void loadSettings( const QDomElement & _this ) override;
  71. inline QString nodeName() const override
  72. {
  73. return "midiclip";
  74. }
  75. inline InstrumentTrack * instrumentTrack() const
  76. {
  77. return m_instrumentTrack;
  78. }
  79. bool empty();
  80. ClipView * createView( TrackView * _tv ) override;
  81. using Model::dataChanged;
  82. public slots:
  83. void addSteps();
  84. void cloneSteps();
  85. void removeSteps();
  86. void clear();
  87. protected:
  88. void updatePatternTrack();
  89. protected slots:
  90. void changeTimeSignature();
  91. private:
  92. TimePos beatClipLength() const;
  93. void setType( MidiClipTypes _new_clip_type );
  94. void checkType();
  95. void resizeToFirstTrack();
  96. InstrumentTrack * m_instrumentTrack;
  97. MidiClipTypes m_clipType;
  98. // data-stuff
  99. NoteVector m_notes;
  100. int m_steps;
  101. MidiClip * adjacentMidiClipByOffset(int offset) const;
  102. friend class MidiClipView;
  103. signals:
  104. void destroyedMidiClip( MidiClip* );
  105. } ;
  106. #endif