26#include "../WaveTrack.h"
32#include "../Shuttle.h"
33#include "../ShuttleGui.h"
34#include "../widgets/AudacityMessageBox.h"
35#include "../widgets/valnum.h"
39{
XO(
"Compare Audio") };
44 R.
AddCommand( std::make_unique<CompareAudioCommand>() );
56 {
return VisitSettings<false>(
S); }
59 {
return VisitSettings<true>(
S); }
65 S.StartMultiColumn(2, wxALIGN_CENTER);
77 mT0 = selectedRegion.t0();
78 mT1 = selectedRegion.t1();
81 context.
Error(wxT(
"There is no selection!"));
91 context.
Error(wxT(
"No tracks selected! Select two tracks to compare."));
94 mTrack1 = * ++ trackRange.first;
97 context.
Error(wxT(
"Only one track selected! Select two tracks to compare."));
100 if ( * ++ trackRange.first )
102 context.
Status(wxT(
"More than two tracks selected - only the first two will be compared."));
109 return fabs(value1 - value2);
112inline int min(
int a,
int b)
114 return (a < b) ? a : b;
124 wxString msg = wxT(
"Comparing tracks '");
140 auto length = s1 - s0;
141 while (position < s1)
150 for (
decltype(block) buffPos = 0; buffPos < block; ++buffPos)
160 (position - s0).as_double() /
167 context.
Status(wxString::Format(wxT(
"%li"), errorCount));
168 context.
Status(wxString::Format(wxT(
"%.4f"), errorSeconds));
169 context.
Status(wxString::Format(wxT(
"Finished comparison: %li samples (%.3f seconds) exceeded the error threshold of %f."), errorCount, errorSeconds,
errorThreshold));
void RegisterCompareAudio(Registrar &R)
Contains declaration of CompareAudioCommand and CompareAudioCommandType classes.
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
virtual void Progress(double d) const
virtual void Error(const wxString &message) const
virtual void Status(const wxString &message, bool bFlush=false) const
AudacityProject & project
double CompareSample(double value1, double value2)
void PopulateOrExchange(ShuttleGui &S) override
const WaveTrack * mTrack1
bool Apply(const CommandContext &context) override
bool GetSelection(const CommandContext &context, AudacityProject &proj)
static const ComponentInterfaceSymbol Symbol
const WaveTrack * mTrack0
bool VisitSettings(SettingsVisitorBase< Const > &S)
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Base class for registration callback. Audacity will call providers RegisterNameOfThing() functions wi...
virtual void AddCommand(std::unique_ptr< AudacityCommand > &&WXUNUSED(command))
bool GetFloats(float *buffer, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
Retrieve samples from a track in floating-point format, regardless of the storage format.
double LongSamplesToTime(sampleCount pos) const
Convert correctly between a number of samples and an (absolute) time in seconds.
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Visitor of effect or command parameters. This is a base class with lots of virtual functions that do ...
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
static TrackList & Get(AudacityProject &project)
auto Selected() -> TrackIterRange< TrackType >
NotifyingSelectedRegion selectedRegion
static ViewInfo & Get(AudacityProject &project)
A Track that contains audio waveform data.
size_t GetMaxBlockSize() const override
This returns a nonnegative number of samples meant to size a memory buffer.
size_t GetBestBlockSize(sampleCount t) const override
This returns a nonnegative number of samples meant to size a memory buffer.
BuiltinCommandsModule::Registration< CompareAudioCommand > reg