46 auto start = track->TimeToLongSamples(selectedRegion.t0());
49 mRate = track->GetRate();
50 auto end = track->TimeToLongSamples(selectedRegion.t1());
51 auto dataLen =
end - start;
54 auto maxDataLen = size_t(2) << 26;
55 if (dataLen > maxDataLen)
64 const auto nChannels = track->NChannels();
65 if (track->GetRate() !=
mRate)
69 XO(
"To plot the spectrum, all selected tracks must have the same sample rate."),
77 float*
const buffers[] { buffer1.get(), buffer2.get() };
79 if (!track->GetFloats(
80 0, nChannels, buffers, start,
mDataLen,
false,
85 XO(
"Audio could not be analyzed. This may be due to a stretched or pitch-shifted clip.\nTry resetting any stretched clips, or mixing and rendering the tracks before analyzing"),
95 for (
size_t i = 0; i <
mDataLen; i++)
96 mData[i] = buffers[0][i];
102 const auto buffer = buffers[
iChannel];
103 for (
size_t i = 0; i <
mDataLen; i++)
104 mData[i] += buffer[i];
115 XO(
"Too much audio was selected. Only the first %.1f seconds of audio will be analyzed.")
Toolkit-neutral facade for basic user interface services.
audacity::BasicSettings * gPrefs
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
SpectrumAnalyst::Algorithm mAlg
PlotSpectrumBase(AudacityProject &project)
Used for finding the peaks, for snapping to peaks.
static TrackList & Get(AudacityProject &project)
auto Selected() -> TrackIterRange< TrackType >
NotifyingSelectedRegion selectedRegion
static ViewInfo & Get(AudacityProject &project)
A Track that contains audio waveform data.
virtual bool Read(const wxString &key, bool *value) const =0
MessageBoxResult ShowMessageBox(const TranslatableString &message, MessageBoxOptions options={})
Show a modal message box with either Ok or Yes and No, and optionally Cancel.
const char * end(const char *str) noexcept
MessageBoxOptions && Caption(TranslatableString caption_) &&