Audacity 3.2.0
Functions
anonymous_namespace{SampleHandle.cpp} Namespace Reference

Functions

double adjustTime (const WaveChannel &wt, double time)
 
bool SampleResolutionTest (const ViewInfo &viewInfo, const WaveChannelInterval &clip, const ZoomInfo::Intervals &intervals)
 
size_t GetLastEditableClipStartingFromNthClip (size_t n, bool forward, const WaveChannelUtilities::ClipPointers &sortedClips, const ViewInfo &viewInfo, const ZoomInfo::Intervals &intervals)
 

Function Documentation

◆ adjustTime()

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

Definition at line 84 of file SampleHandle.cpp.

85 {
86 // Round to an exact sample time
87 const auto clip = WaveChannelUtilities::GetClipAtTime(wt, time);
88 if (!clip)
89 return wt.SnapToSample(time);
90 const auto sampleOffset =
91 clip->TimeToSamples(time - clip->GetPlayStartTime());
92 return clip->SamplesToTime(sampleOffset) + clip->GetPlayStartTime();
93 }
double SnapToSample(double t) const
WAVE_TRACK_API ClipPointer GetClipAtTime(WaveChannel &channel, double time)

References WaveChannelUtilities::GetClipAtTime(), and WideSampleSequence::SnapToSample().

Referenced by SampleHandle::HitTest().

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

◆ GetLastEditableClipStartingFromNthClip()

size_t anonymous_namespace{SampleHandle.cpp}::GetLastEditableClipStartingFromNthClip ( size_t  n,
bool  forward,
const WaveChannelUtilities::ClipPointers sortedClips,
const ViewInfo viewInfo,
const ZoomInfo::Intervals intervals 
)

Definition at line 330 of file SampleHandle.cpp.

333{
334 assert(n < sortedClips.size());
335 const auto increment = forward ? 1 : -1;
336 int last = n + increment;
337 const auto limit = forward ? sortedClips.size() : -1;
338 while (last != limit)
339 {
340 if (!SampleResolutionTest(viewInfo, *sortedClips[last], intervals))
341 break;
342 last += increment;
343 }
344 last -= increment;
345 assert(last >= 0 && last < sortedClips.size());
346 return last;
347}
bool SampleResolutionTest(const ViewInfo &viewInfo, const WaveChannelInterval &clip, const ZoomInfo::Intervals &intervals)

References forward, and SampleResolutionTest().

Referenced by SampleHandle::Drag().

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 WaveChannelInterval clip,
const ZoomInfo::Intervals intervals 
)

Definition at line 97 of file SampleHandle.cpp.

100 {
101 // Require more than 3 pixels per sample
102 const auto xx = std::max<ZoomInfo::int64>(
103 0, viewInfo.TimeToPosition(clip.GetPlayStartTime()));
104 const double rate = clip.GetRate() / clip.GetStretchRatio();
105 ZoomInfo::Intervals::const_iterator it = intervals.begin(),
106 end = intervals.end(), prev;
107 wxASSERT(it != end && it->position == 0);
108 do
109 prev = it++;
110 while (it != end && it->position <= xx);
111 const double threshold = 3 * rate;
112 // three times as many pixels per second, as samples
113 return prev->averageZoom > threshold;
114 }
int GetRate() const override
Definition: WaveClip.cpp:193
double GetPlayStartTime() const override
Definition: WaveClip.cpp:198
double GetStretchRatio() const override
Definition: WaveClip.cpp:218
int64 TimeToPosition(double time, int64 origin=0, bool ignoreFisheye=false) const
STM: Converts a project time to screen x position.
Definition: ZoomInfo.cpp:44
const char * end(const char *str) noexcept
Definition: StringUtils.h:106

References details::end(), WaveClipChannel::GetPlayStartTime(), WaveClipChannel::GetRate(), WaveClipChannel::GetStretchRatio(), and ZoomInfo::TimeToPosition().

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

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