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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_AudioFile.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{
21
22 static AudioFileInfo parse (const AudioFile&);
23
24 Engine* engine = nullptr;
25 bool wasParsedOk = false;
26 HashCode hashCode = 0;
27 juce::AudioFormat* format = nullptr;
28 double sampleRate = 0;
29 SampleCount lengthInSamples = 0;
30 int numChannels = 0;
31 int bitsPerSample = 0;
32 bool isFloatingPoint = false;
33 bool needsCachedProxy = false;
34 juce::StringPairArray metadata;
35 juce::Time fileModificationTime;
36 LoopInfo loopInfo;
37
38 double getLengthInSeconds() const noexcept
39 {
40 if (sampleRate > 0)
41 return lengthInSamples / sampleRate;
42
43 return 0.0;
44 }
45
46 juce::String getLongDescription() const;
47};
48
49//==============================================================================
53{
54public:
55 AudioFile() = delete;
56 inline AudioFile (Engine& e) noexcept : engine (&e) {}
57 explicit AudioFile (Engine&, const juce::File&) noexcept;
58 AudioFile (const AudioFile&) noexcept;
59 AudioFile& operator= (const AudioFile&) noexcept;
60 ~AudioFile();
61
62 const juce::File& getFile() const noexcept { return file; }
63 HashCode getHash() const noexcept { return hash; }
64 juce::String getHashString() const { return juce::String::toHexString (hash); }
65
66 inline bool operator== (const AudioFile& other) const noexcept { return hash == other.hash; }
67 inline bool operator!= (const AudioFile& other) const noexcept { return hash != other.hash; }
68
69 bool deleteFile() const;
70 static bool deleteFiles (Engine&, const juce::Array<juce::File>& files);
71
72 bool moveToTrash() const;
73
74 //==============================================================================
75 bool isNull() const noexcept { return hash == 0; }
76 bool isValid() const;
77
78 AudioFileInfo getInfo() const;
79
80 int64_t getLengthInSamples() const;
81 double getLength() const;
82 int getNumChannels() const;
83 double getSampleRate() const;
84 int getBitsPerSample() const;
85 bool isFloatingPoint() const;
86 juce::StringPairArray getMetadata() const;
87
88 juce::AudioFormat* getFormat() const;
89
90 bool isWavFile() const;
91 bool isAiffFile() const;
92 bool isOggFile() const;
93 bool isMp3File() const;
94 bool isFlacFile() const;
95 bool isRexFile() const;
96
97 Engine* engine = nullptr;
98
99private:
100 juce::File file;
101 HashCode hash = 0;
102};
103
104}} // namespace tracktion { inline namespace engine
static String toHexString(IntegerType number)
The Engine is the central class for all tracktion sessions.
Holds tempo/beat information about an audio file.
typedef int64_t