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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_TrackCompAudioNode.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
11#pragma once
12
15
16
17namespace tracktion { inline namespace engine
18{
19
20inline AudioNode* createTrackCompAudioNode (AudioNode* input,
22 const juce::Array<legacy::EditTimeRange>& nonMuteTimes,
23 double crossfadeTime)
24{
25 if (muteTimes.isEmpty())
26 return input;
27
28 input = new TimedMutingAudioNode (input, muteTimes);
29
30 for (auto r : nonMuteTimes)
31 {
32 auto fadeIn = r.withLength (crossfadeTime) - 0.0001;
33 auto fadeOut = fadeIn.movedToEndAt (r.getEnd() + 0.0001);
34
35 if (! (fadeIn.isEmpty() && fadeOut.isEmpty()))
36 input = new FadeInOutAudioNode (input, fadeIn, fadeOut,
37 AudioFadeCurve::convex,
38 AudioFadeCurve::convex, false);
39 }
40
41 return input;
42}
43
44inline AudioNode* createTrackCompAudioNode (AudioNode* input,
45 const juce::Array<TimeRange>& muteTimes,
46 const juce::Array<TimeRange>& nonMuteTimes,
47 TimeDuration crossfadeTime)
48{
51
52 for (auto t : muteTimes)
53 muteEditTimes.add ({ t.getStart().inSeconds(), t.getEnd().inSeconds() });
54
55 for (auto t : nonMuteTimes)
56 nonMuteEditTimes.add ({ t.getStart().inSeconds(), t.getEnd().inSeconds() });
57
58 return createTrackCompAudioNode (input,
59 muteEditTimes,
60 nonMuteEditTimes,
61 crossfadeTime.inSeconds());
62}
63
64inline AudioNode* createAudioNode (TrackCompManager::TrackComp& trackComp, Track& t, AudioNode* input)
65{
66 auto crossfadeTimeMs = trackComp.edit.engine.getPropertyStorage().getProperty (SettingID::compCrossfadeMs, 20.0);
67 auto crossfadeTime = TimeDuration::fromSeconds (static_cast<double> (crossfadeTimeMs) / 1000.0);
68 auto nonMuteTimes = trackComp.getNonMuteTimes (t, crossfadeTime);
69
70 return createTrackCompAudioNode (input, TrackCompManager::TrackComp::getMuteTimes (nonMuteTimes),
71 nonMuteTimes, crossfadeTime);
72}
73
74
75}} // namespace tracktion { inline namespace engine
bool isEmpty() const noexcept