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

Method GetSamples

src/toolbars/TranscriptionToolBar.cpp:443–481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

441}
442
443void TranscriptionToolBar::GetSamples(
444 const WaveTrack *t, sampleCount *s0, sampleCount *slen)
445{
446 // GetSamples attempts to translate the start and end selection markers into sample indices
447 // These selection numbers are doubles.
448
449 AudacityProject *p = &mProject;
450 if (!p) {
451 return;
452 }
453
454 //First, get the current selection. It is part of the mViewInfo, which is
455 //part of the project
456
457 const auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
458 double start = selectedRegion.t0();
459 double end = selectedRegion.t1();
460
461 auto ss0 = sampleCount( (start - t->GetStartTime()) * t->GetRate() );
462 auto ss1 = sampleCount( (end - t->GetStartTime()) * t->GetRate() );
463
464 if (start < t->GetStartTime()) {
465 ss0 = 0;
466 }
467
468#if 0
469 //This adjusts the right samplecount to the maximum sample.
470 if (ss1 >= t->GetNumSamples()) {
471 ss1 = t->GetNumSamples();
472 }
473#endif
474
475 if (ss1 < ss0) {
476 ss1 = ss0;
477 }
478
479 *s0 = ss0;
480 *slen = ss1 - ss0;
481}
482
483// PRL: duplicating constants from TimeTrack.cpp
484//TODO-MB: are these sensible values?

Callers 1

DrawIndividualSamplesFunction · 0.45

Calls 5

GetFunction · 0.85
sampleCountClass · 0.70
GetStartTimeMethod · 0.45
GetRateMethod · 0.45
GetNumSamplesMethod · 0.45

Tested by

no test coverage detected