MCPcopy Create free account
hub / github.com/audacity/audacity / CrossFadeMix

Method CrossFadeMix

src/CrossFade.cpp:59–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59bool CrossFader::CrossFadeMix(samplePtr buffer, sampleFormat format, sampleCount start, size_t len)
60{
61
62 std::cout << "Crossfading from " << start.as_long_long()
63 << " to " << ( len + start ).as_long_long()
64 << std::endl;
65
66 // start refers to the position in the wave.
67
68
69 //just mix the right things together.
70
71
72 //For each relevant clip, we need to construct a buffer.
73 //we should use one of the size len, because this has already
74 //been determined to be good in Mixer
75
76 //Go through each clip, adding it to the total in the appropriate way.
77
78 //this could be 'optimized' by getting all of the sequences and then
79 //iterating through each of them.
80
81 int numclips = mClips.size();
82
83 //create vectors to store the important info for each clip.
84 std::vector<sampleCount> clipStart(numclips);
85 std::vector<sampleCount> clipLength(numclips);
86 std::vector<Sequence*> tmpSequence(numclips);
87
88
89 unsigned int i = 0;
90 //Now, go through the clips and load up the vectors.
91 for(const auto &tmpclip: mClips)
92 {
93 tmpSequence[i] = tmpclip->GetSequence();
94
95
96 //start is the position of the beginning of the buffer
97 //relative to the beginning of the clip. It could be negative.
98 clipStart[i]= start - tmpclip->GetStartSample();
99
100
101
102 //determine the index of the last sample to get, relative to the start of the clip
103
104 //it will be no longer than the clip itself.
105 clipLength[i] = tmpclip->GetNumSamples()-clipStart[i];
106
107 std::cout << "X:" << " "
108 << clipLength[i].as_long_long()
109 << " "
110 << tmpclip->GetStartSample().as_long_long()
111 << " ";
112 //if the buffer ends before the clip does, adjust the length
113 if(clipStart[i] + len < clipLength[i])
114 {
115 clipLength[i] = len + clipStart[i];
116 }

Callers

nothing calls this directly

Calls 4

GetStartSampleMethod · 0.80
sizeMethod · 0.45
GetNumSamplesMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected