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 85 of file SampleHandle.cpp.

86 {
87 // Round to an exact sample time
88 const auto clip = WaveChannelUtilities::GetClipAtTime(wt, time);
89 if (!clip)
90 return wt.SnapToSample(time);
91 const auto sampleOffset =
92 clip->TimeToSamples(time - clip->GetPlayStartTime());
93 return clip->SamplesToTime(sampleOffset) + clip->GetPlayStartTime();
94 }
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 331 of file SampleHandle.cpp.

334{
335 assert(n < sortedClips.size());
336 const auto increment = forward ? 1 : -1;
337 int last = n + increment;
338 const auto limit = forward ? sortedClips.size() : -1;
339 while (last != limit)
340 {
341 if (!SampleResolutionTest(viewInfo, *sortedClips[last], intervals))
342 break;
343 last += increment;
344 }
345 last -= increment;
346 assert(last >= 0 && last < sortedClips.size());
347 return last;
348}
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 98 of file SampleHandle.cpp.

101 {
102 // Require more than 3 pixels per sample
103 const auto xx = std::max<ZoomInfo::int64>(
104 0, viewInfo.TimeToPosition(clip.GetPlayStartTime()));
105 const double rate = clip.GetRate() / clip.GetStretchRatio();
106 ZoomInfo::Intervals::const_iterator it = intervals.begin(),
107 end = intervals.end(), prev;
108 wxASSERT(it != end && it->position == 0);
109 do
110 prev = it++;
111 while (it != end && it->position <= xx);
112 const double threshold = 3 * rate;
113 // three times as many pixels per second, as samples
114 return prev->averageZoom > threshold;
115 }
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: