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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_TempoTrack.cpp
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
15 : Track (e, v, true)
16{
17}
18
20{
21 notifyListenersOfDeletion();
22}
23
24bool TempoTrack::isTempoTrack() const { return true; }
25juce::String TempoTrack::getName() const { return TRANS ("Tempo"); }
27bool TempoTrack::canContainPlugin (Plugin*) const { return false; }
28
30{
31 return edit.tempoSequence.getNumTimeSigs()
32 + edit.pitchSequence.getNumPitches();
33}
34
36{
37 return buildTrackItemList()[index];
38}
39
41{
42 return buildTrackItemList().indexOf (ti);
43}
44
46{
47 return findIndexOfNextItemAt (buildTrackItemList(), time);
48}
49
54
56{
57 Track::insertSpaceIntoTrack (time, amountOfSpace);
58
59 // Insert in to pitch sequence first of the tempo calculations will be different
60 edit.pitchSequence.insertSpaceIntoSequence (time, amountOfSpace, false);
61 edit.tempoSequence.insertSpaceIntoSequence (time, amountOfSpace, false);
62}
63
64juce::Array<TrackItem*> TempoTrack::buildTrackItemList() const
65{
67
68 items.addArray (edit.tempoSequence.getTimeSigs());
69 items.addArray (edit.pitchSequence.getPitches());
70
71 std::sort (items.begin(), items.end(),
72 [] (TrackItem* a, TrackItem* b)
73 {
74 auto t1 = a->getPosition().getStart();
75 auto t2 = b->getPosition().getStart();
76
77 if (t1 != t2)
78 return t1 < t2;
79
80 if (typeid (*a) == typeid (*b))
81 return false;
82
83 return typeid (*a) == typeid (TimeSigSetting);
84 });
85
86 return items;
87}
88
89}} // namespace tracktion { inline namespace engine
void addArray(const Type *elementsToAdd, int numElementsToAdd)
ElementType * begin() noexcept
ElementType * end() noexcept
The Tracktion Edit class!
PitchSequence pitchSequence
The global PitchSequence of this Edit.
TempoSequence tempoSequence
The global TempoSequence of this Edit.
void insertSpaceIntoSequence(TimePosition, TimeDuration amountOfSpace, bool snapToBeat)
Inserts space in to a sequence, shifting all PitchSettings.
void insertSpaceIntoSequence(TimePosition time, TimeDuration amountOfSpaceInSeconds, bool snapToBeat)
Inserts space in to a sequence, shifting TempoSettings and TimeSigs.
const juce::Array< TimeSigSetting * > & getTimeSigs() const
Returns an array of the TimeSigSetting.
int getNumTimeSigs() const
Returns the number of TimeSigSetting[s] in the sequence.
int getNumTrackItems() const override
Should return the number of TrackItem[s] on this Track.
bool isTempoTrack() const override
Returns true if this is a TempoTrack.
TrackItem * getNextTrackItemAt(TimePosition) override
Should return the TrackItem after this time.
void insertSpaceIntoTrack(TimePosition, TimeDuration) override
Should insert empty space in to the track, shuffling down any items after the time.
TrackItem * getTrackItem(int idx) const override
Should return the TrackItem at the given index.
int indexOfTrackItem(TrackItem *) const override
Should return the index of the given TrackItem.
juce::String getSelectableDescription() override
Subclasses must return a description of what they are.
bool canContainPlugin(Plugin *) const override
Returns true if this track can contain a specific Plugin.
int getIndexOfNextTrackItemAt(TimePosition) override
Should return the index of the TrackItem after this time.
TempoTrack(Edit &, const juce::ValueTree &)
Create the TempoTrack for an Edit with a given state.
Base class for EditItems that live in a Track, e.g.
Base class for tracks which contain clips and plugins and can be added to Edit[s].
virtual void insertSpaceIntoTrack(TimePosition, TimeDuration)
Should insert empty space in to the track, shuffling down any items after the time.
#define TRANS(stringLiteral)
int findIndexOfNextItemAt(const ArrayType &items, TimePosition time)
Returns the index of the next item after the given time.
T sort(T... args)
Represents a duration in real-life time.
Represents a position in real-life time.
time