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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_MidiLearn.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{
19public:
22
23 void setActive (bool shouldBeActive);
24 bool isActive() { return learnActive; }
25
26 enum ChangeType
27 {
28 added,
29 removed
30 };
31
32 void assignmentChanged (ChangeType t);
33
43
44 //==============================================================================
49 struct Listener
50 {
52 virtual ~Listener();
53
54 virtual void midiLearnStatusChanged (bool isActive) = 0;
55 virtual void midiLearnAssignmentChanged (ChangeType) {}
56
57 MidiLearnState& ownerState;
58 };
59
60 Engine& engine;
61
62private:
64 bool learnActive = false;
65
66 void addListener (Listener* l) { listeners.add (l); }
67 void removeListener (Listener* l) { listeners.remove (l); }
68
70};
71
72//==============================================================================
80{
81public:
82 //==============================================================================
84 {
85 Assignment() : id (CustomControlSurface::none) {}
86 Assignment (juce::String n, CustomControlSurface::ActionID i) : name (n), id (i) {}
87
88 juce::String name;
90 };
91
92 //==============================================================================
94 virtual ~MidiAssignable() {}
95
97 void addAssignent (Assignment);
98
100 juce::Array<Assignment>& getAssignments() { return assignemnts; }
101
103 bool isSingleAssignment() const noexcept { return assignemnts.size() == 1; }
104
109
114 void handleMenuResult (int menuResult);
115
119 int getFaderIndex();
120
121 //==============================================================================
123 virtual bool isAssignable() = 0;
124
127
129 virtual Track::Ptr getControlledTrack() { return {}; }
130
131 Engine& engine;
132
133private:
134 juce::Array<Assignment> assignemnts;
135};
136
137}} // namespace tracktion { inline namespace engine
void add(ListenerClass *listenerToAdd)
void remove(ListenerClass *listenerToRemove)
ActionID
enum used to determine the action type.
The Engine is the central class for all tracktion sessions.
Base class for things that can be assigned to external control surfaces, not plugin paramters.
void addAssignent(Assignment)
Adds an assignment to the list.
void handleMenuResult(int menuResult)
If you've shown a custom menu this will be called with the result which you should handle appropriate...
int getFaderIndex()
Returns the fader index which varies depending on the track num and selected bank etc.
juce::Array< Assignment > & getAssignments()
This should return any assignments that should be shown by the pop-up component.
bool isSingleAssignment() const noexcept
Should return true if only one action can be assigned from this control.
virtual Track::Ptr getControlledTrack()
Should return the track that this control represents or nullptr if it is track independant.
void buildMenu(juce::PopupMenu &)
Builds a menu of actions that can be assigned by this control.
virtual bool isAssignable()=0
Should return true if the control is currently assignable.
virtual juce::String getDescription()=0
Should return a brief description such as "Track 1 Aux Send" or "Track 4 Record Arm".
Manages the Midi learn state and Listener interface to notify subclasses when the state changes.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Subclass this to be notified when the MidiLearn state changes.