ProcessOne() takes a track, transforms it to bunch of buffer-blocks, and executes TwoBufferProcessPass1 or TwoBufferProcessPass2 on these blocks
| 120 | // ProcessOne() takes a track, transforms it to bunch of buffer-blocks, |
| 121 | // and executes TwoBufferProcessPass1 or TwoBufferProcessPass2 on these blocks |
| 122 | bool EffectTwoPassSimpleMono::ProcessOne(WaveChannel &track, |
| 123 | WaveChannel &outTrack, sampleCount start, sampleCount end) |
| 124 | { |
| 125 | bool ret; |
| 126 | |
| 127 | // Get the length of the buffer (as double). len is |
| 128 | // used simple to calculate a progress meter, so it is easier |
| 129 | // to make it a double now than it is to do it later |
| 130 | auto len = (end - start).as_double(); |
| 131 | auto maxblock = track.GetMaxBlockSize(); |
| 132 | |
| 133 | // Initiate a processing buffer. This buffer will (most likely) |
| 134 | // be shorter than the length of the track being processed. |
| 135 | Floats buffer1{ maxblock }; |
| 136 | Floats buffer2{ maxblock }; |
| 137 | auto samples1 = limitSampleBufferSize( |
| 138 | std::min(maxblock, track.GetBestBlockSize(start)), end - start); |
| 139 | |
| 140 | // Get the samples from the track and put them in the buffer |
| 141 | track.GetFloats(buffer1.get(), start, samples1); |
| 142 | |
| 143 | // Process the first buffer with a null previous buffer |
| 144 | if (mPass == 0) |
| 145 | ret = TwoBufferProcessPass1(nullptr, 0, buffer1.get(), samples1); |
| 146 | else |
| 147 | ret = TwoBufferProcessPass2(nullptr, 0, buffer1.get(), samples1); |
| 148 | if (!ret) |
| 149 | // Return false because the effect failed. |
| 150 | return false; |
| 151 | |
| 152 | // Go through the track one buffer at a time. s counts which |
| 153 | // sample the current buffer starts at. |
| 154 | auto s = start + samples1; |
| 155 | while (s < end) { |
| 156 | // Get a block of samples (smaller than the size of the buffer) |
| 157 | // Adjust the block size if it is the final block in the track |
| 158 | auto samples2 = limitSampleBufferSize( |
| 159 | std::min(track.GetBestBlockSize(s), maxblock), end - s); |
| 160 | |
| 161 | // Get the samples from the track and put them in the buffer |
| 162 | track.GetFloats(buffer2.get(), s, samples2); |
| 163 | |
| 164 | // Process the buffer. If it fails, clean up and exit. |
| 165 | if (mPass == 0) |
| 166 | ret = TwoBufferProcessPass1(buffer1.get(), samples1, buffer2.get(), |
| 167 | samples2); |
| 168 | else |
| 169 | ret = TwoBufferProcessPass2(buffer1.get(), samples1, buffer2.get(), |
| 170 | samples2); |
| 171 | if (!ret) |
| 172 | // Return false because the effect failed. |
| 173 | return false; |
| 174 | |
| 175 | // Processing succeeded. copy the newly-changed samples back |
| 176 | // onto the track. |
| 177 | if (mSecondPassDisabled || mPass != 0) { |
| 178 | if (!outTrack.SetFloats(buffer1.get(), s - samples1, |
| 179 | samples1)) |
nothing calls this directly
no test coverage detected