Audacity  3.0.3
ChangeSpeed.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  ChangeSpeed.cpp
6 
7  Vaughan Johnson, Dominic Mazzoni
8 
9 *******************************************************************//*******************************************************************/
15 
16 
17 #include "ChangeSpeed.h"
18 #include "LoadEffects.h"
19 
20 #include <math.h>
21 
22 #include <wx/choice.h>
23 #include <wx/intl.h>
24 #include <wx/slider.h>
25 
26 #include "../LabelTrack.h"
27 #include "../Prefs.h"
28 #include "../Resample.h"
29 #include "../Shuttle.h"
30 #include "../ShuttleGui.h"
31 #include "../widgets/NumericTextCtrl.h"
32 #include "../widgets/valnum.h"
33 
34 #include "TimeWarper.h"
35 #include "../WaveClip.h"
36 #include "../WaveTrack.h"
37 
38 enum
39 {
45 };
46 
47 // the standard vinyl rpm choices
48 // If the percent change is not one of these ratios, the choice control gets "n/a".
49 enum kVinyl
50 {
54  kVinyl_NA
55 };
56 
58  XO("33\u2153"),
59  XO("45"),
60  XO("78"),
61  /* i18n-hint: n/a is an English abbreviation meaning "not applicable". */
62  XO("n/a"),
63 };
64 
65 // Soundtouch is not reasonable below -99% or above 3000%.
66 
67 // Define keys, defaults, minimums, and maximums for the effect parameters
68 //
69 // Name Type Key Def Min Max Scale
70 Param( Percentage, double, wxT("Percentage"), 0.0, -99.0, 4900.0, 1 );
71 
72 // We warp the slider to go up to 400%, but user can enter higher values
73 static const double kSliderMax = 100.0; // warped above zero to actually go up to 400%
74 static const double kSliderWarp = 1.30105; // warp power takes max from 100 to 400.
75 
76 //
77 // EffectChangeSpeed
78 //
79 
81 { XO("Change Speed") };
82 
84 
85 BEGIN_EVENT_TABLE(EffectChangeSpeed, wxEvtHandler)
94 
96 {
97  // effect parameters
98  m_PercentChange = DEF_Percentage;
99 
100  mFromVinyl = kVinyl_33AndAThird;
101  mToVinyl = kVinyl_33AndAThird;
102  mFromLength = 0.0;
103  mToLength = 0.0;
105  mbLoopDetect = false;
106 
107  SetLinearEffectFlag(true);
108 }
109 
111 {
112 }
113 
114 // ComponentInterface implementation
115 
117 {
118  return Symbol;
119 }
120 
122 {
123  return XO("Changes the speed of a track, also changing its pitch");
124 }
125 
127 {
128  return wxT("Change_Speed");
129 }
130 
131 
132 // EffectDefinitionInterface implementation
133 
135 {
136  return EffectTypeProcess;
137 }
138 
139 // EffectClientInterface implementation
141  S.SHUTTLE_PARAM( m_PercentChange, Percentage );
142  return true;
143 }
144 
146 {
147  parms.Write(KEY_Percentage, m_PercentChange);
148 
149  return true;
150 }
151 
153 {
154  ReadAndVerifyDouble(Percentage);
155 
156  m_PercentChange = Percentage;
157 
158  return true;
159 }
160 
162 {
165 
167 }
168 
169 // Effect implementation
170 
172 {
173  return (m_PercentChange == 0.0);
174 }
175 
176 double EffectChangeSpeed::CalcPreviewInputLength(double previewLength)
177 {
178  return previewLength * (100.0 + m_PercentChange) / 100.0;
179 }
180 
182 {
183  wxString base = wxT("/Effects/ChangeSpeed/");
184 
185  // Migrate settings from 2.1.0 or before
186 
187  // Already migrated, so bail
188  if (gPrefs->Exists(base + wxT("Migrated")))
189  {
190  return true;
191  }
192 
193  // Load the old "current" settings
194  if (gPrefs->Exists(base))
195  {
196  // Retrieve last used control values
197  gPrefs->Read(base + wxT("PercentChange"), &m_PercentChange, 0);
198 
199  wxString format;
200  gPrefs->Read(base + wxT("TimeFormat"), &format, wxString{});
202 
203  gPrefs->Read(base + wxT("VinylChoice"), &mFromVinyl, 0);
204  if (mFromVinyl == kVinyl_NA)
205  {
207  }
208 
209  SetPrivateConfig(GetCurrentSettingsGroup(), wxT("TimeFormat"), mFormat.Internal());
210  SetPrivateConfig(GetCurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl);
211 
213 
214  // Do not migrate again
215  gPrefs->Write(base + wxT("Migrated"), true);
216  gPrefs->Flush();
217  }
218 
219  return true;
220 }
221 
223 {
224  // The selection might have changed since the last time EffectChangeSpeed
225  // was invoked, so recalculate the Length parameters.
226  mFromLength = mT1 - mT0;
227  return true;
228 }
229 
231 {
232  // Similar to EffectSoundTouch::Process()
233 
234  // Iterate over each track.
235  // All needed because this effect needs to introduce
236  // silence in the sync-lock group tracks to keep sync
237  CopyInputTracks(true); // Set up mOutputTracks.
238  bool bGoodResult = true;
239 
240  mCurTrackNum = 0;
241  mMaxNewLength = 0.0;
242 
243  mFactor = 100.0 / (100.0 + m_PercentChange);
244 
245  mOutputTracks->Any().VisitWhile( bGoodResult,
246  [&](LabelTrack *lt) {
247  if (lt->GetSelected() || lt->IsSyncLockSelected())
248  {
249  if (!ProcessLabelTrack(lt))
250  bGoodResult = false;
251  }
252  },
253  [&](WaveTrack *pOutWaveTrack, const Track::Fallthrough &fallthrough) {
254  if (!pOutWaveTrack->GetSelected())
255  return fallthrough();
256 
257  //Get start and end times from track
258  mCurT0 = pOutWaveTrack->GetStartTime();
259  mCurT1 = pOutWaveTrack->GetEndTime();
260 
261  //Set the current bounds to whichever left marker is
262  //greater and whichever right marker is less:
263  mCurT0 = wxMax(mT0, mCurT0);
264  mCurT1 = wxMin(mT1, mCurT1);
265 
266  // Process only if the right marker is to the right of the left marker
267  if (mCurT1 > mCurT0) {
268  //Transform the marker timepoints to samples
269  auto start = pOutWaveTrack->TimeToLongSamples(mCurT0);
270  auto end = pOutWaveTrack->TimeToLongSamples(mCurT1);
271 
272  //ProcessOne() (implemented below) processes a single track
273  if (!ProcessOne(pOutWaveTrack, start, end))
274  bGoodResult = false;
275  }
276  mCurTrackNum++;
277  },
278  [&](Track *t) {
279  if (t->IsSyncLockSelected())
280  t->SyncLockAdjust(mT1, mT0 + (mT1 - mT0) * mFactor);
281  }
282  );
283 
284  if (bGoodResult)
285  ReplaceProcessedTracks(bGoodResult);
286 
287  // Update selection.
288  mT1 = mT0 + (((mT1 - mT0) * 100.0) / (100.0 + m_PercentChange));
289 
290  return bGoodResult;
291 }
292 
294 {
295  {
296  wxString formatId;
297  GetPrivateConfig(GetCurrentSettingsGroup(), wxT("TimeFormat"),
298  formatId, mFormat.Internal());
300  NumericConverter::TIME, formatId );
301  }
303 
304  S.SetBorder(5);
305 
306  S.StartVerticalLay(0);
307  {
308  S.AddSpace(0, 5);
309  S.AddTitle(XO("Change Speed, affecting both Tempo and Pitch"));
310  S.AddSpace(0, 10);
311 
312  // Speed multiplier and percent change controls.
313  S.StartMultiColumn(4, wxCENTER);
314  {
316  .Validator<FloatingPointValidator<double>>(
317  3, &mMultiplier,
318  NumValidatorStyle::THREE_TRAILING_ZEROES,
319  MIN_Percentage / 100.0, ((MAX_Percentage / 100.0) + 1)
320  )
321  .AddTextBox(XXO("&Speed Multiplier:"), wxT(""), 12);
322 
324  .Validator<FloatingPointValidator<double>>(
325  3, &m_PercentChange,
326  NumValidatorStyle::THREE_TRAILING_ZEROES,
327  MIN_Percentage, MAX_Percentage
328  )
329  .AddTextBox(XXO("Percent C&hange:"), wxT(""), 12);
330  }
331  S.EndMultiColumn();
332 
333  // Percent change slider.
334  S.StartHorizontalLay(wxEXPAND);
335  {
337  .Name(XO("Percent Change"))
338  .Style(wxSL_HORIZONTAL)
339  .AddSlider( {}, 0, (int)kSliderMax, (int)MIN_Percentage);
340  }
341  S.EndHorizontalLay();
342 
343  // Vinyl rpm controls.
344  S.StartMultiColumn(5, wxCENTER);
345  {
346  /* i18n-hint: "rpm" is an English abbreviation meaning "revolutions per minute".
347  "vinyl" refers to old-fashioned phonograph records */
348  S.AddUnits(XO("Standard Vinyl rpm:"));
349 
351  /* i18n-hint: changing speed of audio "from" one value "to" another
352  "rpm" means "revolutions per minute" as on a vinyl record turntable
353  */
354  .Name(XO("From rpm"))
355  .MinSize( { 100, -1 } )
356  /* i18n-hint: changing speed of audio "from" one value "to" another */
357  .AddChoice(XXC("&from", "change speed"), kVinylStrings);
358 
360  /* i18n-hint: changing speed of audio "from" one value "to" another
361  "rpm" means "revolutions per minute" as on a vinyl record turntable
362  */
363  .Name(XO("To rpm"))
364  .MinSize( { 100, -1 } )
365  /* i18n-hint: changing speed of audio "from" one value "to" another */
366  .AddChoice(XXC("&to", "change speed"), kVinylStrings);
367  }
368  S.EndMultiColumn();
369 
370  // From/To time controls.
371  S.StartStatic(XO("Selection Length"), 0);
372  {
373  S.StartMultiColumn(2, wxALIGN_LEFT);
374  {
375  S.AddPrompt(XXO("C&urrent Length:"));
376 
378  NumericTextCtrl(S.GetParent(), wxID_ANY,
380  mFormat,
381  mFromLength,
382  mProjectRate,
384  .ReadOnly(true)
385  .MenuEnabled(false));
386 
387  S.ToolTip(XO("Current length of selection."))
388  /* i18n-hint: changing speed of audio "from" one value "to" another */
389  .Name(XC("from", "change speed"))
390  .Position(wxALIGN_LEFT)
392 
393  S.AddPrompt(XXO("&New Length:"));
394 
398  mFormat,
399  mToLength,
400  mProjectRate);
401 
402  /* i18n-hint: changing speed of audio "from" one value "to" another */
403  S.Name(XC("to", "change speed"))
404  .Position(wxALIGN_LEFT)
406  }
407  S.EndMultiColumn();
408  }
409  S.EndStatic();
410  }
411  S.EndVerticalLay();
412 }
413 
415 {
416  mbLoopDetect = true;
417 
418  if (!mUIParent->TransferDataToWindow())
419  {
420  return false;
421  }
422 
423  if (mFromVinyl == kVinyl_NA)
424  {
426  }
427 
432 
433  // Set from/to Vinyl controls - mFromVinyl must be set first.
434  mpChoice_FromVinyl->SetSelection(mFromVinyl);
435  // Then update to get correct mToVinyl.
436  Update_Vinyl();
437  // Then update ToVinyl control.
438  mpChoice_ToVinyl->SetSelection(mToVinyl);
439 
440  // Set From Length control.
441  // Set the format first so we can get sample accuracy.
444 
445  mbLoopDetect = false;
446 
447  return true;
448 }
449 
451 {
452  // mUIParent->TransferDataFromWindow() loses some precision, so save and restore it.
453  double exactPercent = m_PercentChange;
454  if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
455  {
456  return false;
457  }
458  m_PercentChange = exactPercent;
459 
460  SetPrivateConfig(GetCurrentSettingsGroup(), wxT("TimeFormat"), mFormat.Internal());
461  SetPrivateConfig(GetCurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl);
462 
463  return true;
464 }
465 
466 // EffectChangeSpeed implementation
467 
468 // Labels are time-scaled linearly inside the affected region, and labels after
469 // the region are shifted along according to how the region size changed.
471 {
472  RegionTimeWarper warper { mT0, mT1,
473  std::make_unique<LinearTimeWarper>(mT0, mT0,
474  mT1, mT0 + (mT1-mT0)*mFactor) };
475  lt->WarpLabels(warper);
476  return true;
477 }
478 
479 // ProcessOne() takes a track, transforms it to bunch of buffer-blocks,
480 // and calls libsamplerate code on these blocks.
482  sampleCount start, sampleCount end)
483 {
484  if (track == NULL)
485  return false;
486 
487  // initialization, per examples of Mixer::Mixer and
488  // EffectSoundTouch::ProcessOne
489 
490 
491  auto outputTrack = track->EmptyCopy();
492 
493  //Get the length of the selection (as double). len is
494  //used simple to calculate a progress meter, so it is easier
495  //to make it a double now than it is to do it later
496  auto len = (end - start).as_double();
497 
498  // Initiate processing buffers, most likely shorter than
499  // the length of the selection being processed.
500  auto inBufferSize = track->GetMaxBlockSize();
501 
502  Floats inBuffer{ inBufferSize };
503 
504  // mFactor is at most 100-fold so this shouldn't overflow size_t
505  auto outBufferSize = size_t( mFactor * inBufferSize + 10 );
506  Floats outBuffer{ outBufferSize };
507 
508  // Set up the resampling stuff for this track.
509  Resample resample(true, mFactor, mFactor); // constant rate resampling
510 
511  //Go through the track one buffer at a time. samplePos counts which
512  //sample the current buffer starts at.
513  bool bResult = true;
514  auto samplePos = start;
515  while (samplePos < end) {
516  //Get a blockSize of samples (smaller than the size of the buffer)
517  auto blockSize = limitSampleBufferSize(
518  track->GetBestBlockSize(samplePos),
519  end - samplePos
520  );
521 
522  //Get the samples from the track and put them in the buffer
523  track->Get((samplePtr) inBuffer.get(), floatSample, samplePos, blockSize);
524 
525  const auto results = resample.Process(mFactor,
526  inBuffer.get(),
527  blockSize,
528  ((samplePos + blockSize) >= end),
529  outBuffer.get(),
530  outBufferSize);
531  const auto outgen = results.second;
532 
533  if (outgen > 0)
534  outputTrack->Append((samplePtr)outBuffer.get(), floatSample,
535  outgen);
536 
537  // Increment samplePos
538  samplePos += results.first;
539 
540  // Update the Progress meter
541  if (TrackProgress(mCurTrackNum, (samplePos - start).as_double() / len)) {
542  bResult = false;
543  break;
544  }
545  }
546 
547  // Flush the output WaveTrack (since it's buffered, too)
548  outputTrack->Flush();
549 
550  // Take the output track and insert it in place of the original
551  // sample data
552  double newLength = outputTrack->GetEndTime();
553  if (bResult)
554  {
555  // Silenced samples will be inserted in gaps between clips, so capture where these
556  // gaps are for later deletion
557  std::vector<std::pair<double, double>> gaps;
558  double last = 0.0;
559  auto clips = track->SortedClipArray();
560  auto front = clips.front();
561  auto back = clips.back();
562  for (auto &clip : clips) {
563  auto st = clip->GetStartTime();
564  auto et = clip->GetEndTime();
565 
566  if (st >= mCurT0 || et < mCurT1) {
567  if (mCurT0 < st && clip == front) {
568  gaps.push_back(std::make_pair(mCurT0, st));
569  }
570  if (mCurT1 > et && clip == back) {
571  gaps.push_back(std::make_pair(et, mCurT1));
572  }
573  if (last >= mCurT0) {
574  gaps.push_back(std::make_pair(last, st));
575  }
576  }
577  last = et;
578  }
579 
580  LinearTimeWarper warper { mCurT0, mCurT0, mCurT1, mCurT0 + newLength };
581 
582  // Take the output track and insert it in place of the original sample data
583  track->ClearAndPaste(mCurT0, mCurT1, outputTrack.get(), true, true, &warper);
584 
585  // Finally, recreate the gaps
586  for (auto gap : gaps) {
587  auto st = track->LongSamplesToTime(track->TimeToLongSamples(gap.first));
588  auto et = track->LongSamplesToTime(track->TimeToLongSamples(gap.second));
589  if (st >= mCurT0 && et <= mCurT1 && st != et)
590  {
591  track->SplitDelete(warper.Warp(st), warper.Warp(et));
592  }
593  }
594  }
595 
596  if (newLength > mMaxNewLength)
597  mMaxNewLength = newLength;
598 
599  return bResult;
600 }
601 
602 // handler implementations for EffectChangeSpeed
603 
604 void EffectChangeSpeed::OnText_PercentChange(wxCommandEvent & WXUNUSED(evt))
605 {
606  if (mbLoopDetect)
607  return;
608 
609  mpTextCtrl_PercentChange->GetValidator()->TransferFromWindow();
610  UpdateUI();
611 
612  mbLoopDetect = true;
615  Update_Vinyl();
617  mbLoopDetect = false;
618 }
619 
620 void EffectChangeSpeed::OnText_Multiplier(wxCommandEvent & WXUNUSED(evt))
621 {
622  if (mbLoopDetect)
623  return;
624 
625  mpTextCtrl_Multiplier->GetValidator()->TransferFromWindow();
626  m_PercentChange = 100 * (mMultiplier - 1);
627  UpdateUI();
628 
629  mbLoopDetect = true;
632  Update_Vinyl();
634  mbLoopDetect = false;
635 }
636 
637 void EffectChangeSpeed::OnSlider_PercentChange(wxCommandEvent & WXUNUSED(evt))
638 {
639  if (mbLoopDetect)
640  return;
641 
642  m_PercentChange = (double)(mpSlider_PercentChange->GetValue());
643  // Warp positive values to actually go up faster & further than negatives.
644  if (m_PercentChange > 0.0)
646  UpdateUI();
647 
648  mbLoopDetect = true;
651  Update_Vinyl();
653  mbLoopDetect = false;
654 }
655 
656 void EffectChangeSpeed::OnChoice_Vinyl(wxCommandEvent & WXUNUSED(evt))
657 {
658  // Treat mpChoice_FromVinyl and mpChoice_ToVinyl as one control since we need
659  // both to calculate Percent Change.
660  mFromVinyl = mpChoice_FromVinyl->GetSelection();
661  mToVinyl = mpChoice_ToVinyl->GetSelection();
662  // Use this as the 'preferred' choice.
663  if (mFromVinyl != kVinyl_NA) {
664  SetPrivateConfig(GetCurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl);
665  }
666 
667  // If mFromVinyl & mToVinyl are set, then there's a NEW percent change.
668  if ((mFromVinyl != kVinyl_NA) && (mToVinyl != kVinyl_NA))
669  {
670  double fromRPM;
671  double toRPM;
672  switch (mFromVinyl) {
673  default:
674  case kVinyl_33AndAThird: fromRPM = 33.0 + (1.0 / 3.0); break;
675  case kVinyl_45: fromRPM = 45.0; break;
676  case kVinyl_78: fromRPM = 78; break;
677  }
678  switch (mToVinyl) {
679  default:
680  case kVinyl_33AndAThird: toRPM = 33.0 + (1.0 / 3.0); break;
681  case kVinyl_45: toRPM = 45.0; break;
682  case kVinyl_78: toRPM = 78; break;
683  }
684  m_PercentChange = ((toRPM * 100.0) / fromRPM) - 100.0;
685  UpdateUI();
686 
687  mbLoopDetect = true;
692  }
693  mbLoopDetect = false;
694 }
695 
696 void EffectChangeSpeed::OnTimeCtrl_ToLength(wxCommandEvent & WXUNUSED(evt))
697 {
698  if (mbLoopDetect)
699  return;
700 
702  // Division by (double) 0.0 is not an error and we want to show "infinite" in
703  // text controls, so take care that we handle infinite values when they occur.
704  m_PercentChange = ((mFromLength * 100.0) / mToLength) - 100.0;
705  UpdateUI();
706 
707  mbLoopDetect = true;
708 
712  Update_Vinyl();
713 
714  mbLoopDetect = false;
715 }
716 
717 void EffectChangeSpeed::OnTimeCtrlUpdate(wxCommandEvent & evt)
718 {
720  NumericConverter::TIME, evt.GetString() );
721 
723  // Update From/To Length controls (precision has changed).
726 }
727 
728 // helper functions
729 
731 // Update Text Percent control from percent change.
732 {
733  mpTextCtrl_PercentChange->GetValidator()->TransferToWindow();
734 }
735 
737 // Update Multiplier control from percent change.
738 {
739  mMultiplier = 1 + (m_PercentChange) / 100.0;
740  mpTextCtrl_Multiplier->GetValidator()->TransferToWindow();
741 }
742 
744 // Update Slider Percent control from percent change.
745 {
746  auto unwarped = std::min<double>(m_PercentChange, MAX_Percentage);
747  if (unwarped > 0.0)
748  // Un-warp values above zero to actually go up to kSliderMax.
749  unwarped = pow(m_PercentChange, (1.0 / kSliderWarp));
750 
751  // Caution: m_PercentChange could be infinite.
752  int unwarpedi = (int)(unwarped + 0.5);
753  unwarpedi = std::min<int>(unwarpedi, (int)kSliderMax);
754 
755  mpSlider_PercentChange->SetValue(unwarpedi);
756 }
757 
759 // Update Vinyl controls from percent change.
760 {
761  // Match Vinyl rpm when within 0.01% of a standard ratio.
762  // Ratios calculated as: ((toRPM / fromRPM) - 1) * 100 * 100
763 
764  // Caution: m_PercentChange could be infinite
765  int ratio = (int)((m_PercentChange * 100) + 0.5);
766 
767  switch (ratio)
768  {
769  case 0: // toRPM is the same as fromRPM
770  if (mFromVinyl != kVinyl_NA) {
771  mpChoice_ToVinyl->SetSelection(mpChoice_FromVinyl->GetSelection());
772  } else {
773  // Use the last saved option.
774  GetPrivateConfig(GetCurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl, 0);
775  mpChoice_FromVinyl->SetSelection(mFromVinyl);
776  mpChoice_ToVinyl->SetSelection(mFromVinyl);
777  }
778  break;
779  case 3500:
780  mpChoice_FromVinyl->SetSelection(kVinyl_33AndAThird);
781  mpChoice_ToVinyl->SetSelection(kVinyl_45);
782  break;
783  case 13400:
784  mpChoice_FromVinyl->SetSelection(kVinyl_33AndAThird);
785  mpChoice_ToVinyl->SetSelection(kVinyl_78);
786  break;
787  case -2593:
788  mpChoice_FromVinyl->SetSelection(kVinyl_45);
789  mpChoice_ToVinyl->SetSelection(kVinyl_33AndAThird);
790  break;
791  case 7333:
792  mpChoice_FromVinyl->SetSelection(kVinyl_45);
793  mpChoice_ToVinyl->SetSelection(kVinyl_78);
794  break;
795  case -5727:
796  mpChoice_FromVinyl->SetSelection(kVinyl_78);
797  mpChoice_ToVinyl->SetSelection(kVinyl_33AndAThird);
798  break;
799  case -4231:
800  mpChoice_FromVinyl->SetSelection(kVinyl_78);
801  mpChoice_ToVinyl->SetSelection(kVinyl_45);
802  break;
803  default:
804  mpChoice_ToVinyl->SetSelection(kVinyl_NA);
805  }
806  // and update variables.
807  mFromVinyl = mpChoice_FromVinyl->GetSelection();
808  mToVinyl = mpChoice_ToVinyl->GetSelection();
809 }
810 
812 // Update ToLength control from percent change.
813 {
814  mToLength = (mFromLength * 100.0) / (100.0 + m_PercentChange);
815 
816  // Set the format first so we can get sample accuracy.
818  // Negative times do not make sense.
819  // 359999 = 99h:59m:59s which is a little less disturbing than overflow characters
820  // though it may still look a bit strange with some formats.
821  mToLength = TrapDouble(mToLength, 0.0, 359999.0);
823 }
824 
826 // Disable OK and Preview if not in sensible range.
827 {
828  EnableApply(m_PercentChange >= MIN_Percentage && m_PercentChange <= MAX_Percentage);
829 }
EffectChangeSpeed::mpChoice_FromVinyl
wxChoice * mpChoice_FromVinyl
Definition: ChangeSpeed.h:105
EffectChangeSpeed::OnTimeCtrlUpdate
void OnTimeCtrlUpdate(wxCommandEvent &evt)
Definition: ChangeSpeed.cpp:717
EffectChangeSpeed::ProcessOne
bool ProcessOne(WaveTrack *t, sampleCount start, sampleCount end)
Definition: ChangeSpeed.cpp:481
EffectChangeSpeed::Update_Text_Multiplier
void Update_Text_Multiplier()
Definition: ChangeSpeed.cpp:736
TranslatableString
Definition: Types.h:290
kSliderMax
static const double kSliderMax
Definition: ChangeSpeed.cpp:73
CommandParameters
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
Definition: EffectAutomationParameters.h:67
NumericTextCtrl::SetFormatName
bool SetFormatName(const NumericFormatSymbol &formatName)
Definition: NumericTextCtrl.cpp:1443
EffectChangeSpeed::Startup
bool Startup() override
Definition: ChangeSpeed.cpp:181
ShuttleGuiBase::StartVerticalLay
void StartVerticalLay(int iProp=1)
Definition: ShuttleGui.cpp:1177
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:68
EffectTypeProcess
@ EffectTypeProcess
Definition: EffectInterface.h:59
EffectChangeSpeed::ProcessLabelTrack
bool ProcessLabelTrack(LabelTrack *t)
Definition: ChangeSpeed.cpp:470
EffectChangeSpeed::GetAutomationParameters
bool GetAutomationParameters(CommandParameters &parms) override
Definition: ChangeSpeed.cpp:145
Effect::EnableApply
virtual bool EnableApply(bool enable=true)
Definition: Effect.cpp:1925
EffectChangeSpeed::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: ChangeSpeed.h:27
ShuttleGuiBase::AddTitle
void AddTitle(const TranslatableString &Prompt, int wrapWidth=0)
Centred text string.
Definition: ShuttleGui.cpp:274
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:67
kVinyl_NA
@ kVinyl_NA
Definition: ChangeSpeed.cpp:54
EffectChangeSpeed::mToVinyl
int mToVinyl
Definition: ChangeSpeed.h:112
EVT_COMMAND
EVT_COMMAND(wxID_ANY, EVT_FREQUENCYTEXTCTRL_UPDATED, LabelDialog::OnFreqUpdate) LabelDialog
Definition: LabelDialog.cpp:91
WaveTrack::GetEndTime
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Definition: WaveTrack.cpp:1797
EffectChangeSpeed::mbLoopDetect
bool mbLoopDetect
Definition: ChangeSpeed.h:99
ShuttleGui::ToolTip
ShuttleGui & ToolTip(const TranslatableString &tip)
Definition: ShuttleGui.h:663
Effect::CopyInputTracks
void CopyInputTracks(bool allSyncLockSelected=false)
Definition: Effect.cpp:2070
kVinyl_33AndAThird
@ kVinyl_33AndAThird
Definition: ChangeSpeed.cpp:51
TimeWarper.h
Contains declarations for TimeWarper, IdentityTimeWarper, ShiftTimeWarper, LinearTimeWarper,...
EffectChangeSpeed::mpToLengthCtrl
NumericTextCtrl * mpToLengthCtrl
Definition: ChangeSpeed.h:108
Effect::mT1
double mT1
Definition: Effect.h:466
EffectChangeSpeed::~EffectChangeSpeed
virtual ~EffectChangeSpeed()
Definition: ChangeSpeed.cpp:110
ShuttleGui::AddSpace
wxSizerItem * AddSpace(int width, int height, int prop=0)
Definition: ShuttleGui.cpp:2421
XO
#define XO(s)
Definition: Internat.h:32
XC
#define XC(s, c)
Definition: Internat.h:38
EffectChangeSpeed::GetSymbol
ComponentInterfaceSymbol GetSymbol() override
Definition: ChangeSpeed.cpp:116
Effect::SetPrivateConfig
bool SetPrivateConfig(const RegistryPath &group, const RegistryPath &key, const wxString &value) override
Definition: Effect.cpp:986
ShuttleParams
Shuttle that deals with parameters. This is a base class with lots of virtual functions that do nothi...
Definition: Shuttle.h:61
LabelTrack
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:88
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1212
floatSample
@ floatSample
Definition: Types.h:722
EffectChangeSpeed::ManualPage
wxString ManualPage() override
Definition: ChangeSpeed.cpp:126
EffectChangeSpeed::Init
bool Init() override
Definition: ChangeSpeed.cpp:222
ID_Multiplier
@ ID_Multiplier
Definition: ChangeSpeed.cpp:41
WaveTrack::ClearAndPaste
void ClearAndPaste(double t0, double t1, const Track *src, bool preserve=true, bool merge=true, const TimeWarper *effectWarper=NULL)
Definition: WaveTrack.cpp:750
Effect::SaveUserPreset
bool SaveUserPreset(const RegistryPath &name) override
Definition: Effect.cpp:569
NumericTextCtrl
Definition: NumericTextCtrl.h:171
EffectChangeSpeed::mpTextCtrl_PercentChange
wxTextCtrl * mpTextCtrl_PercentChange
Definition: ChangeSpeed.h:102
NumericTextCtrl::SetValue
void SetValue(double newValue)
Definition: NumericTextCtrl.cpp:1472
Track::IsSyncLockSelected
bool IsSyncLockSelected() const
Definition: Track.cpp:245
kSliderWarp
static const double kSliderWarp
Definition: ChangeSpeed.cpp:74
EffectChangeSpeed::Update_Vinyl
void Update_Vinyl()
Definition: ChangeSpeed.cpp:758
WaveTrack::EmptyCopy
Holder EmptyCopy(const SampleBlockFactoryPtr &pFactory={}) const
Definition: WaveTrack.cpp:574
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterface.h:60
ID_FromVinyl
@ ID_FromVinyl
Definition: ChangeSpeed.cpp:42
NumericTextCtrl::Options
Definition: NumericTextCtrl.h:177
ShuttleGui::Id
ShuttleGui & Id(int id)
Definition: ShuttleGui.cpp:2248
kVinyl
kVinyl
Definition: ChangeSpeed.cpp:50
WaveTrack::SplitDelete
void SplitDelete(double t0, double t1)
Definition: WaveTrack.cpp:926
WaveTrack::Get
bool Get(samplePtr buffer, sampleFormat format, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
Definition: WaveTrack.cpp:1895
WaveTrack::SortedClipArray
WaveClipPointers SortedClipArray()
Definition: WaveTrack.cpp:2502
limitSampleBufferSize
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: Types.h:706
EffectChangeSpeed::Update_Slider_PercentChange
void Update_Slider_PercentChange()
Definition: ChangeSpeed.cpp:743
EffectChangeSpeed::CheckWhetherSkipEffect
bool CheckWhetherSkipEffect() override
Definition: ChangeSpeed.cpp:171
anonymous_namespace{ChangeSpeed.cpp}::reg
BuiltinEffectsModule::Registration< EffectChangeSpeed > reg
Definition: ChangeSpeed.cpp:83
EffectChangeSpeed::mCurTrackNum
int mCurTrackNum
Definition: ChangeSpeed.h:84
EffectChangeSpeed::mToLength
double mToLength
Definition: ChangeSpeed.h:113
EffectChangeSpeed::SetAutomationParameters
bool SetAutomationParameters(CommandParameters &parms) override
Definition: ChangeSpeed.cpp:152
ChangeSpeed.h
Effect::mProjectRate
double mProjectRate
Definition: Effect.h:457
NumericConverter::DefaultSelectionFormat
static NumericFormatSymbol DefaultSelectionFormat()
Definition: NumericTextCtrl.cpp:688
TranslatableStrings
std::vector< TranslatableString > TranslatableStrings
Definition: Types.h:555
NumericConverter::LookupFormat
static NumericFormatSymbol LookupFormat(Type type, const wxString &id)
Definition: NumericTextCtrl.cpp:702
EffectChangeSpeed::mCurT0
double mCurT0
Definition: ChangeSpeed.h:86
samplePtr
char * samplePtr
Definition: Types.h:737
XXO
#define XXO(s)
Definition: Internat.h:45
EffectChangeSpeed::m_PercentChange
double m_PercentChange
Definition: ChangeSpeed.h:90
ShuttleGuiBase::EndHorizontalLay
void EndHorizontalLay()
Definition: ShuttleGui.cpp:1170
Effect::mT0
double mT0
Definition: Effect.h:465
EffectChangeSpeed::mCurT1
double mCurT1
Definition: ChangeSpeed.h:87
EffectChangeSpeed::mMaxNewLength
double mMaxNewLength
Definition: ChangeSpeed.h:85
ShuttleGuiBase::StartHorizontalLay
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
Definition: ShuttleGui.cpp:1160
WaveTrack::LongSamplesToTime
double LongSamplesToTime(sampleCount pos) const
Convert correctly between a number of samples and an (absolute) time in seconds.
Definition: WaveTrack.cpp:1772
EffectChangeSpeed::mpChoice_ToVinyl
wxChoice * mpChoice_ToVinyl
Definition: ChangeSpeed.h:106
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1203
ShuttleGuiBase::EndVerticalLay
void EndVerticalLay()
Definition: ShuttleGui.cpp:1196
EffectChangeSpeed::mFormat
NumericFormatSymbol mFormat
Definition: ChangeSpeed.h:114
RegionTimeWarper
No change before the specified region; during the region, warp according to the given warper; after t...
Definition: TimeWarper.h:192
Effect::LoadFactoryDefaults
bool LoadFactoryDefaults() override
Definition: Effect.cpp:605
ShuttleGuiBase::AddUnits
void AddUnits(const TranslatableString &Prompt, int wrapWidth=0)
Left aligned text string.
Definition: ShuttleGui.cpp:256
LabelTrack::WarpLabels
void WarpLabels(const TimeWarper &warper)
Definition: LabelTrack.cpp:256
Effect::ReplaceProcessedTracks
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:2192
NumericConverter::TIME
@ TIME
Definition: NumericTextCtrl.h:51
Track::Fallthrough
Continuation<> Fallthrough
Type of arguments passed as optional second parameter to TypeSwitch<void>() cases.
Definition: Track.h:487
gap
static const int gap
Definition: Meter.cpp:255
format
int format
Definition: ExportPCM.cpp:54
EffectChangeSpeed::TransferDataFromWindow
bool TransferDataFromWindow() override
Definition: ChangeSpeed.cpp:450
ShuttleGuiBase::GetParent
wxWindow * GetParent()
Definition: ShuttleGui.h:503
EffectChangeSpeed::OnText_Multiplier
void OnText_Multiplier(wxCommandEvent &evt)
Definition: ChangeSpeed.cpp:620
ShuttleGui::Validator
ShuttleGui & Validator(const Factory &f)
Definition: ShuttleGui.h:685
EffectChangeSpeed::LoadFactoryDefaults
bool LoadFactoryDefaults() override
Definition: ChangeSpeed.cpp:161
NumericTextCtrl::Options::MenuEnabled
Options & MenuEnabled(bool enable)
Definition: NumericTextCtrl.h:191
WaveTrack::GetStartTime
double GetStartTime() const override
Get the time at which the first clip in the track starts.
Definition: WaveTrack.cpp:1777
Param
Param(Percentage, double, wxT("Percentage"), 0.0, -99.0, 4900.0, 1)
Resample
Interface to libsoxr.
Definition: Resample.h:29
Effect::mOutputTracks
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:464
ReadAndVerifyDouble
#define ReadAndVerifyDouble(name)
Definition: Effect.h:632
EffectChangeSpeed::OnTimeCtrl_ToLength
void OnTimeCtrl_ToLength(wxCommandEvent &evt)
Definition: ChangeSpeed.cpp:696
ShuttleGuiBase::AddSlider
wxSlider * AddSlider(const TranslatableString &Prompt, int pos, int Max, int Min=0)
Definition: ShuttleGui.cpp:582
EffectChangeSpeed
An Effect that affects both pitch & speed.
Definition: ChangeSpeed.h:25
kVinyl_78
@ kVinyl_78
Definition: ChangeSpeed.cpp:53
Effect::GetCurrentSettingsGroup
RegistryPath GetCurrentSettingsGroup() override
Definition: Effect.cpp:865
Track::GetSelected
bool GetSelected() const
Definition: Track.h:414
EffectChangeSpeed::OnSlider_PercentChange
void OnSlider_PercentChange(wxCommandEvent &evt)
Definition: ChangeSpeed.cpp:637
LoadEffects.h
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:886
EffectChangeSpeed::Update_Text_PercentChange
void Update_Text_PercentChange()
Definition: ChangeSpeed.cpp:730
WaveTrack::GetMaxBlockSize
size_t GetMaxBlockSize() const
Definition: WaveTrack.cpp:1578
EffectChangeSpeed::GetType
EffectType GetType() override
Definition: ChangeSpeed.cpp:134
ShuttleGui::Name
ShuttleGui & Name(const TranslatableString &name)
Definition: ShuttleGui.h:670
EffectChangeSpeed::mMultiplier
double mMultiplier
Definition: ChangeSpeed.h:97
EffectChangeSpeed::mFromLength
double mFromLength
Definition: ChangeSpeed.h:95
EffectChangeSpeed::OnText_PercentChange
void OnText_PercentChange(wxCommandEvent &evt)
Definition: ChangeSpeed.cpp:604
EffectChangeSpeed::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: ChangeSpeed.cpp:293
ShuttleGuiBase::AddWindow
wxWindow * AddWindow(wxWindow *pWindow)
Definition: ShuttleGui.cpp:292
EffectChangeSpeed::OnChoice_Vinyl
void OnChoice_Vinyl(wxCommandEvent &evt)
Definition: ChangeSpeed.cpp:656
FileConfig::Flush
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:151
WaveTrack::TimeToLongSamples
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: WaveTrack.cpp:1767
BuiltinEffectsModule::Registration
Definition: LoadEffects.h:40
ShuttleGui::Position
ShuttleGui & Position(int flags)
Definition: ShuttleGui.h:719
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:238
EffectChangeSpeed::mpFromLengthCtrl
NumericTextCtrl * mpFromLengthCtrl
Definition: ChangeSpeed.h:107
Effect::mUIParent
wxWindow * mUIParent
Definition: Effect.h:477
kVinyl_45
@ kVinyl_45
Definition: ChangeSpeed.cpp:52
sampleCount
Definition: Types.h:589
LinearTimeWarper
Linear scaling, initialised by giving two points on the line.
Definition: TimeWarper.h:87
NumericTextCtrl::Options::ReadOnly
Options & ReadOnly(bool enable)
Definition: NumericTextCtrl.h:190
ComponentInterfaceSymbol::Internal
const wxString & Internal() const
Definition: ComponentInterface.h:88
XXC
#define XXC(s, c)
Definition: Internat.h:48
EffectChangeSpeed::mFactor
double mFactor
Definition: ChangeSpeed.h:94
EffectChangeSpeed::GetDescription
TranslatableString GetDescription() override
Definition: ChangeSpeed.cpp:121
EffectChangeSpeed::Process
bool Process() override
Definition: ChangeSpeed.cpp:230
Resample::Process
std::pair< size_t, size_t > Process(double factor, float *inBuffer, size_t inBufferLen, bool lastFlag, float *outBuffer, size_t outBufferLen)
Main processing function. Resamples from the input buffer to the output buffer.
Definition: Resample.cpp:88
TrapDouble
double TrapDouble(double x, double min, double max)
Definition: Effect.h:563
WaveTrack::GetBestBlockSize
size_t GetBestBlockSize(sampleCount t) const
Definition: WaveTrack.cpp:1560
ShuttleGuiBase::AddPrompt
void AddPrompt(const TranslatableString &Prompt, int wrapWidth=0)
Right aligned text string.
Definition: ShuttleGui.cpp:231
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:497
EffectChangeSpeed::CalcPreviewInputLength
double CalcPreviewInputLength(double previewLength) override
Definition: ChangeSpeed.cpp:176
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:915
ID_ToLength
@ ID_ToLength
Definition: ChangeSpeed.cpp:44
EffectType
EffectType
Definition: EffectInterface.h:55
safenew
#define safenew
Definition: MemoryX.h:8
EffectChangeSpeed::mFromVinyl
int mFromVinyl
Definition: ChangeSpeed.h:93
Effect::GetPrivateConfig
bool GetPrivateConfig(const RegistryPath &group, const RegistryPath &key, wxString &value, const wxString &defval={}) override
Definition: Effect.cpp:961
NumericConverter::GetValue
double GetValue()
Definition: NumericTextCtrl.cpp:1172
kVinylStrings
static const TranslatableStrings kVinylStrings
Definition: ChangeSpeed.cpp:57
END_EVENT_TABLE
END_EVENT_TABLE()
Effect::TrackProgress
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={})
Definition: Effect.cpp:2024
ArrayOf< float >
EffectChangeSpeed::TransferDataToWindow
bool TransferDataToWindow() override
Definition: ChangeSpeed.cpp:414
EffectChangeSpeed::mpTextCtrl_Multiplier
wxTextCtrl * mpTextCtrl_Multiplier
Definition: ChangeSpeed.h:103
ID_ToVinyl
@ ID_ToVinyl
Definition: ChangeSpeed.cpp:43
EffectChangeSpeed::UpdateUI
void UpdateUI()
Definition: ChangeSpeed.cpp:825
ID_PercentChange
@ ID_PercentChange
Definition: ChangeSpeed.cpp:40
EffectChangeSpeed::Update_TimeCtrl_ToLength
void Update_TimeCtrl_ToLength()
Definition: ChangeSpeed.cpp:811
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:638
EffectChangeSpeed::DefineParams
bool DefineParams(ShuttleParams &S) override
Definition: ChangeSpeed.cpp:140
EffectChangeSpeed::mpSlider_PercentChange
wxSlider * mpSlider_PercentChange
Definition: ChangeSpeed.h:104