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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_RenderOptions.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
14//==============================================================================
20{
21public:
22 enum TargetFileFormat
23 {
24 wav = 0,
25 aiff,
26 flac,
27 ogg,
28 mp3,
29 midi,
30 numFormats
31 };
32
35 {
36 addTrack = 0,
37 replaceTrack = 1,
38 nextTrack = 2,
39 thisTrack = 3,
40 replaceClips = 4,
41 none = 5,
42 };
43
44 //==============================================================================
48 ~RenderOptions() override;
49
50 RenderOptions() = delete;
51 RenderOptions (const RenderOptions&) = delete;
52 RenderOptions (RenderOptions&&) = delete;
53 RenderOptions operator= (const RenderOptions&) = delete;
54 RenderOptions operator= (RenderOptions&&) = delete;
55
56 void loadFromUserSettings();
57 void saveToUserSettings();
58 void setToDefault();
59
60 //==============================================================================
63
64 //==============================================================================
66 HashCode getHash() const noexcept { return hash; }
67
73
76
79
80 //==============================================================================
83 static std::unique_ptr<RenderOptions> forTrackRender (juce::Array<Track*> tracks, AddRenderOptions addOption);
84 static std::unique_ptr<RenderOptions> forClipRender (juce::Array<Clip*> clips, bool midiNotes);
85 static std::unique_ptr<RenderOptions> forEditClip (Clip& editClip);
86
87 //==============================================================================
91 bool getUINeedsRefresh();
92 void setUINeedsRefresh();
93
94 //==============================================================================
96 enum class RenderType
97 {
98 editClip = 0,
99 clip,
100 track,
101 midi,
102 allExport
103 };
104
105 bool isEditClipRender() const { return type == RenderType::editClip; }
106 bool isClipRender() const { return type == RenderType::clip; }
107 bool isTrackRender() const { return type == RenderType::track; }
108 bool isMidiRender() const { return type == RenderType::midi; }
109 bool isExportAll() const { return type == RenderType::allExport; }
110 bool isRender() const { return isTrackRender() || isClipRender() || isMidiRender(); }
111
112 //==============================================================================
113 TargetFileFormat setFormat (TargetFileFormat);
114 void setFormatType (const juce::String& typeString);
115 juce::String getFormatTypeName (TargetFileFormat);
116
117 juce::Array<EditItemID> getTrackIDs() const { return tracks; }
118 void setTrackIDs (const juce::Array<EditItemID>&);
119 HashCode getTracksHash() const;
120
121 void setSampleRate (int);
122 void setBitDepth (int depth) { bitDepth = depth; }
123
124 juce::StringArray getQualitiesList() const;
125 int getQualityIndex() const { return qualityIndex; }
126 void setQualityIndex (int q) { qualityIndex = q; }
127
128 juce::File getDestFile() const noexcept { return destFile; }
129 juce::String getFileExtension() const;
130
131 TargetFileFormat getFormat() const noexcept { return format; }
132 int getBitDepth() const { return bitDepth; }
133 bool getStereo() const { return stereo; }
134 double getSampleRate() const { return sampleRate; }
135 bool shouldAddMetadata() const { return addMetadata; }
136
137 bool shouldAddAcidMetadata() const { return addAcidMetadata; }
138
139 juce::BigInteger getTrackIndexes (const Edit&) const;
140 bool getRemoveSilence() const noexcept { return removeSilence; }
141 bool getMarkedRegion() const noexcept { return markedRegion; }
142 int getNumTracks() const noexcept { return tracks.size(); }
143
144 void setSelected (bool onlySelectedTrackAndClips);
145 void setMarkedRegion (bool onlyMarked) { markedRegion = onlyMarked; }
146 void setIncludePlugins (bool includePlugins) { usePlugins = includePlugins; }
147 void setAddRenderOption (AddRenderOptions options) { addRenderOptions = options; }
148 void setEndAllowance (TimeDuration time) { endAllowance = time; }
149 void setFilename (juce::String, bool canPromptToOverwriteExisting);
150 void updateHash();
151
152 //==============================================================================
153 juce::StringArray getFormatTypes();
154 juce::StringArray getAddRenderOptionText();
155
156 static TimeDuration findEndAllowance (Edit&, juce::Array<EditItemID>* tracks, juce::Array<Clip*>*);
157 static bool isMarkedRegionBigEnough (TimeRange);
158
159 Engine& engine;
160
162 juce::CachedValue<juce::String> tracksProperty;
163
164 juce::CachedValue<bool> createMidiFile;
167 juce::CachedValue<double> sampleRate;
168 juce::CachedValue<int> bitDepth, qualityIndex;
169 juce::CachedValue<double> rmsLevelDb, peakLevelDb;
170
171 juce::CachedValue<bool> removeSilence, normalise, dither, adjustBasedOnRMS,
172 markedRegion, selectedTracks, selectedClips,
173 tracksToSeparateFiles, realTime, usePlugins;
174
176 juce::CachedValue<bool> addRenderToLibrary, reverseRender, addMetadata, addAcidMetadata;
177
178 // These optional lambdas will be called when the addRenderToLibrary flag
179 // is set, and can be used to do something with the finished item
180 std::function<void(AudioClipBase&)> offerToAddClipToLibrary;
181 std::function<void(const juce::File&)> offerToAddFileToLibrary;
182
183private:
184 //==============================================================================
185 juce::ValueTree state;
186
187 void relinkCachedValues (juce::UndoManager*);
188
189 void valueTreePropertyChanged (juce::ValueTree&, const juce::Identifier&) override;
190 void valueTreeChildAdded (juce::ValueTree&, juce::ValueTree&) override {}
191 void valueTreeChildRemoved (juce::ValueTree&, juce::ValueTree&, int) override {}
192 void valueTreeChildOrderChanged (juce::ValueTree&, int, int) override {}
193 void valueTreeParentChanged (juce::ValueTree&) override {}
194
195 //==============================================================================
197 juce::File destFile;
198 juce::Array<Clip*> allowedClips;
199 TimeDuration endAllowance;
200 HashCode hash = 0;
201 bool uiNeedsRefresh = true;
202
203 static void updateLastUsedRenderPath (RenderOptions&, const juce::String& itemID);
204
205 //==============================================================================
206 void updateFileName();
207 void updateOptionsForFormat();
208 void updateDefaultFilename (Edit*);
209 juce::String getCurrentFileExtension();
210};
211
212}} // namespace tracktion { inline namespace engine
213
214namespace juce
215{
216 template <>
217 struct VariantConverter<tracktion::engine::RenderOptions::RenderType>
218 {
219 static tracktion::engine::RenderOptions::RenderType fromVar (const var& v) { return (tracktion::engine::RenderOptions::RenderType) static_cast<int> (v); }
220 static var toVar (tracktion::engine::RenderOptions::RenderType v) { return static_cast<int> (v); }
221 };
222
223 template <>
224 struct VariantConverter<tracktion::engine::RenderOptions::TargetFileFormat>
225 {
226 static tracktion::engine::RenderOptions::TargetFileFormat fromVar (const var& v) { return (tracktion::engine::RenderOptions::TargetFileFormat) static_cast<int> (v); }
227 static var toVar (tracktion::engine::RenderOptions::TargetFileFormat v) { return static_cast<int> (v); }
228 };
229
230 template <>
231 struct VariantConverter<tracktion::engine::RenderOptions::AddRenderOptions>
232 {
234 static var toVar (tracktion::engine::RenderOptions::AddRenderOptions v) { return static_cast<int> (v); }
235 };
236}
A clip in an edit.
This is the main source of an Edit clip and is responsible for managing its properties.
The Tracktion Edit class!
The Engine is the central class for all tracktion sessions.
Represents a set of user properties used to control a render operation, using a ValueTree to hold the...
static std::unique_ptr< RenderOptions > forGeneralExporter(Edit &)
Creates a default RenderOptions object for a general purpose exporter.
juce::AudioFormat * getAudioFormat()
Returns an AudioFormat to use for the current render properties.
AddRenderOptions
Enum to set the options for renders.
RenderType
Enum to determine the type of UI this RenderOptions represents.
HashCode getHash() const noexcept
Returns a hash representing the current set of render options.
bool getUINeedsRefresh()
If you've chnaged a property that will cause the UI configuration to change this will return true whi...
RenderManager::Job::Ptr performBackgroundRender(Edit &, SelectionManager *, TimeRange timeRangeToRender)
Performs the render operation on a background thread.
Renderer::Parameters getRenderParameters(Edit &, SelectionManager *, TimeRange markedRegion)
Returns a set of renderer parameters which can be used to describe a render operation.
Clip::Ptr applyRenderToEdit(Edit &, ProjectItem::Ptr, TimeRange time, SelectionManager *) const
Adds the given ProjectItem to the Edit using the render properties for positioning info.
Manages a list of items that are currently selected.
time