24 const std::vector<sampleCount>& oldWhere,
size_t oldLen,
size_t newLen,
25 double t0,
double sampleRate,
double stretchRatio,
double samplesPerPixel,
26 int& oldX0,
double& correction)
33 const double oldWhere0 = oldWhere[1].as_double() - samplesPerPixel;
34 const double oldWhereLast = oldWhere0 + oldLen * samplesPerPixel;
36 const double denom = oldWhereLast - oldWhere0;
39 const double guessWhere0 = t0 *
sampleRate / stretchRatio;
42 oldWhereLast <= guessWhere0 ||
43 guessWhere0 + newLen * samplesPerPixel <= oldWhere0 ||
56 oldX0 = floor(0.5 + oldLen * (guessWhere0 - oldWhere0) / denom);
58 const double where0 = oldWhere0 + double(oldX0) * samplesPerPixel;
60 const double correction0 = where0 - guessWhere0;
61 correction = std::clamp(correction0, -samplesPerPixel, samplesPerPixel);
62 assert(correction == correction0);
67 std::vector<sampleCount>& where,
size_t len,
bool addBias,
double correction,
68 double t0,
double sampleRate,
double stretchRatio,
double samplesPerPixel)
71 const auto bias = addBias ? .5 : 0.;
72 const double w0 = 0.5 + correction + bias + t0 *
sampleRate / stretchRatio;
74 for (
decltype(len) x = 1; x < len + 1; x++)
75 where[x] =
sampleCount(floor(w0 +
double(x) * samplesPerPixel));
78std::vector<CommonTrackPanelCell::MenuItem>
82 { L
"Cut",
XO(
"Cut") },
83 { L
"Copy",
XO(
"Copy") },
84 { L
"Paste",
XO(
"Paste") },
86 { L
"Split",
XO(
"Split Clip") },
87 { L
"Join",
XO(
"Join Clips") },
88 { L
"TrackMute",
XO(
"Mute/Unmute Track") },
90 { L
"RenameClip",
XO(
"Rename Clip...") },
91 { L
"ChangePitchAndSpeed",
XO(
"Pitch and Speed...") },
92 { L
"RenderPitchAndSpeed",
XO(
"Render Pitch and Speed") },
103 XO(
"Changed Clip Speed to %.01f%%").
Format(speedInPercent),
106 XO(
"Changed Speed to %.01f%%").
Format(speedInPercent),
114 viewInfo.selectedRegion.setTimes(
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
static ProjectHistory & Get(AudacityProject &project)
static ViewInfo & Get(AudacityProject &project)
This allows multiple clips to be a part of one WaveTrack.
double GetPlayStartTime() const noexcept override
double GetPlayEndTime() const override
Positions or offsets within audio files need a wide type.
void SelectClip(AudacityProject &project, const WaveTrack::Interval &clip)
void PushClipSpeedChangedUndoState(AudacityProject &project, double speedInPercent)
std::vector< CommonTrackPanelCell::MenuItem > GetWaveClipMenuItems()
AUDACITY_DLL_API void fillWhere(std::vector< sampleCount > &where, size_t len, bool addBias, double correction, double t0, double sampleRate, double stretchRatio, double samplesPerPixel)
AUDACITY_DLL_API void findCorrection(const std::vector< sampleCount > &oldWhere, size_t oldLen, size_t newLen, double t0, double sampleRate, double stretchRatio, double samplesPerPixel, int &oldX0, double &correction)
constexpr auto sampleRate