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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_Engine.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
14static Engine* instance = nullptr;
15static juce::Array<Engine*> engines;
16
18{
19 instance = this;
20 engines.add (this);
21
22 jassert (ps != nullptr);
23 propertyStorage = std::move (ps);
24
25 if (ub == nullptr)
26 uiBehaviour = std::make_unique<UIBehaviour>();
27 else
28 uiBehaviour = std::move (ub);
29
30 if (! eb)
31 engineBehaviour = std::make_unique<EngineBehaviour>();
32 else
33 engineBehaviour = std::move (eb);
34
35 initialise();
36}
37
39 : Engine (std::make_unique<PropertyStorage> (applicationName), std::move (ub), std::move (eb))
40{
41}
42
43Engine::Engine (juce::String applicationName) : Engine (applicationName, nullptr, nullptr)
44{
45}
46
47void Engine::initialise()
48{
49 Selectable::initialise();
51
52 projectManager = std::make_unique<ProjectManager> (*this);
53 activeEdits = std::unique_ptr<ActiveEdits> (new ActiveEdits());
54 temporaryFileManager = std::make_unique<TemporaryFileManager> (*this);
55 recordingThumbnailManager = std::make_unique<RecordingThumbnailManager> (*this);
56 waveInputRecordingThread = std::make_unique<WaveInputRecordingThread> (*this);
57 editDeleter = std::unique_ptr<EditDeleter> (new EditDeleter());
58 audioFileFormatManager = std::make_unique<AudioFileFormatManager>();
59 midiLearnState = std::make_unique<MidiLearnState> (*this);
60 renderManager = std::make_unique<RenderManager> (*this);
61 audioFileManager = std::make_unique<AudioFileManager> (*this);
62 deviceManager = std::unique_ptr<DeviceManager> (new DeviceManager (*this));
63 midiProgramManager = std::make_unique<MidiProgramManager> (*this);
64 externalControllerManager = std::unique_ptr<ExternalControllerManager> (new ExternalControllerManager (*this));
65 backgroundJobManager = std::make_unique<BackgroundJobManager>();
66 pluginManager = std::make_unique<PluginManager> (*this);
67
68 if (engineBehaviour->autoInitialiseDeviceManager())
69 deviceManager->initialise();
70
71 pluginManager->initialise();
72 getProjectManager().initialise();
73
74 externalControllerManager->initialise();
75}
76
78{
79 getProjectManager().saveList();
80
82 getDeviceManager().closeDevices();
83 getBackgroundJobs().stopAndDeleteAllRunningJobs();
84
85 temporaryFileManager->cleanUp();
86
87 editDeleter.reset();
88
90 backgroundJobManager.reset();
91 deviceManager.reset();
92 midiProgramManager.reset();
93
94 MelodyneFileReader::cleanUpOnShutdown();
95 pluginManager.reset();
96
97 temporaryFileManager.reset();
98 projectManager.reset();
99
100 renderManager.reset();
101 externalControllerManager.reset();
102 propertyStorage.reset();
103 uiBehaviour.reset();
104 engineBehaviour.reset();
105 audioFileManager.reset();
106 midiLearnState.reset();
107 audioFileFormatManager.reset();
108 backToArrangerUpdateTimer.reset();
109 bufferedAudioFileManager.reset();
110
111 instance = nullptr;
112 engines.removeFirstMatchingValue (this);
113}
114
116{
117 return "Tracktion Engine v3.0.0";
118}
119
121{
122 return engines;
123}
124
125#if TRACKTION_ENABLE_SINGLETONS
126Engine& Engine::getInstance()
127{
128 jassert (instance != nullptr);
129 return *instance;
130}
131#endif
132
134{
135 jassert (projectManager != nullptr);
136 return *projectManager;
137}
138
140{
141 jassert (audioFileFormatManager != nullptr);
142 return *audioFileFormatManager;
143}
144
146{
147 jassert (deviceManager != nullptr);
148 return *deviceManager;
149}
150
152{
153 jassert (midiProgramManager);
154 return *midiProgramManager;
155}
156
158{
159 jassert (externalControllerManager != nullptr);
160 return *externalControllerManager;
161}
162
164{
165 jassert (renderManager != nullptr);
166 return *renderManager;
167}
168
170{
171 jassert (backgroundJobManager != nullptr);
172 return *backgroundJobManager;
173}
174
176{
177 jassert (propertyStorage != nullptr);
178 return *propertyStorage;
179}
180
182{
183 jassert (uiBehaviour != nullptr);
184 return *uiBehaviour;
185}
186
188{
189 jassert (engineBehaviour != nullptr);
190 return *engineBehaviour;
191}
192
194{
195 jassert (audioFileManager != nullptr);
196 return *audioFileManager;
197}
198
200{
201 jassert (midiLearnState != nullptr);
202 return *midiLearnState;
203}
204
206{
207 jassert (pluginManager != nullptr);
208 return *pluginManager;
209}
210
212{
213 jassert (editDeleter != nullptr);
214 return *editDeleter;
215}
216
218{
219 jassert (temporaryFileManager != nullptr);
220 return *temporaryFileManager;
221}
222
224{
225 jassert (recordingThumbnailManager != nullptr);
226 return *recordingThumbnailManager;
227}
228
230{
231 jassert (waveInputRecordingThread != nullptr);
232 return *waveInputRecordingThread;
233}
234
236{
237 jassert (activeEdits != nullptr);
238 return *activeEdits;
239}
240
242{
243 if (! grooveTemplateManager)
244 grooveTemplateManager = std::make_unique<GrooveTemplateManager> (*this);
245
246 return *grooveTemplateManager;
247}
248
250{
251 if (! compFactory)
252 compFactory = std::make_unique<CompFactory>();
253
254 return *compFactory;
255}
256
258{
259 if (! warpTimeFactory)
260 warpTimeFactory = std::make_unique<WarpTimeFactory>();
261
262 return *warpTimeFactory;
263}
264
266{
267 if (! backToArrangerUpdateTimer)
268 backToArrangerUpdateTimer = std::make_unique<SharedTimer> (HertzTag_t, 10);
269
270 return *backToArrangerUpdateTimer;
271}
272
274{
275 if (! bufferedAudioFileManager)
276 bufferedAudioFileManager = std::make_unique<BufferedAudioFileManager> (*this);
277
278 return *bufferedAudioFileManager;
279}
280
282{
283 return p.edit.shouldLoadPlugins();
284}
285
286}} // namespace tracktion { inline namespace engine
Keeps a list of available wave formats and can create a format object for a file.
static void initialise()
Initialises the internal buffer list.
Manages a set of background tasks that can be run concurrently on a background thread.
Provides custom handlers to control various aspects of the engine's behaviour.
virtual bool shouldLoadPlugin(ExternalPlugin &p)
Should the plugin be loaded.
The Engine is the central class for all tracktion sessions.
CompFactory & getCompFactory() const
Returns the CompFactory instance.
MidiProgramManager & getMidiProgramManager() const
Returns the MidiProgramManager instance that handles MIDI banks, programs, sets or presets.
PropertyStorage & getPropertyStorage() const
Returns the PropertyStorage user settings customisable XML file.
RenderManager & getRenderManager() const
Returns the RenderManager instance.
WaveInputRecordingThread & getWaveInputRecordingThread() const
Returns the WaveInputRecordingThread instance.
AudioFileFormatManager & getAudioFileFormatManager() const
Returns the AudioFileFormatManager that maintains a list of available audio file formats.
WarpTimeFactory & getWarpTimeFactory() const
Returns the WarpTimeFactory instance.
static juce::Array< Engine * > getEngines()
Returns the list of currently active engines.
UIBehaviour & getUIBehaviour() const
Returns the UIBehaviour class.
ExternalControllerManager & getExternalControllerManager() const
Returns the ExternalControllerManager instance.
DeviceManager & getDeviceManager() const
Returns the DeviceManager instance for handling audio / MIDI devices.
AudioFileManager & getAudioFileManager() const
Returns the AudioFileManager instance.
EngineBehaviour & getEngineBehaviour() const
Returns the EngineBehaviour instance.
Engine(juce::String applicationName)
Constructs a default Engine with an application name.
ProjectManager & getProjectManager() const
Returns the ProjectManager instance.
GrooveTemplateManager & getGrooveTemplateManager()
Returns the GrooveTemplateManager instance.
BufferedAudioFileManager & getBufferedAudioFileManager()
Returns the BufferedAudioFileManager instance.
RecordingThumbnailManager & getRecordingThumbnailManager() const
Returns the RecordingThumbnailManager instance.
ActiveEdits & getActiveEdits() const noexcept
Returns the ActiveEdits instance.
static juce::String getVersion()
Returns the current version of Tracktion Engine.
MidiLearnState & getMidiLearnState() const
Returns the MidiLearnState instance.
PluginManager & getPluginManager() const
Returns the PluginManager instance.
BackgroundJobManager & getBackgroundJobs() const
Returns the BackgroundJobManager instance.
TemporaryFileManager & getTemporaryFileManager() const
Returns the TemporaryFileManager allowing to handle the default app and user temporary folders.
SharedTimer & getBackToArrangerUpdateTimer() const
Returns the SharedTimer instance.
EditDeleter & getEditDeleter() const
Returns the EditDeleter instance.
Keeps a list of external controllers and keeps them connected to the right MIDI in/out devices.
Looks after the list of groove templates.
Manages the Midi learn state and Listener interface to notify subclasses when the state changes.
Create a subclass of PropertyStorage to customize how settings are saved and recalled.
Holds a pool of Thumbnails that are populated whilst recording.
Manages a set of reference counted render jobs and can be used to retrieve matching jobs or create ne...
void cleanUp()
Cleans up any remaining jobs - should be called before the manager is deleted.
Holds info about where temp files should go, and tidies up old ones when needed.
Create a subclass of UIBehaviour to custom UI elements created by the engine.
A WarpTimeFactory manages WarpTimeManagers for Clips living in an Edit.
T is_pointer_v
#define jassert(expression)
A list of all currently open edits.
Deferred Edit object deleter.