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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_WarpTimeRenderJob.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//==============================================================================
18{
19public:
20 static Ptr getOrCreateRenderJob (AudioClipBase& clip,
21 const juce::File& source,
22 const juce::File& destination)
23 {
24 AudioFile targetFile (clip.edit.engine, destination);
25
26 if (auto ptr = clip.edit.engine.getRenderManager().getRenderJobWithoutCreating (targetFile))
27 return ptr;
28
29 return *new WarpTimeRenderJob (clip, source, targetFile);
30 }
31
32protected:
33 bool setUpRender() override
34 {
35 return true;
36 }
37
38 bool renderNextBlock() override
39 {
41
42 if (proxyInfo != nullptr)
43 {
44 AudioFileInfo sourceInfo (source.getInfo());
45
46 // need to strip AIFF metadata to write to wav files
47 if (sourceInfo.metadata.getValue ("MetaDataSource", "None") == "AIFF")
48 sourceInfo.metadata.clear();
49
50 AudioFileWriter writer (proxy, engine.getAudioFileFormatManager().getWavFormat(),
51 sourceInfo.numChannels, sourceInfo.sampleRate,
52 juce::jmax (16, sourceInfo.bitsPerSample),
53 sourceInfo.metadata, 0);
54
55 success = writer.isOpen() && proxyInfo->render (engine, source, writer, this, progress);
56 }
57
58 if (! shouldExit() && ! success)
59 {
60 // if we fail here just copy the source to the destination to avoid loops
61 source.getFile().copyFileTo (proxy.getFile());
63 }
64
65 return true;
66 }
67
68 bool completeRender() override { return true; }
69
70private:
71 WarpTimeRenderJob (AudioClipBase& clip, const juce::File& sourceFile, const AudioFile& destination)
72 : Job (clip.edit.engine, destination), source (clip.edit.engine, sourceFile)
73 {
74 auto tm = clip.getTimeStretchMode();
76 proxyInfo->audioSegmentList = AudioSegmentList::create (clip);
77 proxyInfo->clipTime = { {}, clip.getWarpTimeManager().getWarpEndMarkerTime() };
78 proxyInfo->speedRatio = 1.0;
79 proxyInfo->mode = (tm != TimeStretcher::disabled && tm != TimeStretcher::melodyne)
80 ? tm : TimeStretcher::defaultMode;
81 }
82
83 AudioFile source;
84 bool success = false;
86
88};
89
90}} // namespace tracktion { inline namespace engine
String getValue(StringRef, const String &defaultReturnValue) const
bool shouldExit() const noexcept
Base class for Clips that produce some kind of audio e.g.
Smart wrapper for writing to an audio file.
bool isOpen() const noexcept
Returns true if the file is open and ready to write to.
AudioFileFormatManager & getAudioFileFormatManager() const
Returns the AudioFileFormatManager that maintains a list of available audio file formats.
The base class that all generator jobs derive from.
@ melodyne
Melodyne, only used for clip timestretching.
bool completeRender() override
This is called once after all the render blocks have completed.
bool renderNextBlock() override
During a render process this will be repeatedly called.
bool setUpRender() override
Subclasses should override this to set-up their render process.
T is_pointer_v
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
#define jassertfalse
constexpr Type jmax(Type a, Type b)
#define CRASH_TRACER
This macro adds the current location to a stack which gets logged if a crash happens.