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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_SmartThumbnail.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//==============================================================================
22 private juce::Timer
23{
24public:
25 //==============================================================================
31 SmartThumbnail (Engine&, const AudioFile&, juce::Component& componentToRepaint, Edit*);
32
39 SmartThumbnail (Engine&, const AudioFile&, juce::Component& componentToRepaint, Edit*,
41
43 ~SmartThumbnail() override;
44
46 static void setEnabled (bool e) { enabled = e; }
47
49 static bool areThumbnailsFullyLoaded (Engine&);
50
51 //==============================================================================
53 void setNewFile (const AudioFile&);
54
56 bool isGeneratingProxy() const noexcept { return wasGeneratingProxy; }
57
59 float getProxyProgress() const noexcept { return lastProgress; }
60
62 bool isOutOfDate() const noexcept { return thumbnailIsInvalid; }
63
64 //==============================================================================
67 TimeRange, int channelNum, float verticalZoomFactor);
68
71 TimeRange, float verticalZoomFactor);
72
74 double getProportionComplete() const noexcept;
75
76 //==============================================================================
78 void clear() override;
80 bool setSource (juce::InputSource*) override;
82 void setReader (juce::AudioFormatReader*, juce::int64 hashCode) override;
84 bool loadFrom (juce::InputStream&) override;
86 void saveTo (juce::OutputStream&) const override;
88 int getNumChannels() const noexcept override;
90 double getTotalLength() const noexcept override;
92 bool isFullyLoaded() const noexcept override;
94 juce::int64 getNumSamplesFinished() const noexcept override;
96 float getApproximatePeak() const override;
98 void getApproximateMinMax (double startTime, double endTime, int channelIndex,
99 float& minValue, float& maxValue) const noexcept override;
101 juce::int64 getHashCode() const override;
103 void reset (int numChannels, double sampleRate, juce::int64 totalSamplesInSource) override;
105 void addBlock (juce::int64 sampleNumberInSource, const juce::AudioBuffer<float>&,
106 int startOffsetInBuffer, int numSamples) override;
107
108 //==============================================================================
110 void audioFileChanged();
112 void releaseFile();
113
114 //==============================================================================
115 AudioFile file;
116 Engine& engine;
117 Edit* const edit = nullptr;
118
119private:
120 //==============================================================================
121 std::unique_ptr<juce::AudioThumbnailBase> thumbnail;
122 juce::Component& component;
123 bool wasGeneratingProxy = false;
124 std::atomic<bool> thumbnailIsInvalid { true };
125 float lastProgress = 0.0f;
126
127 void timerCallback() override;
128 void fileWasChanged();
129 void createThumbnailReader();
130
131 static bool enabled;
132
136 double startTimeSeconds,
137 double endTimeSeconds,
138 int channelNum,
139 float verticalZoomFactor) override;
143 double startTimeSeconds,
144 double endTimeSeconds,
145 float verticalZoomFactor) override;
146
149};
150
151}} // namespace tracktion { inline namespace engine
The Tracktion Edit class!
The Engine is the central class for all tracktion sessions.
SmartThumnail automatically tracks changes to an AudioFile and will update its cache if the file chan...
double getProportionComplete() const noexcept
Returns the proportion of the thumbnail that has been generated.
static void setEnabled(bool e)
Enable/disable all smart thumbnail generation.
static bool areThumbnailsFullyLoaded(Engine &)
Returns true if any thumbnails are currently being generated for the given Edit.
bool isGeneratingProxy() const noexcept
Returns true if this is a proxy file being generated by the AudioProxyGenerator.
void drawChannels(juce::Graphics &, juce::Rectangle< int >, TimeRange, float verticalZoomFactor)
Draws all of the channels, optionally using a hi-res algorithm.
void drawChannel(juce::Graphics &, juce::Rectangle< int >, TimeRange, int channelNum, float verticalZoomFactor)
Draws one of the channels, optionally using a hi-res algorithm.
float getProxyProgress() const noexcept
Returns the progress of the current proxy file creation.
void setNewFile(const AudioFile &)
Sets a new file to display.
bool isOutOfDate() const noexcept
Returns true if the file has been changed and a new thumbnail has not yet been generated.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
#define JUCE_DECLARE_WEAK_REFERENCEABLE(Class)