LMMS
Loading...
Searching...
No Matches
MidiClip.h
Go to the documentation of this file.
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
26#ifndef LMMS_MIDI_CLIP_H
27#define LMMS_MIDI_CLIP_H
28
29#include "Clip.h"
30#include "Note.h"
31
32
33namespace lmms
34{
35
36
37class InstrumentTrack;
38
39namespace gui
40{
41class MidiClipView;
42}
43
44
45class LMMS_EXPORT MidiClip : public Clip
46{
47 Q_OBJECT
48public:
49 enum class Type
50 {
51 BeatClip,
52 MelodyClip
53 } ;
54
55 MidiClip( InstrumentTrack* instrumentTrack );
56 ~MidiClip() override;
57
58 void init();
59
60 void updateLength() override;
61
62 // note management
63 Note * addNote( const Note & _new_note, const bool _quant_pos = true );
64
65 NoteVector::const_iterator removeNote(NoteVector::const_iterator it);
66 NoteVector::const_iterator removeNote(Note* note);
67
68 Note * noteAtStep( int _step );
69
70 void rearrangeAllNotes();
71 void clearNotes();
72
73 inline const NoteVector & notes() const
74 {
75 return m_notes;
76 }
77
78 Note * addStepNote( int step );
79 void setStep( int step, bool enabled );
80
82 void reverseNotes(const NoteVector& notes);
83
84 // Split the list of notes on the given position
85 void splitNotes(const NoteVector& notes, TimePos pos);
86
87 // Split the list of notes along a line
88 void splitNotesAlongLine(const NoteVector notes, TimePos pos1, int key1, TimePos pos2, int key2, bool deleteShortEnds);
89
90 // clip-type stuff
91 inline Type type() const
92 {
93 return m_clipType;
94 }
95
96
97 // next/previous track based on position in the containing track
98 MidiClip * previousMidiClip() const;
99 MidiClip * nextMidiClip() const;
100
101 // settings-management
102 void exportToXML(QDomDocument& doc, QDomElement& midiClipElement, bool onlySelectedNotes = false);
103 void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override;
104 void loadSettings( const QDomElement & _this ) override;
105 inline QString nodeName() const override
106 {
107 return "midiclip";
108 }
109
111 {
112 return m_instrumentTrack;
113 }
114
115 bool empty();
116
117
118 gui::ClipView * createView( gui::TrackView * _tv ) override;
119
120 MidiClip* clone() override
121 {
122 return new MidiClip(*this);
123 }
124
125
126 using Model::dataChanged;
127
128public slots:
129 void addSteps();
130 void cloneSteps();
131 void removeSteps();
132 void clear();
133
134protected:
135 MidiClip( const MidiClip& other );
136 void updatePatternTrack();
137
138protected slots:
139 void changeTimeSignature();
140
141
142private:
143 TimePos beatClipLength() const;
144
145 void setType( Type _new_clip_type );
146 void checkType();
147
148 void resizeToFirstTrack();
149
151
153
154 // data-stuff
157
158 MidiClip * adjacentMidiClipByOffset(int offset) const;
159
160 friend class gui::MidiClipView;
161
162
163signals:
165} ;
166
167
168} // namespace lmms
169
170#endif // LMMS_MIDI_CLIP_H
Clip(Track *track)
Create a new Clip.
Definition Clip.cpp:47
Definition InstrumentTrack.h:62
Definition MidiClip.h:46
NoteVector m_notes
Definition MidiClip.h:155
MidiClip(InstrumentTrack *instrumentTrack)
Definition MidiClip.cpp:42
MidiClip * clone() override
Definition MidiClip.h:120
Type type() const
Definition MidiClip.h:91
int m_steps
Definition MidiClip.h:156
InstrumentTrack * instrumentTrack() const
Definition MidiClip.h:110
MidiClip * adjacentMidiClipByOffset(int offset) const
Definition MidiClip.cpp:555
InstrumentTrack * m_instrumentTrack
Definition MidiClip.h:150
Type m_clipType
Definition MidiClip.h:152
Type
Definition MidiClip.h:50
QString nodeName() const override
Definition MidiClip.h:105
void destroyedMidiClip(lmms::MidiClip *)
const NoteVector & notes() const
Definition MidiClip.h:73
void dataChanged()
Definition Note.h:101
Definition TimePos.h:68
Definition ClipView.h:52
Definition MidiClipView.h:42
Definition TrackView.h:60
Definition AudioPortAudio.cpp:223
Definition AudioAlsa.cpp:35
std::vector< Note * > NoteVector
Definition Note.h:282
ZCONST uch * init
Definition extract.c:2392