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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_LoopInfo.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
19{
20public:
23
25 LoopInfo (const LoopInfo&);
26
31
33 LoopInfo (Engine&, const juce::File&);
34
37
40
41 //==============================================================================
43 double getBpm (const AudioFileInfo&) const;
44
46 double getBeatsPerSecond (const AudioFileInfo&) const;
47
49 void setBpm (double newBpm, const AudioFileInfo&);
50
51 //==============================================================================
53 int getDenominator() const;
54
56 int getNumerator() const;
57
59 void setDenominator (int newDenominator);
60
62 void setNumerator (int newNumerator);
63
65 double getNumBeats() const;
66
68 void setNumBeats (double newNumBeats);
69
70 //==============================================================================
72 bool isLoopable() const;
73
75 bool isOneShot() const;
76
77 //==============================================================================
79 int getRootNote() const;
80
82 void setRootNote (int note);
83
84 //==============================================================================
86 SampleCount getInMarker() const;
87
89 SampleCount getOutMarker() const;
90
92 void setInMarker (SampleCount);
93
95 void setOutMarker (SampleCount);
96
97 //==============================================================================
99 enum class LoopPointType
100 {
101 manual = 0,
102 automatic
103 };
104
106 {
107 SampleCount pos = 0;
111 bool isAutomatic() const { return type == LoopPointType::automatic; }
112 };
113
115 int getNumLoopPoints() const;
116
118 LoopPoint getLoopPoint (int index) const;
119
121 void addLoopPoint (SampleCount, LoopPointType);
122
124 void changeLoopPoint (int index, SampleCount, LoopPointType);
125
127 void deleteLoopPoint (int index);
128
130 void clearLoopPoints();
131
134
135 //==============================================================================
137 int getNumTags() const;
138
140 void clearTags();
141
143 juce::String getTag (int index) const;
144
146 void addTag (const juce::String& tag);
147
149 void addTags (const juce::StringArray& tags);
150
152 juce::ValueTree state;
154private:
156 juce::UndoManager* um = nullptr;
157 bool maintainParent = false;
158
159 void init (const juce::AudioFormatReader*, const juce::AudioFormat*, const juce::File& file);
160 void initialiseMissingProps();
161 void duplicateIfShared();
162 LoopInfo& copyFrom (const juce::ValueTree&);
163 void removeChildIfEmpty (const juce::Identifier&);
164 juce::ValueTree getLoopPoints() const;
165 juce::ValueTree getOrCreateLoopPoints();
166 juce::ValueTree getTags() const;
167 juce::ValueTree getOrCreateTags();
168 void setBpm (double newBpm, double currentBpm);
169
170 bool deduceTempo (const juce::File& file, const juce::AudioFormatReader&);
171 std::optional<float> getCueTempo (const juce::StringPairArray& metadata);
172 std::optional<float> getFileNameTempo (const juce::String& rawName);
173 std::optional<int> getFileNameRootNote (const juce::String& rawName);
174
175 template<typename Type>
176 void setProp (const juce::Identifier& i, Type v)
177 {
178 duplicateIfShared();
179 const juce::ScopedLock sl (lock);
180 state.setProperty (i, v, um);
181 }
182
183 template<typename Type>
184 Type getProp (const juce::Identifier& i) const
185 {
186 const juce::ScopedLock sl (lock);
187 return state.getProperty (i);
188 }
189
191};
192
193}} // namespace tracktion { inline namespace engine
The Engine is the central class for all tracktion sessions.
Holds tempo/beat information about an audio file.
bool isOneShot() const
Returns true if this can be is a one-shot e.g.
SampleCount getOutMarker() const
Returns the sample number used as the end point in the file.
void clearLoopPoints()
Removes all the loop points.
void setInMarker(SampleCount)
Sets the sample number to be used as the start point in the file.
void setNumerator(int newNumerator)
Sets the numerator of the object.
void setDenominator(int newDenominator)
Sets the denominator of the object.
void setBpm(double newBpm, const AudioFileInfo &)
Sets the tempo of the object.
void addLoopPoint(SampleCount, LoopPointType)
Adds a loop point at the given position.
int getDenominator() const
Returns the denominator of the object.
int getNumTags() const
Returns the number of tags.
LoopInfo & operator=(const LoopInfo &)
Creates a copy of another LoopInfo.
void addTag(const juce::String &tag)
Adds a tag.
bool isLoopable() const
Returns true if this can be looped.
LoopPoint getLoopPoint(int index) const
Returns the loop points at the given index.
int getRootNote() const
Returns the root note of the object.
void changeLoopPoint(int index, SampleCount, LoopPointType)
Sets the loop point at the given index to a new position and type.
int getNumLoopPoints() const
Returns the number of loop points in the object.
LoopPointType
Enum to represet the type of loop point.
SampleCount getInMarker() const
Returns the sample number used as the start point in the file.
void addTags(const juce::StringArray &tags)
Adds multiple tags.
double getNumBeats() const
Returns the number of beats.
double getBpm(const AudioFileInfo &) const
Returns the tempo of the object.
void clearTags()
Removes all the tags.
void setOutMarker(SampleCount)
Sets the sample number to be used as the end point in the file.
void deleteLoopPoint(int index)
Removes the loop point at the given index.
int getNumerator() const
Returns the numerator of the object.
Engine & engine
The engine this belongs to.
juce::String getTag(int index) const
Returns the tag at a given index.
void setRootNote(int note)
Sets the root note of the object.
void setNumBeats(double newNumBeats)
Sets the number of beats.
double getBeatsPerSecond(const AudioFileInfo &) const
Returns the tempo of the object.
#define JUCE_LEAK_DETECTOR(OwnerClass)
LoopPointType type
The type of the loop point.
SampleCount pos
The sample position of the loop point.
bool isAutomatic() const
Returns true if this is an automatic loop point.