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

Method ProcessOne

libraries/lib-builtin-effects/NormalizeBase.cpp:307–366  ·  view source on GitHub ↗

ProcessOne() takes a track, transforms it to bunch of buffer-blocks, and executes ProcessData, on it... uses mMult and offset to normalize a track. mMult must be set before this is called

Source from the content-addressed store, hash-verified

305// uses mMult and offset to normalize a track.
306// mMult must be set before this is called
307bool NormalizeBase::ProcessOne(
308 WaveChannel& track, const TranslatableString& msg, double& progress,
309 float offset)
310{
311 bool rc = true;
312
313 // Transform the marker timepoints to samples
314 auto start = track.TimeToLongSamples(mCurT0);
315 auto end = track.TimeToLongSamples(mCurT1);
316
317 // Get the length of the buffer (as double). len is
318 // used simply to calculate a progress meter, so it is easier
319 // to make it a double now than it is to do it later
320 auto len = (end - start).as_double();
321
322 // Initiate a processing buffer. This buffer will (most likely)
323 // be shorter than the length of the track being processed.
324 Floats buffer { track.GetMaxBlockSize() };
325
326 // Go through the track one buffer at a time. s counts which
327 // sample the current buffer starts at.
328 auto s = start;
329 while (s < end)
330 {
331 // Get a block of samples (smaller than the size of the buffer)
332 // Adjust the block size if it is the final block in the track
333 const auto block =
334 limitSampleBufferSize(track.GetBestBlockSize(s), end - s);
335
336 // Get the samples from the track and put them in the buffer
337 track.GetFloats(buffer.get(), s, block);
338
339 // Process the buffer.
340 ProcessData(buffer.get(), block, offset);
341
342 // Copy the newly-changed samples back onto the track.
343 if (!track.SetFloats(buffer.get(), s, block))
344 {
345 rc = false;
346 break;
347 }
348
349 // Increment s one blockfull of samples
350 s += block;
351
352 // Update the Progress meter
353 if (TotalProgress(
354 progress + ((s - start).as_double() / len) /
355 double(2 * GetNumWaveTracks()),
356 msg))
357 {
358 rc = false; // lda .. break, not return, so that buffer is deleted
359 break;
360 }
361 }
362 progress += 1.0 / double(2 * GetNumWaveTracks());
363
364 // Return true because the effect processing succeeded ... unless cancelled

Callers

nothing calls this directly

Calls 8

limitSampleBufferSizeFunction · 0.85
GetNumWaveTracksFunction · 0.85
TimeToLongSamplesMethod · 0.80
SetFloatsMethod · 0.80
GetMaxBlockSizeMethod · 0.45
GetBestBlockSizeMethod · 0.45
GetFloatsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected