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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_ReverseRenderJob.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:
26 const juce::File& source,
27 const juce::File& destination)
28 {
29 AudioFile targetFile (e, destination);
30
31 if (auto ptr = e.getRenderManager().getRenderJobWithoutCreating (targetFile))
32 return ptr;
33
34 return *new ReverseRenderJob (e, source, targetFile);
35 }
36
37protected:
38 //==============================================================================
39 bool setUpRender() override { return true; }
40
41 bool renderNextBlock() override
42 {
44
46 success = AudioFileUtils::reverse (engine, source, tempFile.getFile(), progress, this);
47
48 if (success)
49 {
50 tempFile.overwriteTargetFileWithTemporary();
51 }
52 else
53 {
54 // if we fail here just copy the source to the destination to avoid loops
55 source.copyFileTo (proxy.getFile());
57 }
58
59 // validates the AudioFile by giving it a sample rate etc.
60 engine.getAudioFileManager().checkFileForChangesAsync (proxy);
61
62 return true;
63 }
64
65 bool completeRender() override { return success; }
66
67private:
68 //==============================================================================
69 ReverseRenderJob (Engine& e, const juce::File& src, const AudioFile& destination)
70 : Job (e, destination), source (src)
71 {
72 }
73
74 juce::File source;
75 bool success = false;
76
78};
79
80}} // namespace tracktion { inline namespace engine
bool copyFileTo(const File &targetLocation) const
The Engine is the central class for all tracktion sessions.
RenderManager & getRenderManager() const
Returns the RenderManager instance.
AudioFileManager & getAudioFileManager() const
Returns the AudioFileManager instance.
The base class that all generator jobs derive from.
Job::Ptr getRenderJobWithoutCreating(const AudioFile &audioFile)
This will return a Ptr to an existing render job for an audio file or nullptr if no job is in progres...
bool setUpRender() override
Subclasses should override this to set-up their render process.
bool renderNextBlock() override
During a render process this will be repeatedly called.
bool completeRender() override
This is called once after all the render blocks have completed.
static Ptr getOrCreateRenderJob(Engine &e, const juce::File &source, const juce::File &destination)
Returns a job that will have been started to generate the Render described by the params.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
#define jassertfalse
static bool reverse(Engine &, const juce::File &source, const juce::File &destination, std::atomic< float > &progress, juce::ThreadPoolJob *job=nullptr, bool canCreateWavIntermediate=true)
Reverses a file updating a progress value and checking the exit status of a given job.
#define CRASH_TRACER
This macro adds the current location to a stack which gets logged if a crash happens.