| 1403 | } |
| 1404 | |
| 1405 | void SelectHandle::MoveSnappingFreqSelection( |
| 1406 | AudacityProject *pProject, ViewInfo &viewInfo, int mouseYCoordinate, |
| 1407 | int trackTopEdge, |
| 1408 | int trackHeight, ChannelView &channelView, Track *const pTrack) |
| 1409 | { |
| 1410 | if (pTrack && |
| 1411 | pTrack->GetSelected() && |
| 1412 | isSpectralSelectionView(channelView)) { |
| 1413 | auto pWc = channelView.FindChannel<const WaveChannel>(); |
| 1414 | // Spectral selection track is always wave |
| 1415 | assert(pWc); |
| 1416 | auto &wc = *pWc; |
| 1417 | // PRL: |
| 1418 | // What would happen if center snapping selection began in one spectrogram track, |
| 1419 | // then continues inside another? We do not then recalculate |
| 1420 | // the spectrum (as was done in StartSnappingFreqSelection) |
| 1421 | // but snap according to the peaks in the old track. |
| 1422 | |
| 1423 | // But if we always supply the original clicked track here that doesn't matter. |
| 1424 | const double rate = wc.GetRate(); |
| 1425 | const double frequency = |
| 1426 | PositionToFrequency(wc, false, mouseYCoordinate, |
| 1427 | trackTopEdge, trackHeight); |
| 1428 | const double snappedFrequency = |
| 1429 | mFrequencySnapper->FindPeak(frequency, NULL); |
| 1430 | const double maxRatio = findMaxRatio(snappedFrequency, rate); |
| 1431 | double ratio = 2.0; // An arbitrary octave on each side, at most |
| 1432 | { |
| 1433 | const double f0 = viewInfo.selectedRegion.f0(); |
| 1434 | const double f1 = viewInfo.selectedRegion.f1(); |
| 1435 | if (f1 >= f0 && f0 >= 0) |
| 1436 | // Preserve already chosen ratio instead |
| 1437 | ratio = sqrt(f1 / f0); |
| 1438 | } |
| 1439 | ratio = std::min(ratio, maxRatio); |
| 1440 | |
| 1441 | mFreqSelPin = snappedFrequency; |
| 1442 | viewInfo.selectedRegion.setFrequencies( |
| 1443 | snappedFrequency / ratio, snappedFrequency * ratio); |
| 1444 | |
| 1445 | // A change here would affect what AdjustFreqSelection() does |
| 1446 | // in the prototype version where you switch from moving center to |
| 1447 | // dragging width with a click. No effect now. |
| 1448 | mFreqSelTrack = pWc; |
| 1449 | |
| 1450 | // SelectNone(); |
| 1451 | // SelectTrack(pTrack, true); |
| 1452 | TrackFocus::Get( *pProject ).Set(pTrack); |
| 1453 | } |
| 1454 | } |
| 1455 | |
| 1456 | void SelectHandle::SnapCenterOnce(SpectrumAnalyst &analyst, |
| 1457 | ViewInfo &viewInfo, const WaveChannel &wc, bool up) |
nothing calls this directly
no test coverage detected