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

Method ProcessOne

libraries/lib-builtin-effects/PaulstretchBase.cpp:185–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183}
184
185bool PaulstretchBase::ProcessOne(
186 const WaveChannel& track, WaveChannel& outputTrack, double t0, double t1,
187 int count)
188{
189 const auto badAllocMessage = XO("Requested value exceeds memory capacity.");
190
191 const auto rate = track.GetTrack().GetRate();
192 const auto stretch_buf_size = GetBufferSize(rate);
193 if (stretch_buf_size == 0)
194 {
195 BasicUI::ShowMessageBox(badAllocMessage);
196 return {};
197 }
198
199 double amount = this->mAmount;
200
201 auto start = track.TimeToLongSamples(t0);
202 auto end = track.TimeToLongSamples(t1);
203 auto len = end - start;
204
205 const auto minDuration = stretch_buf_size * 2 + 1;
206 if (minDuration < stretch_buf_size)
207 {
208 // overflow!
209 BasicUI::ShowMessageBox(badAllocMessage);
210 return {};
211 }
212
213 if (len < minDuration)
214 { // error because the selection is too short
215
216 float maxTimeRes = log(len.as_double()) / log(2.0);
217 maxTimeRes = pow(2.0, floor(maxTimeRes) + 0.5);
218 maxTimeRes = maxTimeRes / rate;
219
220 using namespace BasicUI;
221 if (this->IsPreviewing())
222 {
223 double defaultPreviewLen;
224 gPrefs->Read(
225 wxT("/AudioIO/EffectsPreviewLen"), &defaultPreviewLen, 6.0);
226
227 if ((minDuration / mProjectRate) < defaultPreviewLen)
228 {
229 ShowMessageBox(
230 /* i18n-hint: 'Time Resolution' is the name of a control in the
231 Paulstretch effect.*/
232 XO("Audio selection too short to preview.\n\n"
233 "Try increasing the audio selection to at least %.1f seconds,\n"
234 "or reducing the 'Time Resolution' to less than %.1f seconds.")
235 .Format(
236 (minDuration / rate) + 0.05, // round up to 1/10 s.
237 floor(maxTimeRes * 10.0) / 10.0),
238 MessageBoxOptions {}.IconStyle(Icon::Warning));
239 }
240 else
241 {
242 ShowMessageBox(

Callers

nothing calls this directly

Calls 11

ShowMessageBoxFunction · 0.85
TimeToLongSamplesMethod · 0.80
get_nsamples_for_fillMethod · 0.80
get_nsamplesMethod · 0.80
GetRateMethod · 0.45
GetTrackMethod · 0.45
ReadMethod · 0.45
getMethod · 0.45
GetFloatsMethod · 0.45
processMethod · 0.45
AppendMethod · 0.45

Tested by

no test coverage detected