| 441 | } |
| 442 | |
| 443 | void 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? |
no test coverage detected