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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_AudioTrack.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
15class AudioTrack : public ClipTrack,
17 private juce::Timer
18{
19public:
21 ~AudioTrack() override;
22
24
25 void initialise() override;
26 bool isAudioTrack() const override { return true; }
27
28 //==============================================================================
30
31 //==============================================================================
32 // This isn't an index - it starts from 1
33 int getAudioTrackNumber() const noexcept;
34
36 void sanityCheckName() override;
37 juce::String getName() const override;
38
40 juce::String getNameAsTrackNumber() const;
41
46
47 bool canContainPlugin (Plugin*) const override;
48 bool processAudioNodesWhileMuted() const override { return edit.engine.getEngineBehaviour().shouldProcessMutedTracks() || isSidechainSource(); }
49
52
53 //==============================================================================
56 juce::String getLauncherPlayabilityWarning() const;
57
58 //==============================================================================
59 VolumeAndPanPlugin* getVolumePlugin();
60 LevelMeterPlugin* getLevelMeterPlugin();
61 EqualiserPlugin* getEqualiserPlugin();
62 AuxSendPlugin* getAuxSendPlugin (int bus = -1, AuxPosition ap = AuxPosition::byBus) const; // -1 == any bus, first aux found
63
64 //==============================================================================
68 juce::String getNameForMidiNoteNumber (int note, int midiChannel, bool preferSharp = true) const;
69
71 juce::String getNameForProgramNumber (int programNumber, int bank) const;
72 juce::String getNameForBank (int bank) const;
73 int getIdForBank (int bank) const;
74 bool areMidiPatchesZeroBased() const;
75
76 //==============================================================================
77 WaveInputDevice& getWaveInputDevice() const noexcept { jassert (waveInputDevice); return *waveInputDevice; }
78 MidiInputDevice& getMidiInputDevice() const noexcept { jassert (midiInputDevice); return *midiInputDevice; }
79
80 TrackOutput& getOutput() const noexcept { return *output; }
81
82 int getMaxNumOfInputs() const noexcept { return maxInputs; }
83 void setMaxNumOfInputs (int newMaxNumber);
84
87 bool canPlayAudio() const;
88 bool canPlayMidi() const;
89
90 //==============================================================================
92 ClipSlotList& getClipSlotList();
93
94 //==============================================================================
95 bool isFrozen (FreezeType) const override;
96 void setFrozen (bool, FreezeType) override;
97 void insertFreezePointAfterPlugin (const Plugin::Ptr&);
98 void removeFreezePoint();
99 void freezeTrackAsync() const;
100
101 //==============================================================================
102 bool hasAnyLiveInputs();
103 bool hasAnyTracksFeedingIn();
104
105 juce::Array<Track*> getInputTracks() const override;
106 juce::Array<Track*> findSidechainSourceTracks() const;
107
108 void injectLiveMidiMessage (const MidiMessageArray::MidiMessageWithSource&);
109 void injectLiveMidiMessage (const juce::MidiMessage&, MidiMessageArray::MPESourceID);
110
111 //==============================================================================
112 bool isMuted (bool includeMutingByDestination) const override;
113 bool isSolo (bool includeIndirectSolo) const override;
114 bool isSoloIsolate (bool includeIndirectSolo) const override;
115
116 void setMute (bool) override;
117 void setSolo (bool) override;
118 void setSoloIsolate (bool) override;
119
120 //==============================================================================
122 double getMidiVisibleProportion() const;
123 double getMidiVerticalOffset() const;
124 void setMidiVerticalPos (double visibleProp, double offset);
125 void scaleVerticallyToFitMidi();
126 void setVerticalScaleToDefault();
127
128 void setTrackToGhost (AudioTrack*, bool shouldGhost);
129 void clearGhostTracks() { ghostTracks.resetToDefault(); }
130 juce::Array<AudioTrack*> getGhostTracks() const;
131
132 int getCompGroup() const noexcept { return compGroup.get(); }
133 void setCompGroup (int groupIndex) { compGroup = groupIndex; }
134
135 //==============================================================================
136 bool hasMidiNoteNames() { return midiNoteMapCache.size() > 0; }
137 void clearMidiNoteNames() { midiNoteMap = juce::String(); }
138 void loadMidiNoteNames (const juce::String namesFile) { midiNoteMap = namesFile; }
139
140 //==============================================================================
145 bool mergeInMidiSequence (juce::MidiMessageSequence, TimePosition startTime,
147
148 void playGuideNote (int note, MidiChannel midiChannel, int velocity,
149 bool stopOtherFirst = true, bool forceNote = false, bool autorelease = false);
150
151 void playGuideNotes (const juce::Array<int>& notes, MidiChannel midiChannel,
152 const juce::Array<int>& velocities,
153 bool stopOthersFirst = true);
154
155 void turnOffGuideNotes();
156 void turnOffGuideNotes (MidiChannel);
157
158 //==============================================================================
166
167 //==============================================================================
169 struct Listener
170 {
171 /* Destructor */
172 virtual ~Listener() = default;
173
179
184 };
185
189 void addListener (Listener*);
190
192 void removeListener (Listener*);
193
196
197protected:
198 void valueTreePropertyChanged (juce::ValueTree&, const juce::Identifier&) override;
199 void valueTreeParentChanged (juce::ValueTree& v) override;
200
201 bool isTrackAudible (bool areAnyTracksSolo) const override;
202
203 void timerCallback() override { turnOffGuideNotes(); }
204
205private:
206 //==============================================================================
207 struct TrackMuter;
208 struct FreezeUpdater;
209 friend struct TrackMuter;
210 friend class Edit;
211 friend class Clip;
212
213 //==============================================================================
215 std::unique_ptr<WaveInputDevice> waveInputDevice;
216 std::unique_ptr<MidiInputDevice> midiInputDevice;
217
218 juce::CachedValue<bool> muted, soloed, soloIsolated;
219 juce::CachedValue<bool> frozen, frozenIndividually;
220
221 int freezePointRemovalInhibitor = 0;
222 juce::CachedValue<int> maxInputs, compGroup;
223
226
227 std::map<int, juce::String> midiNoteMapCache;
228
229 juce::Array<int> currentlyPlayingGuideNotes;
230
231 std::unique_ptr<FreezeUpdater> freezeUpdater;
233
234 enum { updateAutoCrossfadesFlag = 1 };
235 AsyncFunctionCaller asyncCaller;
236
239
240 double defaultMidiVisibleProportion = 0, defaultMidiVerticalOffset = 0;
241
242 //==============================================================================
243 void freezeTrack();
244 bool insertFreezePointIfRequired();
245 int getIndexOfDefaultFreezePoint();
246 int getIndexOfFreezePoint();
247 void freezePlugins (juce::Range<int> pluginsToFreeze);
248 void unFreezeTrack();
249 juce::File getFreezeFile() const;
250
251 void updateTracksToGhost();
252 bool isSidechainSource() const;
253
254 void updateMidiNoteMapCache();
255
256 //==============================================================================
258};
259
260}} // namespace tracktion { inline namespace engine
Type get() const noexcept
ClipSlotList & getClipSlotList()
Returns the ClipSlotList for this track.
bool canContainPlugin(Plugin *) const override
Returns true if this track can contain a specific Plugin.
bool mergeInMidiSequence(juce::MidiMessageSequence, TimePosition startTime, MidiClip *, MidiList::NoteAutomationType)
try to add this MIDI sequence to any MIDI clips that are already in the track.
bool canPlayAudio() const
checks whether audio clips can be played - i.e.
juce::CachedValue< AtomicWrapper< bool > > playSlotClips
Determines if the track's arrange clips or clip slots should be audible.
juce::String getNameForMidiNoteNumber(int note, int midiChannel, bool preferSharp=true) const
looks for a name for a midi note by trying all the plugins, and returning a default on failure.
bool processAudioNodesWhileMuted() const override
Subclasses can override this to ensure track contents are still played even when the track is muted.
bool isSolo(bool includeIndirectSolo) const override
Returns true if this track is soloed.
void initialise() override
Initialises the Track.
juce::ListenerList< Listener > & getListeners()
Returns the listener list so Nodes can manually call them.
void sanityCheckName() override
checks whether the name is 'track n' and if so, makes sure the number is right
bool isTrackAudible(bool areAnyTracksSolo) const override
Returns whether this Track should be audible.
juce::String getTrackPlayabilityWarning() const
returns a warning message about this track not being playable, or "" if it's ok
bool isFrozen(FreezeType) const override
Returns true if this track is frozen using the given type.
void setSolo(bool) override
Subclasses should implement this to solo themselves.
void removeListener(Listener *)
Removes a Listener.
void addListener(Listener *)
Adds a Listener.
bool isMuted(bool includeMutingByDestination) const override
Returns true if this track is muted.
void setFrozen(bool, FreezeType) override
Attempts to freeze or unfreeze the track using a given FreezeType.
void setSoloIsolate(bool) override
Subclasses should implement this to solo isolate themselves.
bool isAudioTrack() const override
Returns true if this is an AudioTrack.
void setMute(bool) override
Subclasses should implement this to mute themselves.
bool isSoloIsolate(bool includeIndirectSolo) const override
Returns true if this track is solo isolated.
double getMidiVisibleProportion() const
vertical scales for displaying the midi note editor
juce::String getNameAsTrackNumberWithDescription() const
Returns a name in the form "Track [number] ([track name])" (This is smart enough to not add the paren...
juce::String getSelectableDescription() override
Subclasses must return a description of what they are.
juce::String getNameForProgramNumber(int programNumber, int bank) const
prog number is 0 based.
juce::Array< Track * > getInputTracks() const override
Should return any tracks which feed into this track.
juce::String getNameAsTrackNumber() const
Returns a name in the form "Track [number]".
A clip in an edit.
The Tracktion Edit class!
Engine & engine
A reference to the Engine.
virtual bool shouldProcessMutedTracks()
Should muted tracks processing be disabled to save CPU.
EngineBehaviour & getEngineBehaviour() const
Returns the EngineBehaviour instance.
Base class for elements which can contain macro parameters.
Represents the destination output device(s) for a track.
FreezeType
Determines the type of freeze.
The built-in Tracktion volume/pan plugin.
#define jassert(expression)
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
T size(T... args)
Prevents the freeze point from being removed during an unfreeze operation.
Listener interface to be notified of recorded MIDI being sent to the plugins.
virtual void injectLiveMidiMessage(AudioTrack &, const MidiMessageArray::MidiMessageWithSource &, bool &wasUsed)=0
Called when a MidiMessage (i.e.
virtual void recordedMidiMessageSentToPlugins(AudioTrack &, const juce::MidiMessage &)=0
Called when a recorded MidiMessage (i.e.