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

Method StartSnappingFreqSelection

src/tracks/ui/SelectHandle.cpp:1363–1403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1361}
1362
1363void SelectHandle::StartSnappingFreqSelection(SpectrumAnalyst &analyst,
1364 const ViewInfo &viewInfo, const WaveChannel &wc)
1365{
1366 static const size_t minLength = 8;
1367
1368 const double rate = wc.GetRate();
1369
1370 // Grab samples, just for this track, at these times
1371 std::vector<float> frequencySnappingData;
1372 const auto start =
1373 wc.TimeToLongSamples(viewInfo.selectedRegion.t0());
1374 const auto end =
1375 wc.TimeToLongSamples(viewInfo.selectedRegion.t1());
1376 const auto length =
1377 std::min(frequencySnappingData.max_size(),
1378 limitSampleBufferSize(10485760, // as in FreqWindow.cpp
1379 end - start));
1380 const auto effectiveLength = std::max(minLength, length);
1381 frequencySnappingData.resize(effectiveLength, 0.0f);
1382 wc.GetFloats(
1383 &frequencySnappingData[0],
1384 start, length, FillFormat::fillZero,
1385 // Don't try to cope with exceptions, just read zeroes instead.
1386 false);
1387
1388 // Use same settings as are now used for spectrogram display,
1389 // except, shrink the window as needed so we get some answers
1390
1391 const auto &settings = SpectrogramSettings::Get(wc);
1392 auto windowSize = settings.GetFFTLength();
1393
1394 while(windowSize > effectiveLength)
1395 windowSize >>= 1;
1396 const int windowType = settings.windowType;
1397
1398 analyst.Calculate(
1399 SpectrumAnalyst::Spectrum, windowType, windowSize, rate,
1400 &frequencySnappingData[0], length);
1401
1402 // We can now throw away the sample data but we keep the spectrum.
1403}
1404
1405void SelectHandle::MoveSnappingFreqSelection(
1406 AudacityProject *pProject, ViewInfo &viewInfo, int mouseYCoordinate,

Callers

nothing calls this directly

Calls 9

limitSampleBufferSizeFunction · 0.85
maxFunction · 0.85
GetFunction · 0.85
TimeToLongSamplesMethod · 0.80
GetFFTLengthMethod · 0.80
minFunction · 0.50
GetRateMethod · 0.45
GetFloatsMethod · 0.45
CalculateMethod · 0.45

Tested by

no test coverage detected