Audacity 3.2.0
Functions
anonymous_namespace{SampleHandle.cpp} Namespace Reference

Functions

double adjustTime (const WaveTrack *wt, double time)
 
bool SampleResolutionTest (const ViewInfo &viewInfo, const WaveTrack *wt, double time, int width)
 
bool IsSampleEditingPossible (const wxMouseEvent &event, const wxRect &rect, const ViewInfo &viewInfo, WaveTrack *wt, int width)
 

Function Documentation

◆ adjustTime()

double anonymous_namespace{SampleHandle.cpp}::adjustTime ( const WaveTrack wt,
double  time 
)
inline

Definition at line 83 of file SampleHandle.cpp.

84 {
85 // Round to an exact sample time
86 return wt->LongSamplesToTime(wt->TimeToLongSamples(time));
87 }
double LongSamplesToTime(sampleCount pos) const
Convert correctly between a number of samples and an (absolute) time in seconds.
Definition: SampleTrack.cpp:40
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: SampleTrack.cpp:35

References SampleTrack::LongSamplesToTime(), and SampleTrack::TimeToLongSamples().

Referenced by SampleHandle::Click(), SampleHandle::HitTest(), and IsSampleEditingPossible().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsSampleEditingPossible()

bool anonymous_namespace{SampleHandle.cpp}::IsSampleEditingPossible ( const wxMouseEvent &  event,
const wxRect &  rect,
const ViewInfo viewInfo,
WaveTrack wt,
int  width 
)

Determines if we can edit samples in a wave track. Also pops up warning messages in certain cases where we can't.

Returns
true if we can edit the samples, false otherwise.

Definition at line 172 of file SampleHandle.cpp.

175 {
176 //If we aren't zoomed in far enough, show a message dialog.
177 const double time = adjustTime(wt, viewInfo.PositionToTime(event.m_x, rect.x));
178 if (!SampleResolutionTest(viewInfo, wt, time, width))
179 {
181 XO(
182"To use Draw, zoom in further until you can see the individual samples."),
183 XO("Draw Tool"));
184 return false;
185 }
186 return true;
187 }
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
#define XO(s)
Definition: Internat.h:31
double PositionToTime(wxInt64 position, wxInt64 origin=0, bool ignoreFisheye=false) const
Definition: ZoomInfo.cpp:41
bool SampleResolutionTest(const ViewInfo &viewInfo, const WaveTrack *wt, double time, int width)
double adjustTime(const WaveTrack *wt, double time)

References adjustTime(), AudacityMessageBox(), ZoomInfo::PositionToTime(), SampleResolutionTest(), and XO.

Referenced by SampleHandle::Click().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SampleResolutionTest()

bool anonymous_namespace{SampleHandle.cpp}::SampleResolutionTest ( const ViewInfo viewInfo,
const WaveTrack wt,
double  time,
int  width 
)

Definition at line 91 of file SampleHandle.cpp.

93 {
94 // Require more than 3 pixels per sample
95 const wxInt64 xx = std::max(wxInt64(0), viewInfo.TimeToPosition(time));
96 ZoomInfo::Intervals intervals;
97 const double rate = wt->GetRate();
98 viewInfo.FindIntervals(rate, intervals, width);
99 ZoomInfo::Intervals::const_iterator it = intervals.begin(),
100 end = intervals.end(), prev;
101 wxASSERT(it != end && it->position == 0);
102 do
103 prev = it++;
104 while (it != end && it->position <= xx);
105 const double threshold = 3 * rate;
106 // three times as many pixels per second, as samples
107 return prev->averageZoom > threshold;
108 }
double GetRate() const override
Definition: WaveTrack.cpp:481
std::vector< Interval > Intervals
Definition: ZoomInfo.h:146
void FindIntervals(double rate, Intervals &results, wxInt64 width, wxInt64 origin=0) const
Definition: ZoomInfo.cpp:110
wxInt64 TimeToPosition(double time, wxInt64 origin=0, bool ignoreFisheye=false) const
STM: Converts a project time to screen x position.
Definition: ZoomInfo.cpp:51
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159

References PackedArray::end(), ZoomInfo::FindIntervals(), WaveTrack::GetRate(), and ZoomInfo::TimeToPosition().

Referenced by SampleHandle::HitTest(), and IsSampleEditingPossible().

Here is the call graph for this function:
Here is the caller graph for this function: