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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_CmajorPluginFormat.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
14//==============================================================================
15juce::String getCmajorPatchPluginFormatName()
16{
17 return "Cmajor";
18}
19
20bool isCmajorPatchPluginFormat (const juce::String& formatName)
21{
22 return formatName == getCmajorPatchPluginFormatName();
23}
24
25bool isCmajorPatchPluginFormat (const juce::PluginDescription& pd)
26{
27 return isCmajorPatchPluginFormat (pd.pluginFormatName);
28}
29
30//==============================================================================
31#if TRACKTION_ENABLE_CMAJOR
32
33}} // namespace tracktion { inline namespace engine
34
35#include "cmajor/helpers/cmaj_JUCEPluginFormat.h"
36#include "cmajor/helpers/cmaj_FileBasedCacheDatabase.h"
37
38namespace tracktion { inline namespace engine
39{
40
41std::string getCmajorVersion() { return cmaj::Library::getVersion(); }
42
43cmaj::CacheDatabaseInterface::Ptr createCompilerCache (tracktion::Engine& engine)
44{
45 auto cacheFolder = engine.getTemporaryFileManager().getTempDirectory().getChildFile ("cmajor_patch_cache");
46
47 if (cacheFolder.createDirectory())
48 return choc::com::create<cmaj::FileBasedCacheDatabase> (cacheFolder.getFullPathName().toStdString(), 100u);
49
50 return {};
51}
52
53std::unique_ptr<juce::AudioPluginFormat> createCmajorPatchPluginFormat (tracktion::Engine& engine)
54{
55 jassert (getCmajorPatchPluginFormatName() == cmaj::plugin::JUCEPluginFormat::pluginFormatName);
56
57 auto onPatchChange = [&engine] (cmaj::plugin::SinglePatchJITPlugin& plugin)
58 {
59 for (auto& edit : engine.getActiveEdits().getEdits())
60 {
61 if (auto p = edit->getPluginCache().getPluginFor (plugin))
62 {
63 if (! p->isInitialising())
64 {
65 if (auto ex = dynamic_cast<ExternalPlugin*> (p.get()))
66 {
67 plugin.suspendProcessing (true);
68 plugin.fillInPluginDescription (ex->desc);
69 ex->forceFullReinitialise();
70 plugin.suspendProcessing (false);
71 }
72 else
73 {
75 }
76 }
77
78 return;
79 }
80 }
81 };
82
83 return std::make_unique<cmaj::plugin::JUCEPluginFormat> (createCompilerCache (engine),
84 std::move (onPatchChange),
85 engine.getPropertyStorage().getApplicationVersion().toStdString());
86}
87
88juce::String getCmajorPatchCompileError (Plugin& p)
89{
90 if (auto ex = dynamic_cast<ExternalPlugin*> (&p))
91 if (auto plugin = dynamic_cast<cmaj::plugin::SinglePatchJITPlugin*> (ex->getAudioPluginInstance()))
92 if (plugin->isStatusMessageError)
93 return plugin->statusMessage;
94
95 return {};
96}
97
98#else
99
100//==============================================================================
101std::string getCmajorVersion() { return {}; }
102juce::String getCmajorPatchCompileError (Plugin&) { return {}; }
103std::unique_ptr<juce::AudioPluginFormat> createCmajorPatchPluginFormat (tracktion::Engine&) { return {}; }
104
105#endif
106
107}} // namespace tracktion { inline namespace engine
File getChildFile(StringRef relativeOrAbsolutePath) const
The Engine is the central class for all tracktion sessions.
PropertyStorage & getPropertyStorage() const
Returns the PropertyStorage user settings customisable XML file.
TemporaryFileManager & getTemporaryFileManager() const
Returns the TemporaryFileManager allowing to handle the default app and user temporary folders.
T is_pointer_v
#define jassert(expression)
#define jassertfalse