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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_ReWirePlugin.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
11#if TRACKTION_ENABLE_REWIRE
12
13namespace tracktion { inline namespace engine
14{
15
16//==============================================================================
18class ReWireSystem : private juce::Timer
19{
20public:
21 //==============================================================================
23 static void initialise (Engine&);
24
26 static bool shutdown();
27
28 static ReWireSystem* getInstanceIfActive();
29
30 // if returnCurrentState is false, this returns whether it will be enabled
31 // next time the app runs
32 static bool isReWireEnabled (Engine&, bool returnCurrentState = true);
33 static void setReWireEnabled (Engine&, bool);
34
35 static const char* getReWireLibraryName();
36 static const char* getReWireFolderName();
37 static const char* getPropellerheadFolderName();
38 static int getRequiredVersionNumMajor();
39 static int getRequiredVersionNumMinor();
40
41 class Device;
42 Device* openDevice (const juce::String& devName, juce::String& error);
43 bool tryToCloseAllOpenDevices();
44
45 juce::StringArray deviceNames;
47 juce::String openError;
48 bool isOpen = false;
49
50private:
51 Engine& engine;
52
53 ReWireSystem (Engine&);
54 ~ReWireSystem();
55
56 Device* createDevice (int index, const juce::String& devName, juce::String& error);
57 bool closeSystem();
58 void timerCallback() override;
59};
60
61
62//==============================================================================
64class ReWirePlugin : public Plugin,
65 private juce::Timer,
66 private juce::AsyncUpdater
67{
68public:
69 ReWirePlugin (PluginCreationInfo);
70 ~ReWirePlugin();
71
72 static const char* getPluginName() { return NEEDS_TRANS("ReWire Device"); }
73
74 //==============================================================================
75 static const char* xmlTypeName;
76
77 void initialiseFully() override;
78 juce::String getName() const override;
79 juce::String getPluginType() override { return xmlTypeName; }
80
81 void initialise (const PluginInitialisationInfo&) override;
82 void deinitialise() override;
83
84 void getChannelNames (juce::StringArray*, juce::StringArray*) override;
85 int getNumOutputChannelsGivenInputs (int) override { return 2; }
86
87 void prepareForNextBlock (TimePosition editTime) override;
88 void applyToBuffer (const PluginRenderContext&) override;
89
90 juce::String getSelectableDescription() override { return TRANS("ReWire Filter"); }
91
92 bool takesMidiInput() override { return true; }
93 bool takesAudioInput() override { return true; }
94 bool producesAudioWhenNoAudioInput() override { return true; }
95 bool canBeAddedToClip() override { return false; }
96 bool needsConstantBufferSize() override { return true; }
97
98 bool hasNameForMidiNoteNumber (int note, int midiChannel, juce::String& name) override;
99 bool hasNameForMidiProgram (int, int, juce::String&) override { return false; }
100
101 void timerCallback() override;
102
103 juce::StringArray getDeviceChannelNames() const;
104
105 ReWireSystem::Device* device = nullptr;
106 juce::String rewireError;
107 juce::StringArray buses, channels;
108
109 juce::CachedValue<juce::String> currentDeviceName, currentChannelNameL, currentChannelNameR;
110 juce::CachedValue<int> currentBus, currentChannel;
111
112 juce::String openDevice (const juce::String& devName);
113 void closeDevice();
114 bool updateBusesAndChannels();
115 void openExternalUI();
116 bool isUIRunning() const noexcept { return uiIsRunning; }
117
118 void setLeftChannel (const juce::String& channelName);
119 void setRightChannel (const juce::String& channelName);
120
121 void setMidiBus (int busNum);
122 void setMidiChannel (int channel);
123
124private:
126 int channelIndexL = 0, channelIndexR = 0;
127 bool uiIsRunning = false;
128
129 //==============================================================================
130 void valueTreeChanged() override;
131 void handleAsyncUpdate() override;
132
134};
135
136}} // namespace tracktion { inline namespace engine
137
138#endif //TRACKTION_ENABLE_REWIRE
#define TRANS(stringLiteral)
#define NEEDS_TRANS(stringLiteral)
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
juce::String getName(LaunchQType t)
Retuns the name of a LaunchQType for display purposes.
shutdown