34 wxString pitchShiftText;
35 if (clipCentShift != 0)
37 pitchShiftText = wxString::Format(
"%.2f", std::abs(clipCentShift) / 100.);
38 while (pitchShiftText.EndsWith(
"0"))
39 pitchShiftText.RemoveLast();
40 if (pitchShiftText.EndsWith(
".") || pitchShiftText.EndsWith(
","))
41 pitchShiftText.RemoveLast();
43 return pitchShiftText;
63 const auto playbackSpeed = 100 / clipStretchRatio;
70 if (fabs(playbackSpeed - 100.) < .95)
72 fullText += wxString::Format(
73 "%.1f%%", playbackSpeed > 100 ? std::max(playbackSpeed, 100.1) :
75 else if (playbackSpeed < 1)
77 fullText += wxString::Format(
"%.1f%%", std::max(playbackSpeed, 0.1));
80 const auto roundedPlaybackSpeed =
82 fullText += wxString::Format(
"%d%%", roundedPlaybackSpeed);
88 wxDC& dc,
const wxRect& rect,
const wxBitmap& icon,
const wxString& text)
90 const auto textExtent = dc.GetTextExtent(text);
91 const auto textWidth = textExtent.GetWidth();
92 const auto textHeight = textExtent.GetHeight();
94 const auto iconHeight = icon.GetHeight();
95 const auto iconWidth = textWidth == 0 ? 0 : icon.GetWidth();
96 const auto contentWidth = iconWidth + textWidth;
97 if (contentWidth == 0 || contentWidth > rect.width)
99 const auto height = rect.GetHeight();
100 const auto iconTop = rect.GetTop() + (height - iconHeight) / 2;
101 const auto x = rect.x + (rect.width - contentWidth) / 2;
102 dc.DrawBitmap(icon, x, iconTop);
103 const auto y = rect.GetTop() + (height - textHeight) / 2;
104 dc.DrawText(text, x + iconWidth, y);
109 Type type,
const std::shared_ptr<WaveTrack>& track,
110 const std::shared_ptr<WaveTrack::Interval>& clip)
122 if (event.
event.CmdDown())
126 mClip->SetCentShift(0);
128 XO(
"Reset Clip Pitch"),
XO(
"Reset Clip Pitch"));
134 XO(
"There is not enough space to expand the clip to its original speed."),
142 XO(
"Reset Clip Speed"),
XO(
"Reset Clip Speed"));
151 clip =
mClip, focusedGroup] {
152 if (auto pProject = project.lock())
153 PitchAndSpeedDialog::Get(*pProject)
154 .Retarget(track, clip)
155 .SetFocus(focusedGroup);
164 const auto ctrlDown = state.
state.CmdDown();
167 return { ctrlDown ?
XO(
"Click to reset clip pitch.") :
168 macOs ?
XO(
"Click to change clip pitch, Cmd + click to reset.") :
169 XO(
"Click to change clip pitch, Ctrl + click to reset."),
172 return { ctrlDown ?
XO(
"Click to reset clip speed.") :
173 macOs ?
XO(
"Click to change clip speed, Cmd + click to reset.") :
174 XO(
"Click to change clip speed, Ctrl + click to reset."),
216 const auto& clip = args.
clip;
217 const auto& rect = args.
rect;
219 const auto clipCentShift = clip.GetCentShift();
220 if (clipCentShift == 0)
226 clipCentShift > 0 ? pitchUpIndicator : pitchDownIndicator),
233 const auto& clip = args.
clip;
234 const auto& rect = args.
rect;
236 const auto clipStretchRatio = clip.GetStretchRatio();
Toolkit-neutral facade for basic user interface services.
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
virtual int GetCentShift() const =0
virtual double GetStretchRatio() const =0
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
static ProjectHistory & Get(AudacityProject &project)
wxBitmap & Bitmap(int iIndex)
static bool IsPassThroughMode(double stretchRatio)
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
void ShowErrorDialog(const WindowPlacement &placement, const TranslatableString &dlogTitle, const TranslatableString &message, const ManualPageID &helpPage, const ErrorDialogOptions &options={})
Show an error dialog with a link to the manual for further help.
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
WAVE_TRACK_API bool SetClipStretchRatio(const WaveTrack &track, WaveTrack::Interval &interval, double stretchRatio)
void SelectClip(AudacityProject &project, const WaveTrack::Interval &clip)
fastfloat_really_inline void round(adjusted_mantissa &am, callback cb) noexcept