tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_TempoSequence.h
Go to the documentation of this file.
1 /*
2 ,--. ,--. ,--. ,--.
3 ,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2024
4 '-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
5 | | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
6 `---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
7
8 Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
9*/
10
11namespace tracktion { inline namespace engine
12{
13
14//==============================================================================
15//==============================================================================
24tempo::Sequence::Position createPosition (const TempoSequence&);
25
26
27//==============================================================================
28//==============================================================================
36 private juce::AsyncUpdater
37{
38public:
39 //==============================================================================
42
44 ~TempoSequence() override;
45
47 Edit& getEdit() const { return edit; }
48
50 const juce::ValueTree& getState() const { return state; }
51
53 void setState (const juce::ValueTree&, bool remapEdit);
54
56 void createEmptyState();
57
59 void copyFrom (const TempoSequence&);
60
61 //==============================================================================
64
66 int getNumTimeSigs() const;
67
69 TimeSigSetting* getTimeSig (int index) const;
70
73
76
79
81 int indexOfTimeSig (const TimeSigSetting*) const;
82
83 //==============================================================================
86
88 int getNumTempos() const;
89
91 TempoSetting* getTempo (int index) const;
92
95
98
103 double getBpmAt (TimePosition) const; // takes ramping into account
104
109 double getBeatsPerSecondAt (TimePosition, bool lengthOfOneBeatDependsOnTimeSignature = false) const;
110
112 bool isTripletsAtTime (TimePosition) const;
113
115 int indexOfTempoAt (TimePosition) const;
116
119
121 int indexOfTempo (const TempoSetting*) const;
122
124 int countTemposInRegion (TimeRange) const;
125
126 //==============================================================================
129
131 TempoSetting::Ptr insertTempo (BeatPosition, double bpm, float curve);
132
135
138
142 void removeTempo (int index, bool remapEdit);
143
147 void removeTemposBetween (TimeRange, bool remapEdit);
148
150 void removeTimeSig (int index);
151
153 void removeTimeSigsBetween (TimeRange);
154
156 void moveTempoStart (int index, BeatDuration deltaBeats, bool snapToBeat);
157
159 void moveTimeSigStart (int index, BeatDuration deltaBeats, bool snapToBeat);
160
162 void insertSpaceIntoSequence (TimePosition time, TimeDuration amountOfSpaceInSeconds, bool snapToBeat);
163
165 void deleteRegion (TimeRange);
166
167 //==============================================================================
170
172 BeatRange toBeats (TimeRange) const;
173
175 BeatPosition toBeats (tempo::BarsAndBeats) const;
176
179
181 TimeRange toTime (BeatRange) const;
182
184 TimePosition toTime (tempo::BarsAndBeats) const;
185
187 tempo::BarsAndBeats toBarsAndBeats (TimePosition) const;
188
189 //==============================================================================
193 const tempo::Sequence& getInternalSequence() const;
194
195 //==============================================================================
198 //==============================================================================
199 [[ deprecated ("Use new overload set above") ]] tempo::BarsAndBeats timeToBarsBeats (TimePosition) const;
200 [[ deprecated ("Use new overload set above") ]] TimePosition barsBeatsToTime (tempo::BarsAndBeats) const;
201 [[ deprecated ("Use new overload set above") ]] BeatPosition barsBeatsToBeats (tempo::BarsAndBeats) const;
202 [[ deprecated ("Use new overload set above") ]] BeatPosition timeToBeats (TimePosition time) const;
203 [[ deprecated ("Use new overload set above") ]] BeatRange timeToBeats (TimeRange range) const;
204 [[ deprecated ("Use new overload set above") ]] TimePosition beatsToTime (BeatPosition beats) const;
205 [[ deprecated ("Use new overload set above") ]] TimeRange beatsToTime (BeatRange range) const;
206 [[ deprecated ("Use new overload set above") ]] TimeSigSetting& getTimeSigAtBeat (BeatPosition) const;
207 [[ deprecated ("Use new overload set above") ]] TempoSetting& getTempoAtBeat (BeatPosition) const;
208
210 juce::UndoManager* getUndoManager() const noexcept;
212 juce::String getSelectableDescription() override;
214 void freeResources();
216 void updateTempoData();
217
218private:
219 //==============================================================================
220 friend class TempoSetting;
221 friend class TimeSigSetting;
222
223 //==============================================================================
224 juce::ValueTree state;
225
226 struct TempoSettingList;
227 struct TimeSigList;
228 std::unique_ptr<TempoSettingList> tempos;
229 std::unique_ptr<TimeSigList> timeSigs;
230
231 tempo::Sequence internalSequence { {{ BeatPosition(), 120.0, 0.0f }},
232 {{ BeatPosition(), 4, 4, false }},
233 tempo::LengthOfOneBeat::dependsOnTimeSignature };
234
235 //==============================================================================
236 void updateTempoDataIfNeeded() const;
237 void handleAsyncUpdate() override;
238
239 TempoSetting::Ptr insertTempo (BeatPosition, double bpm, float curve, juce::UndoManager*);
240 TempoSetting::Ptr insertTempo (TimePosition, juce::UndoManager*);
241 TimeSigSetting::Ptr insertTimeSig (TimePosition, juce::UndoManager*);
242 HashCode createHashForTemposInRange (TimeRange) const;
243
245};
246
247
248//==============================================================================
253{
254 void savePreChangeState (Edit&);
255 void remapEdit (Edit&);
256
257private:
258 struct ClipPos
259 {
261 BeatPosition startBeat, endBeat;
262 BeatDuration contentStartBeat;
263 };
264
265 struct AutomationPos
266 {
267 AutomationCurve& curve;
269 };
270
273 BeatRange loopPositionBeats;
274 BeatPosition startPositionBeats;
275};
276
277
278}} // namespace tracktion { inline namespace engine
The Tracktion Edit class!
Holds a pointer to some type of Selectable, which automatically becomes null if the selectable is del...
Base class for things that can be selected, and whose properties can appear in the properties panel.
Holds a list of TempoSetting objects, to form a sequence of tempo changes.
TimePosition toTime(BeatPosition) const
Converts a number of beats a time.
Edit & getEdit() const
Returns the Edit this TempoSequence refers to.
void moveTempoStart(int index, BeatDuration deltaBeats, bool snapToBeat)
Moves the TempoSetting at a given index by a number of beats.
void removeTimeSig(int index)
Removes the TimeSigSetting at a given index.
void insertSpaceIntoSequence(TimePosition time, TimeDuration amountOfSpaceInSeconds, bool snapToBeat)
Inserts space in to a sequence, shifting TempoSettings and TimeSigs.
void deleteRegion(TimeRange)
Removes a region in a sequence, shifting TempoSettings and TimeSigs.
void moveTimeSigStart(int index, BeatDuration deltaBeats, bool snapToBeat)
Moves the TimeSigSetting at a given index by a number of beats.
void createEmptyState()
Resets this to a default, empty state.
TimeSigSetting & getTimeSigAt(TimePosition) const
Returns the TimeSigSetting at a given position.
void removeTimeSigsBetween(TimeRange)
Removes any TimeSigSetting[s] within the range.
TempoSetting::Ptr insertTempo(TimePosition)
Inserts a tempo break that can be edited later.
const juce::Array< TimeSigSetting * > & getTimeSigs() const
Returns an array of the TimeSigSetting.
int countTemposInRegion(TimeRange) const
Returns the number of TempoSetting[s] in the given range.
int indexOfTempo(const TempoSetting *) const
Returns the index of the given TempoSetting.
int getNumTimeSigs() const
Returns the number of TimeSigSetting[s] in the sequence.
bool isTripletsAtTime(TimePosition) const
Returns true if the TempoSetting is triplets at the given time.
int indexOfTimeSig(const TimeSigSetting *) const
Returns the index of a given TimeSigSetting.
juce::String getSelectableDescription() override
Subclasses must return a description of what they are.
BeatPosition toBeats(TimePosition) const
Converts a time to a number of beats.
int getNumTempos() const
Returns the current number of TempoSettings.
void copyFrom(const TempoSequence &)
Copies the contents of another TempoSequence.
const juce::Array< TempoSetting * > & getTempos() const
Returns the TempoSettings.
tempo::BarsAndBeats toBarsAndBeats(TimePosition) const
Converts a time to a number of BarsAndBeats.
const tempo::Sequence & getInternalSequence() const
N.B.
void removeTemposBetween(TimeRange, bool remapEdit)
Removes any TempoSetting[s] within the range.
TimeSigSetting * getTimeSig(int index) const
Returns the TimeSigSetting at a given index.
void removeTempo(int index, bool remapEdit)
Removes the TempoSetting at a given index.
TempoSetting * getTempo(int index) const
Returns the TempoSetting at the given index.
int indexOfTimeSigAt(TimePosition) const
Returns the index of TimeSigSetting at a given position.
const juce::ValueTree & getState() const
Returns the state this TempoSequence models.
double getBeatsPerSecondAt(TimePosition, bool lengthOfOneBeatDependsOnTimeSignature=false) const
Returns the tempo at a given position.
TempoSetting & getTempoAt(TimePosition) const
Returns the TempoSetting at the given position.
void setState(const juce::ValueTree &, bool remapEdit)
Sets the state this TempoSequence should refer to.
Edit & edit
The Edit this sequence belongs to.
int indexOfNextTempoAt(TimePosition) const
Returns the index of the TempoSetting after the given position.
int indexOfTempoAt(TimePosition) const
Returns the index of the TempoSetting at the given position.
double getBpmAt(TimePosition) const
Returns the tempo at a given position.
TimeSigSetting::Ptr insertTimeSig(TimePosition)
Inserts a new TimeSigSetting at the given position.
A tempo value, as used in a TempoSequence.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
tempo::Sequence::Position createPosition(const TempoSequence &s)
Creates a Position to iterate over the given TempoSequence.
Represents a duration in beats.
Represents a position in beats.
Represents a duration in real-life time.
Represents a position in real-life time.
Takes a copy of all the beat related things in an edit in terms of bars/beats and then remaps these a...