Audacity 3.2.0
Classes | Functions | Variables
anonymous_namespace{PitchAndSpeedDialog.cpp} Namespace Reference

Classes

struct  HitClip
 

Functions

std::optional< HitClipGetHitClip (AudacityProject &project, const TrackPanelMouseEvent &event)
 
bool IsExactlySelected (AudacityProject &project, const ClipTimes &clip)
 
PitchAndSpeedDialog::PitchShift ToSemitonesAndCents (int oldCents, int newCents)
 
void ClampPitchShift (PitchAndSpeedDialog::PitchShift &shift)
 
PitchAndSpeedDialog::PitchShift GetClipShift (const WaveClip &clip)
 

Variables

constexpr auto semitoneCtrlId = wxID_HIGHEST + 1
 
constexpr auto speedCtrlId = wxID_HIGHEST + 3
 
static const AttachedWindows::RegisteredFactory key
 

Function Documentation

◆ ClampPitchShift()

void anonymous_namespace{PitchAndSpeedDialog.cpp}::ClampPitchShift ( PitchAndSpeedDialog::PitchShift shift)

Definition at line 120 of file PitchAndSpeedDialog.cpp.

121{
122 static_assert(TimeAndPitchInterface::MaxCents % 100 == 0);
123 static_assert(TimeAndPitchInterface::MinCents % 100 == 0);
124 const auto cents = shift.semis * 100 + shift.cents;
126 shift = { TimeAndPitchInterface::MaxCents / 100, 0 };
127 else if (cents < TimeAndPitchInterface::MinCents)
128 shift = { TimeAndPitchInterface::MinCents / 100, 0 };
129}
static constexpr auto MaxCents
static constexpr auto MinCents

References PitchAndSpeedDialog::PitchShift::cents, TimeAndPitchInterface::MaxCents, TimeAndPitchInterface::MinCents, and PitchAndSpeedDialog::PitchShift::semis.

Referenced by PitchAndSpeedDialog::SetSemitoneShift().

Here is the caller graph for this function:

◆ GetClipShift()

PitchAndSpeedDialog::PitchShift anonymous_namespace{PitchAndSpeedDialog.cpp}::GetClipShift ( const WaveClip clip)

Definition at line 131 of file PitchAndSpeedDialog.cpp.

132{
133 const auto totalShift = clip.GetCentShift();
134 return { totalShift / 100, totalShift % 100 };
135}
int GetCentShift() const override
Definition: WaveClip.cpp:634

References WaveClip::GetCentShift().

Referenced by PitchAndSpeedDialog::Retarget().

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

◆ GetHitClip()

std::optional< HitClip > anonymous_namespace{PitchAndSpeedDialog.cpp}::GetHitClip ( AudacityProject project,
const TrackPanelMouseEvent event 
)

Definition at line 55 of file PitchAndSpeedDialog.cpp.

56{
57 const auto pos = event.event.GetPosition();
58 const auto& viewInfo = ViewInfo::Get(project);
59 const auto t = viewInfo.PositionToTime(pos.x, event.rect.GetX());
60 auto& trackPanel = TrackPanel::Get(project);
61 for (auto leader : TrackList::Get(project).Any<WaveTrack>())
62 {
63 const auto trackRect = trackPanel.FindTrackRect(leader);
64 if (!trackRect.Contains(pos))
65 continue;
66 auto [begin, end] = leader->Intervals();
67 while (begin != end)
68 {
69 auto clip = *begin++;
70 if (clip->WithinPlayRegion(t))
71 return HitClip { std::static_pointer_cast<WaveTrack>(
72 leader->SharedPointer()),
73 clip };
74 }
75 }
76 return {};
77}
const auto project
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:234
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
const char * end(const char *str) noexcept
Definition: StringUtils.h:106
const char * begin(const char *str) noexcept
Definition: StringUtils.h:101

References details::begin(), details::end(), ViewInfo::Get(), TrackList::Get(), TrackPanel::Get(), project, and TrackPanelMouseEvent::rect.

Referenced by PitchAndSpeedDialog::TryRetarget().

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

◆ IsExactlySelected()

bool anonymous_namespace{PitchAndSpeedDialog.cpp}::IsExactlySelected ( AudacityProject project,
const ClipTimes clip 
)

Definition at line 79 of file PitchAndSpeedDialog.cpp.

80{
81 auto& viewInfo = ViewInfo::Get(project);
82 return clip.GetPlayStartTime() == viewInfo.selectedRegion.t0() &&
83 clip.GetPlayEndTime() == viewInfo.selectedRegion.t1();
84}
virtual double GetPlayEndTime() const =0
virtual double GetPlayStartTime() const =0

References ViewInfo::Get(), ClipTimes::GetPlayEndTime(), ClipTimes::GetPlayStartTime(), and project.

Referenced by PitchAndSpeedDialog::SetClipSpeed().

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

◆ ToSemitonesAndCents()

PitchAndSpeedDialog::PitchShift anonymous_namespace{PitchAndSpeedDialog.cpp}::ToSemitonesAndCents ( int  oldCents,
int  newCents 
)

Definition at line 86 of file PitchAndSpeedDialog.cpp.

87{
88 // Rules:
89 // 1. cents must be in the range [-100, 100]
90 // 2. on semitone updates, keep semitone and cent sign consistent
91
92 PitchAndSpeedDialog::PitchShift shift { 0, newCents };
93 while (shift.cents <= -100)
94 {
95 --shift.semis;
96 shift.cents += 100;
97 }
98 while (shift.cents >= 100)
99 {
100 ++shift.semis;
101 shift.cents -= 100;
102 }
103
104 const auto onlySemitonesChanged = [](int oldCents, int newCents) {
105 while (oldCents < 0)
106 oldCents += 100;
107 while (newCents < 0)
108 newCents += 100;
109 return oldCents / 100 != newCents / 100;
110 }(oldCents, newCents);
111
112 if (onlySemitonesChanged && shift.cents > 0 && shift.semis < 0)
113 return { shift.semis + 1, shift.cents - 100 };
114 else if (onlySemitonesChanged && shift.cents < 0 && shift.semis > 0)
115 return { shift.semis - 1, shift.cents + 100 };
116 else
117 return shift;
118}

References PitchAndSpeedDialog::PitchShift::semis.

Referenced by PitchAndSpeedDialog::Retarget().

Here is the caller graph for this function:

Variable Documentation

◆ key

const AttachedWindows::RegisteredFactory anonymous_namespace{PitchAndSpeedDialog.cpp}::key
static
Initial value:
{
[](AudacityProject& project) -> wxWeakRef<wxWindow> {
}
}
#define safenew
Definition: MemoryX.h:10
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90

Definition at line 137 of file PitchAndSpeedDialog.cpp.

Referenced by PitchAndSpeedDialog::Destroy(), and PitchAndSpeedDialog::Get().

◆ semitoneCtrlId

constexpr auto anonymous_namespace{PitchAndSpeedDialog.cpp}::semitoneCtrlId = wxID_HIGHEST + 1
constexpr

◆ speedCtrlId

constexpr auto anonymous_namespace{PitchAndSpeedDialog.cpp}::speedCtrlId = wxID_HIGHEST + 3
constexpr