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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_AudioSegmentList.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//==============================================================================
19{
20public:
21 //==============================================================================
23 static std::unique_ptr<AudioSegmentList> create (AudioClipBase&, bool relativeTime, bool crossFade);
26
29 struct Segment
30 {
31 Segment() = default;
32
33 TimeRange getRange() const;
34 SampleRange getSampleRange() const;
35
36 float getStretchRatio() const;
37 float getTranspose() const;
38
39 bool hasFadeIn() const;
40 bool hasFadeOut() const;
41
42 bool isFollowedBySilence() const;
43 HashCode getHashCode() const;
44
45 bool operator== (const Segment&) const;
46 bool operator!= (const Segment&) const;
47
48 TimePosition start;
49 TimeDuration length;
50 SampleCount startSample = 0, lengthSample = 0;
51 float stretchRatio = 1.0f, transpose = 0;
52 bool fadeIn = false, fadeOut = false;
53 bool followedBySilence = false;
54 };
55
56 const juce::Array<Segment>& getSegments() const { return segments; }
57
58 TimePosition getStart() const;
59 TimePosition getEnd() const;
60 TimeDuration getLength() const { return getEnd() - getStart(); }
61 TimeDuration getCrossfadeLength() const { return crossfadeTime; }
62
63 bool operator== (const AudioSegmentList&) const noexcept;
64 bool operator!= (const AudioSegmentList&) const noexcept;
65
66private:
67 //==============================================================================
68 AudioSegmentList (AudioClipBase&);
69 AudioSegmentList (AudioClipBase&, bool relativeTime, bool crossfade);
70
71 void chopSegmentsForChords();
72 void chopSegment (Segment&, TimePosition at, int insertPos);
73
74 AudioClipBase& clip;
75 juce::Array<Segment> segments;
76 TimeDuration crossfadeTime;
77 bool relativeTime = true;
78
79 void build (bool crossfade);
80 void buildAutoTempo (bool crossfade);
81 void buildNormal (bool crossfade);
82 float getPitchAt (TimePosition);
83 void removeExtraSegments();
84 void crossFadeSegments();
85 void mergeSegments (double sampleRate);
86 void initialiseSegment (Segment&, BeatPosition startBeat, BeatPosition endBeat, double sampleRate);
87
89};
90
91}} // namespace tracktion { inline namespace engine
Base class for Clips that produce some kind of audio e.g.
Holds a list of audio regions for playback of things like warp time.
Holds tempo/beat information about an audio file.
A WarpTimeManager contains a list of WarpMarkers and some source material and maps times from a linea...
Represents a duration in real-life time.
Represents a position in real-life time.