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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_ExternalController.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
18 private SelectableListener,
21 private juce::Timer
22{
23public:
24 //==============================================================================
26 ~ExternalController() override;
27
28 //==============================================================================
29 juce::String getName() const;
30
31 bool wantsDevice (const MidiID& m);
32
33 bool needsMidiChannel() const { return needsChannel; }
34 bool needsMidiBackChannel() const { return needsBackChannel; }
35
36 juce::String getDesiredMidiChannel() const;
37 juce::String getDesiredMidiBackChannel() const;
38
39 bool needsOSCSocket() const { return needsOSC; }
40
41 int getNumDevices() const;
42 void setNumDevices (int);
43
44 int getMainDevice() const;
45 void setMainDevice (int);
46
47 juce::String getMidiInputDevice (int idx) const;
48 void setMidiInputDevice (int idx, const juce::String& nameOfMidiInput);
49
50 juce::String getBackChannelDevice (int idx) const;
51 void setBackChannelDevice (int idx, const juce::String& nameOfMidiOutput);
52 bool isUsingMidiOutputDevice (const MidiOutputDevice* d) const noexcept;
53
54 int getOSCInputPort() { return oscInputPort; }
55 void setOSCInputPort (int port);
56 int getOSCOutputPort() { return oscOutputPort; }
57 void setOSCOutputPort (int port);
58 juce::String getOSCOutputAddress() { return oscOutputAddr; }
59 void setOSCOutputAddress (const juce::String addr);
60
61 bool isEnabled() const;
62 void setEnabled (bool);
63
64 bool isDeletable() const { return deletable; }
65 void deleteController();
66
67 bool wantsMidiClock() const { return wantsClock; }
68
69 void currentEditChanged (Edit*);
70 void currentSelectionManagerChanged (SelectionManager*);
71
72 // these will be called by tracktion when stuff happens, and
73 // will pass the message on to the controller.
74
75 // channels are virtual - i.e. not restricted to physical chans
76 void moveFader (int channelNum, float newSliderPos);
77 void moveMasterFader (float newPos);
78 void movePanPot (int channelNum, float newPan);
79 void moveMasterPanPot (float newPos);
80 void updateSoloAndMute (int channelNum, Track::MuteAndSoloLightState, bool isBright);
81 void soloCountChanged (bool);
82 void playStateChanged (bool isPlaying);
83 void recordStateChanged (bool isRecording);
84 void automationModeChanged (bool isReading, bool isWriting);
85 void snapChanged (bool isOn);
86 void loopChanged (bool isOn);
87 void clickChanged (bool isOn);
88 void channelLevelChanged (int channel, float l, float r);
89 void masterLevelsChanged (float leftLevel, float rightLevel);
90 void timecodeChanged (int barsOrHours, int beatsOrMinutes, int ticksOrSeconds, int millisecs, bool isBarsBeats, bool isFrames);
91 void trackSelected (int channel, bool isSelected);
92 void selectOtherObject (SelectableClass::Relationship, bool moveFromCurrentPlugin);
93 void muteOrUnmutePlugin();
94 void muteOrUnmutePluginsInTrack();
95 void changePluginPreset (int delta);
96 void soloPluginTrack();
97 void auxSendLevelsChanged();
98
99 void updateDeviceState();
100 void updateParameters();
101 void updateMarkers();
102 void selectedPluginChanged();
103 void selectableObjectChanged (Selectable*) override;
104 void selectableObjectAboutToBeDeleted (Selectable*) override;
105 void curveHasChanged (AutomatableParameter&) override;
107 void updateTrackSelectLights();
108 void updateTrackRecordLights();
109 void updatePunchLights();
110 void updateScrollLights();
111 void updateUndoLights();
112 void updatePadColours();
113 void clearPadColours();
114
115 int getNumFaderChannels() const noexcept;
116 int getFaderIndexInActiveRegion (int num) const noexcept;
117 juce::Range<int> getActiveChannels() const noexcept;
118
119 int getNumParameterControls() const noexcept;
120 juce::Range<int> getActiveParams() const noexcept;
121
122 void midiInOutDevicesChanged();
123 void oscSettingsChanged();
124
125 //==============================================================================
126 void handleAsyncUpdate() override;
127 void acceptMidiMessage (MidiInputDevice&, const juce::MidiMessage&);
128 bool wantsMessage (MidiInputDevice&, const juce::MidiMessage&);
129 bool eatsAllMessages() const;
130 bool canSetEatsAllMessages();
131 void setEatsAllMessages (bool eatAll);
132
133 //==============================================================================
134 juce::Colour getSelectionColour() const { return selectionColour; }
135 bool getShowTrackSelectionColour() const { return showTrackSelection; }
136 bool getShowClipSlotSelectionColour() const { return showClipSlotSelection; }
137 void setSelectionColour (juce::Colour);
138 void setShowTrackSelectionColour (bool);
139 void setShowClipSlotSelectionColour (bool);
140
141 bool shouldTrackBeColoured (int channelNum);
142 void getTrackColour (int channelNum, juce::Colour&);
143 std::optional<ColourArea> getColouredArea (const Edit&);
144
145 bool shouldPluginBeColoured (Plugin*);
146 void getPluginColour (Plugin*, juce::Colour&);
147 void repaintParamSource();
148 void redrawTracks();
149
150 ControlSurface& getControlSurface() const noexcept { return *controlSurface; }
151 template <typename Type>
152 Type* getControlSurfaceIfType() const noexcept { return dynamic_cast<Type*> (controlSurface.get()); }
153
154 ExternalControllerManager& getExternalControllerManager() const noexcept { return controlSurface->externalControllerManager; }
155
156 Edit* getEdit() const { return getControlSurface().getEdit(); }
157 TransportControl* getTransport() const noexcept { return getControlSurface().getTransport(); }
158
159 static juce::String shortenName (juce::String, int maxLen);
160
161 juce::String getInputDeviceName (int idx) const { return inputDeviceNames[idx]; }
162 juce::String getOutputDeviceName (int idx) const { return outputDeviceNames[idx]; }
163
164 juce::StringArray getMidiInputPorts() const;
165 juce::StringArray getMidiOutputPorts() const;
166
167 static juce::String getNoDeviceSelectedMessage();
168
169 Engine& engine;
170
171private:
172 void timerCallback() override;
173 void changeListenerCallback (juce::ChangeBroadcaster*) override;
174
175 static constexpr int maxDevices = 4;
176 friend class ExternalControllerManager;
177 friend class ControlSurface;
178 friend class MackieC4;
179 friend class MackieMCU;
180
181 int numDevices = 1;
182 int mainDevice = 0;
183 juce::StringArray inputDeviceNames, outputDeviceNames;
184
185 std::unique_ptr<ControlSurface> controlSurface;
186 int oscInputPort, oscOutputPort;
187 juce::String oscOutputAddr;
188
189 bool enabled;
190 mutable std::optional<bool> hasMidiInput;
191 int maxTrackNameChars;
192 int channelStart = 0;
193 int padStart = 0;
194 int startParamNumber = 0;
195 bool needsBackChannel = false;
196 bool needsChannel = false;
197 bool needsOSC = false;
198 bool usesSettings = false;
199 bool deletable = false;
200 bool allowBankingOffEnd = false;
201 AutomatableParameter::Array currentParams;
202 SafeSelectable<Selectable> currentParamSource, lastRegisteredSelectable;
203 bool showTrackSelection = false;
204 bool showClipSlotSelection = true;
205 juce::Colour selectionColour;
206 int startMarkerNumber = 0;
207 int auxBank = 0;
208 bool followsTrackSelection;
209 bool processMidi = false, updateParams = false;
210
212 std::vector<MidiOutputDevice*> outputDevices;
213
215 juce::CriticalSection incomingMidiLock;
216
217 int getMarkerBankOffset() const { return startMarkerNumber; }
218 int getFaderBankOffset() const { return channelStart; }
219 int getAuxBankOffset() const { return auxBank; }
220 int getParamBankOffset() const { return startParamNumber; }
221 int getClipSlotOffset() const { return padStart; }
222
223 void changeFaderBank (int delta, bool moveSelection);
224 void changePadBank (int delta);
225 void changeParamBank (int delta);
226 void updateParamList();
227 void changeMarkerBank (int delta);
228 void changeAuxBank (int delta);
229 void setAuxBank (int num);
230
231 void userMovedParameterControl (int paramNumber, float newValue, bool delta);
232 void userPressedParameterControl (int paramNumber);
233 void userPressedGoToMarker (int marker);
234
235 Plugin* getCurrentPlugin() const;
236
237 bool wantsClock;
238
240};
241
242}} // namespace tracktion { inline namespace engine
Base class for types of control surface.
The Tracktion Edit class!
The Engine is the central class for all tracktion sessions.
Keeps a list of external controllers and keeps them connected to the right MIDI in/out devices.
Acts as a holder for a ControlSurface object.
void currentValueChanged(AutomatableParameter &) override
Called when the current value of the parameter changed, either from setting the parameter,...
void curveHasChanged(AutomatableParameter &) override
Called when the automation curve has changed, point time, value or curve.
Holds a pointer to some type of Selectable, which automatically becomes null if the selectable is del...
Base class for things that can be selected, and whose properties can appear in the properties panel.
Manages a list of items that are currently selected.
MuteAndSoloLightState
Determines the status of the mute and solo indicators.
Controls the transport of an Edit's playback.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
bool isRecording(EditPlaybackContext &epc)
Returns true if any inputs are currently recording.