Audacity  3.0.3
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
EffectSBSMS Class Reference

#include <SBSMSEffect.h>

Inheritance diagram for EffectSBSMS:
[legend]
Collaboration diagram for EffectSBSMS:
[legend]

Public Member Functions

bool Process () override
 
void setParameters (double rateStart, double rateEnd, double pitchStart, double pitchEnd, SlideType rateSlideType, SlideType pitchSlideType, bool bLinkRatePitch, bool bRateReferenceInput, bool bPitchReferenceInput)
 
void setParameters (double tempoRatio, double pitchRatio)
 
- Public Member Functions inherited from Effect
 Effect ()
 
virtual ~Effect ()
 
PluginPath GetPath () override
 
VendorSymbol GetVendor () override
 
wxString GetVersion () override
 
TranslatableString GetDescription () override
 
EffectType GetType () override
 
EffectFamilySymbol GetFamily () override
 
bool IsInteractive () override
 
bool IsDefault () override
 
bool IsLegacy () override
 
bool SupportsRealtime () override
 
bool SupportsAutomation () override
 
bool SetHost (EffectHostInterface *host) override
 
unsigned GetAudioInCount () override
 
unsigned GetAudioOutCount () override
 
int GetMidiInCount () override
 
int GetMidiOutCount () override
 
sampleCount GetLatency () override
 
size_t GetTailSize () override
 
void SetSampleRate (double rate) override
 
size_t SetBlockSize (size_t maxBlockSize) override
 
size_t GetBlockSize () const override
 
bool IsReady () override
 
bool ProcessInitialize (sampleCount totalLen, ChannelNames chanMap=NULL) override
 
bool ProcessFinalize () override
 
size_t ProcessBlock (float **inBlock, float **outBlock, size_t blockLen) override
 
bool RealtimeInitialize () override
 
bool RealtimeAddProcessor (unsigned numChannels, float sampleRate) override
 
bool RealtimeFinalize () override
 
bool RealtimeSuspend () override
 
bool RealtimeResume () override
 
bool RealtimeProcessStart () override
 
size_t RealtimeProcess (int group, float **inbuf, float **outbuf, size_t numSamples) override
 
bool RealtimeProcessEnd () override
 
bool ShowInterface (wxWindow &parent, const EffectDialogFactory &factory, bool forceModal=false) override
 
bool GetAutomationParameters (CommandParameters &parms) override
 
bool SetAutomationParameters (CommandParameters &parms) override
 
bool LoadUserPreset (const RegistryPath &name) override
 
bool SaveUserPreset (const RegistryPath &name) override
 
RegistryPaths GetFactoryPresets () override
 
bool LoadFactoryPreset (int id) override
 
bool LoadFactoryDefaults () override
 
void SetHostUI (EffectUIHostInterface *host) override
 
bool PopulateUI (ShuttleGui &S) final
 
bool IsGraphicalUI () override
 
bool ValidateUI () override
 
bool HideUI () override
 
bool CloseUI () override
 
bool CanExportPresets () override
 
void ExportPresets () override
 
void ImportPresets () override
 
bool HasOptions () override
 
void ShowOptions () override
 
double GetDefaultDuration () override
 
double GetDuration () override
 
NumericFormatSymbol GetDurationFormat () override
 
virtual NumericFormatSymbol GetSelectionFormat ()
 
void SetDuration (double duration) override
 
RegistryPath GetUserPresetsGroup (const RegistryPath &name) override
 
RegistryPath GetCurrentSettingsGroup () override
 
RegistryPath GetFactoryDefaultsGroup () override
 
virtual wxString GetSavedStateGroup ()
 
bool HasSharedConfigGroup (const RegistryPath &group) override
 
bool GetSharedConfigSubgroups (const RegistryPath &group, RegistryPaths &subgroups) override
 
bool GetSharedConfig (const RegistryPath &group, const RegistryPath &key, wxString &value, const wxString &defval={}) override
 
bool GetSharedConfig (const RegistryPath &group, const RegistryPath &key, int &value, int defval=0) override
 
bool GetSharedConfig (const RegistryPath &group, const RegistryPath &key, bool &value, bool defval=false) override
 
bool GetSharedConfig (const RegistryPath &group, const RegistryPath &key, float &value, float defval=0.0) override
 
bool GetSharedConfig (const RegistryPath &group, const RegistryPath &key, double &value, double defval=0.0) override
 
bool SetSharedConfig (const RegistryPath &group, const RegistryPath &key, const wxString &value) override
 
bool SetSharedConfig (const RegistryPath &group, const RegistryPath &key, const int &value) override
 
bool SetSharedConfig (const RegistryPath &group, const RegistryPath &key, const bool &value) override
 
bool SetSharedConfig (const RegistryPath &group, const RegistryPath &key, const float &value) override
 
bool SetSharedConfig (const RegistryPath &group, const RegistryPath &key, const double &value) override
 
bool RemoveSharedConfigSubgroup (const RegistryPath &group) override
 
bool RemoveSharedConfig (const RegistryPath &group, const RegistryPath &key) override
 
bool HasPrivateConfigGroup (const RegistryPath &group) override
 
bool GetPrivateConfigSubgroups (const RegistryPath &group, RegistryPaths &paths) override
 
bool GetPrivateConfig (const RegistryPath &group, const RegistryPath &key, wxString &value, const wxString &defval={}) override
 
bool GetPrivateConfig (const RegistryPath &group, const RegistryPath &key, int &value, int defval=0) override
 
bool GetPrivateConfig (const RegistryPath &group, const RegistryPath &key, bool &value, bool defval=false) override
 
bool GetPrivateConfig (const RegistryPath &group, const RegistryPath &key, float &value, float defval=0.0) override
 
bool GetPrivateConfig (const RegistryPath &group, const RegistryPath &key, double &value, double defval=0.0) override
 
bool SetPrivateConfig (const RegistryPath &group, const RegistryPath &key, const wxString &value) override
 
bool SetPrivateConfig (const RegistryPath &group, const RegistryPath &key, const int &value) override
 
bool SetPrivateConfig (const RegistryPath &group, const RegistryPath &key, const bool &value) override
 
bool SetPrivateConfig (const RegistryPath &group, const RegistryPath &key, const float &value) override
 
bool SetPrivateConfig (const RegistryPath &group, const RegistryPath &key, const double &value) override
 
bool RemovePrivateConfigSubgroup (const RegistryPath &group) override
 
bool RemovePrivateConfig (const RegistryPath &group, const RegistryPath &key) override
 
virtual PluginID GetID ()
 
virtual bool Startup (EffectClientInterface *client)
 
virtual bool Startup ()
 
virtual bool GetAutomationParameters (wxString &parms)
 
virtual bool SetAutomationParameters (const wxString &parms)
 
virtual RegistryPaths GetUserPresets ()
 
virtual bool HasCurrentSettings ()
 
virtual bool HasFactoryDefaults ()
 
virtual ManualPageID ManualPage ()
 
virtual FilePath HelpPage ()
 
virtual void SetUIFlags (unsigned flags)
 
virtual unsigned TestUIFlags (unsigned mask)
 
virtual bool IsBatchProcessing ()
 
virtual void SetBatchProcessing (bool start)
 
void SetPresetParameters (const wxArrayString *Names, const wxArrayString *Values)
 
bool DoEffect (double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, wxWindow *pParent=nullptr, const EffectDialogFactory &dialogFactory={})
 
bool Delegate (Effect &delegate, wxWindow &parent, const EffectDialogFactory &factory)
 
virtual bool IsHidden ()
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 
- Public Member Functions inherited from EffectClientInterface
virtual ~EffectClientInterface ()
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
virtual EffectType GetClassification ()
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
TranslatableString GetName ()
 
virtual bool DefineParams (ShuttleParams &WXUNUSED(S))
 
- Public Member Functions inherited from EffectUIClientInterface
virtual ~EffectUIClientInterface ()
 
- Public Member Functions inherited from EffectHostInterface
virtual ~EffectHostInterface ()
 
- Public Member Functions inherited from ConfigClientInterface
virtual ~ConfigClientInterface ()
 

Static Public Member Functions

static double getInvertedStretchedTime (double rateStart, double rateEnd, SlideType slideType, double outputTime)
 
static double getRate (double rateStart, double rateEnd, SlideType slideType, double t)
 
- Static Public Member Functions inherited from Effect
static VetoDialogHook SetVetoDialogHook (VetoDialogHook hook)
 
static CommandID GetSquashedName (wxString name)
 
static void IncEffectCounter ()
 

Protected Member Functions

ComponentInterfaceSymbol GetSymbol () override
 
- Protected Member Functions inherited from Effect
virtual bool Init ()
 
virtual bool CheckWhetherSkipEffect ()
 
virtual bool ProcessPass ()
 
virtual bool InitPass1 ()
 
virtual bool InitPass2 ()
 
virtual int GetPass ()
 
virtual void End ()
 
virtual double CalcPreviewInputLength (double previewLength)
 
virtual void Preview (bool dryOnly)
 
virtual void PopulateOrExchange (ShuttleGui &S)
 
virtual bool TransferDataToWindow ()
 
virtual bool TransferDataFromWindow ()
 
virtual bool EnableApply (bool enable=true)
 
virtual bool EnablePreview (bool enable=true)
 
virtual void EnableDebug (bool enable=true)
 
bool TotalProgress (double frac, const TranslatableString &={})
 
bool TrackProgress (int whichTrack, double frac, const TranslatableString &={})
 
bool TrackGroupProgress (int whichGroup, double frac, const TranslatableString &={})
 
int GetNumWaveTracks ()
 
int GetNumWaveGroups ()
 
void GetBounds (const WaveTrack &track, const WaveTrack *pRight, sampleCount *start, sampleCount *len)
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing ()
 
void IncludeNotSelectedPreviewTracks (bool includeNotSelected)
 
void CopyInputTracks (bool allSyncLockSelected=false)
 
std::shared_ptr< AddedAnalysisTrackAddAnalysisTrack (const wxString &name=wxString())
 
ModifiedAnalysisTrack ModifyAnalysisTrack (const LabelTrack *pOrigTrack, const wxString &name=wxString())
 
void ReplaceProcessedTracks (const bool bGoodResult)
 
TrackAddToOutputTracks (const std::shared_ptr< Track > &t)
 
const TrackListinputTracks () const
 
const AudacityProjectFindProject () const
 

Protected Attributes

TranslatableString mProxyEffectName { XO("SBSMS Time / Pitch Stretch") }
 
- Protected Attributes inherited from Effect
ProgressDialogmProgress
 
double mProjectRate
 
double mSampleRate
 
wxWeakRef< NotifyingSelectedRegionmpSelectedRegion {}
 
WaveTrackFactorymFactory
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0
 
double mT1
 
wxArrayString mPresetNames
 
wxArrayString mPresetValues
 
int mPass
 
wxDialog * mUIDialog
 
wxWindow * mUIParent
 
int mUIResultID
 
unsigned mUIFlags
 
sampleCount mSampleCnt
 

Private Member Functions

bool ProcessLabelTrack (LabelTrack *track)
 
void Finalize (WaveTrack *orig, WaveTrack *out, const TimeWarper *warper)
 

Private Attributes

double rateStart
 
double rateEnd
 
double pitchStart
 
double pitchEnd
 
bool bLinkRatePitch
 
bool bRateReferenceInput
 
bool bPitchReferenceInput
 
SlideType rateSlideType
 
SlideType pitchSlideType
 
int mCurTrackNum
 
double mCurT0
 
double mCurT1
 
float mTotalStretch
 

Friends

class EffectChangeTempo
 
class EffectChangePitch
 

Additional Inherited Members

- Public Types inherited from Effect
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
using VetoDialogHook = bool(*)(wxDialog *)
 
- Public Types inherited from EffectClientInterface
using EffectDialogFactory = std::function< wxDialog *(wxWindow &parent, EffectHostInterface *, EffectUIClientInterface *) >
 
- Static Public Attributes inherited from Effect
static const wxString kUserPresetIdent = wxT("User Preset:")
 
static const wxString kFactoryPresetIdent = wxT("Factory Preset:")
 
static const wxString kCurrentSettingsIdent = wxT("<Current Settings>")
 
static const wxString kFactoryDefaultsIdent = wxT("<Factory Defaults>")
 
- Static Protected Attributes inherited from Effect
static int nEffectsDone =0
 

Detailed Description

Definition at line 29 of file SBSMSEffect.h.

Member Function Documentation

◆ Finalize()

void EffectSBSMS::Finalize ( WaveTrack orig,
WaveTrack out,
const TimeWarper warper 
)
private

Definition at line 430 of file SBSMSEffect.cpp.

431 {
432  // Silenced samples will be inserted in gaps between clips, so capture where these
433  // gaps are for later deletion
434  std::vector<std::pair<double, double>> gaps;
435  double last = mCurT0;
436  auto clips = orig->SortedClipArray();
437  auto front = clips.front();
438  auto back = clips.back();
439  for (auto &clip : clips) {
440  auto st = clip->GetStartTime();
441  auto et = clip->GetEndTime();
442 
443  if (st >= mCurT0 || et < mCurT1) {
444  if (mCurT0 < st && clip == front) {
445  gaps.push_back(std::make_pair(mCurT0, st));
446  }
447  else if (last < st && mCurT0 <= last ) {
448  gaps.push_back(std::make_pair(last, st));
449  }
450 
451  if (et < mCurT1 && clip == back) {
452  gaps.push_back(std::make_pair(et, mCurT1));
453  }
454  }
455  last = et;
456  }
457 
458  // Take the output track and insert it in place of the original sample data
459  orig->ClearAndPaste(mCurT0, mCurT1, out, true, true, warper);
460 
461  // Finally, recreate the gaps
462  for (auto gap : gaps) {
463  auto st = orig->LongSamplesToTime(orig->TimeToLongSamples(gap.first));
464  auto et = orig->LongSamplesToTime(orig->TimeToLongSamples(gap.second));
465  if (st >= mCurT0 && et <= mCurT1 && st != et)
466  {
467  orig->SplitDelete(warper->Warp(st), warper->Warp(et));
468  }
469  }
470 }

References WaveTrack::ClearAndPaste(), gap, WaveTrack::LongSamplesToTime(), mCurT0, mCurT1, WaveTrack::SortedClipArray(), WaveTrack::SplitDelete(), WaveTrack::TimeToLongSamples(), and TimeWarper::Warp().

Referenced by Process().

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

◆ getInvertedStretchedTime()

double EffectSBSMS::getInvertedStretchedTime ( double  rateStart,
double  rateEnd,
SlideType  slideType,
double  outputTime 
)
static

Definition at line 200 of file SBSMSEffect.cpp.

201 {
202  Slide slide(slideType,rateStart,rateEnd,0);
203  return slide.getInverseStretchedTime(outputTime);
204 }

References rateEnd, and rateStart.

Referenced by EffectTimeScale::CalcPreviewInputLength().

Here is the caller graph for this function:

◆ getRate()

double EffectSBSMS::getRate ( double  rateStart,
double  rateEnd,
SlideType  slideType,
double  t 
)
static

Definition at line 206 of file SBSMSEffect.cpp.

207 {
208  Slide slide(slideType,rateStart,rateEnd,0);
209  return slide.getRate(t);
210 }

References rateEnd, and rateStart.

Referenced by EffectTimeScale::Process().

Here is the caller graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol EffectSBSMS::GetSymbol ( )
inlineoverrideprotectedvirtual

Reimplemented from Effect.

Reimplemented in EffectTimeScale.

Definition at line 45 of file SBSMSEffect.h.

45 { return mProxyEffectName; }

◆ Process()

bool EffectSBSMS::Process ( )
overridevirtual

Reimplemented from Effect.

Reimplemented in EffectTimeScale.

Definition at line 212 of file SBSMSEffect.cpp.

213 {
214  bool bGoodResult = true;
215 
216  //Iterate over each track
217  //all needed because this effect needs to introduce silence in the group tracks to keep sync
218  this->CopyInputTracks(true); // Set up mOutputTracks.
219  mCurTrackNum = 0;
220 
221  double maxDuration = 0.0;
222 
223  // Must sync if selection length will change
224  bool mustSync = (rateStart != rateEnd);
225  Slide rateSlide(rateSlideType,rateStart,rateEnd);
226  Slide pitchSlide(pitchSlideType,pitchStart,pitchEnd);
227  mTotalStretch = rateSlide.getTotalStretch();
228 
229  mOutputTracks->Leaders().VisitWhile( bGoodResult,
230  [&](LabelTrack *lt, const Track::Fallthrough &fallthrough) {
231  if (!(lt->GetSelected() || (mustSync && lt->IsSyncLockSelected())))
232  return fallthrough();
233  if (!ProcessLabelTrack(lt))
234  bGoodResult = false;
235  },
236  [&](WaveTrack *leftTrack, const Track::Fallthrough &fallthrough) {
237  if (!leftTrack->GetSelected())
238  return fallthrough();
239 
240  //Get start and end times from selection
241  mCurT0 = mT0;
242  mCurT1 = mT1;
243 
244  //Set the current bounds to whichever left marker is
245  //greater and whichever right marker is less
246  mCurT0 = wxMax(mT0, mCurT0);
247  mCurT1 = wxMin(mT1, mCurT1);
248 
249  // Process only if the right marker is to the right of the left marker
250  if (mCurT1 > mCurT0) {
251  auto start = leftTrack->TimeToLongSamples(mCurT0);
252  auto end = leftTrack->TimeToLongSamples(mCurT1);
253 
254  // TODO: more-than-two-channels
255  auto channels = TrackList::Channels(leftTrack);
256  WaveTrack *rightTrack = (channels.size() > 1)
257  ? * ++ channels.first
258  : nullptr;
259  if (rightTrack) {
260  double t;
261 
262  //Adjust bounds by the right tracks markers
263  t = rightTrack->GetStartTime();
264  t = wxMax(mT0, t);
265  mCurT0 = wxMin(mCurT0, t);
266  t = rightTrack->GetEndTime();
267  t = wxMin(mT1, t);
268  mCurT1 = wxMax(mCurT1, t);
269 
270  //Transform the marker timepoints to samples
271  start = leftTrack->TimeToLongSamples(mCurT0);
272  end = leftTrack->TimeToLongSamples(mCurT1);
273 
274  mCurTrackNum++; // Increment for rightTrack, too.
275  }
276 
277  // SBSMS has a fixed sample rate - we just convert to its sample rate and then convert back
278  float srTrack = leftTrack->GetRate();
279  float srProcess = bLinkRatePitch ? srTrack : 44100.0;
280 
281  // the resampler needs a callback to supply its samples
282  ResampleBuf rb;
283  auto maxBlockSize = leftTrack->GetMaxBlockSize();
284  rb.blockSize = maxBlockSize;
285  rb.buf.reinit(rb.blockSize, true);
286  rb.leftTrack = leftTrack;
287  rb.rightTrack = rightTrack?rightTrack:leftTrack;
288  rb.leftBuffer.reinit(maxBlockSize, true);
289  rb.rightBuffer.reinit(maxBlockSize, true);
290 
291  // Samples in selection
292  auto samplesIn = end - start;
293 
294  // Samples for SBSMS to process after resampling
295  auto samplesToProcess = (sampleCount) (samplesIn.as_float() * (srProcess/srTrack));
296 
297  SlideType outSlideType;
298  SBSMSResampleCB outResampleCB;
299 
300  if(bLinkRatePitch) {
301  rb.bPitch = true;
302  outSlideType = rateSlideType;
303  outResampleCB = resampleCB;
304  rb.offset = start;
305  rb.end = end;
306  // Third party library has its own type alias, check it
307  static_assert(sizeof(sampleCount::type) <=
308  sizeof(_sbsms_::SampleCountType),
309  "Type _sbsms_::SampleCountType is too narrow to hold a sampleCount");
310  rb.iface = std::make_unique<SBSMSInterfaceSliding>
311  (&rateSlide, &pitchSlide, bPitchReferenceInput,
312  static_cast<_sbsms_::SampleCountType>
313  ( samplesToProcess.as_long_long() ),
314  0, nullptr);
315 
316  }
317  else {
318  rb.bPitch = false;
319  outSlideType = (srProcess==srTrack?SlideIdentity:SlideConstant);
320  outResampleCB = postResampleCB;
321  rb.ratio = srProcess/srTrack;
322  rb.quality = std::make_unique<SBSMSQuality>(&SBSMSQualityStandard);
323  rb.resampler = std::make_unique<Resampler>(resampleCB, &rb, srProcess==srTrack?SlideIdentity:SlideConstant);
324  rb.sbsms = std::make_unique<SBSMS>(rightTrack ? 2 : 1, rb.quality.get(), true);
325  rb.SBSMSBlockSize = rb.sbsms->getInputFrameSize();
326  rb.SBSMSBuf.reinit(static_cast<size_t>(rb.SBSMSBlockSize), true);
327  rb.offset = start;
328  rb.end = end;
329  rb.iface = std::make_unique<SBSMSEffectInterface>
330  (rb.resampler.get(), &rateSlide, &pitchSlide,
332  static_cast<_sbsms_::SampleCountType>( samplesToProcess.as_long_long() ),
333  0,
334  rb.quality.get());
335  }
336 
337  Resampler resampler(outResampleCB,&rb,outSlideType);
338 
339  audio outBuf[SBSMSOutBlockSize];
340  float outBufLeft[2*SBSMSOutBlockSize];
341  float outBufRight[2*SBSMSOutBlockSize];
342 
343  // Samples in output after SBSMS
344  sampleCount samplesToOutput = rb.iface->getSamplesToOutput();
345 
346  // Samples in output after resampling back
347  auto samplesOut = (sampleCount) (samplesToOutput.as_float() * (srTrack/srProcess));
348 
349  // Duration in track time
350  double duration = (mCurT1-mCurT0) * mTotalStretch;
351 
352  if(duration > maxDuration)
353  maxDuration = duration;
354 
355  auto warper = createTimeWarper(mCurT0,mCurT1,maxDuration,rateStart,rateEnd,rateSlideType);
356 
357  rb.outputLeftTrack = leftTrack->EmptyCopy();
358  if(rightTrack)
359  rb.outputRightTrack = rightTrack->EmptyCopy();
360 
361  long pos = 0;
362  long outputCount = -1;
363 
364  // process
365  while(pos<samplesOut && outputCount) {
366  const auto frames =
367  limitSampleBufferSize( SBSMSOutBlockSize, samplesOut - pos );
368 
369  outputCount = resampler.read(outBuf,frames);
370  for(int i = 0; i < outputCount; i++) {
371  outBufLeft[i] = outBuf[i][0];
372  if(rightTrack)
373  outBufRight[i] = outBuf[i][1];
374  }
375  pos += outputCount;
376  rb.outputLeftTrack->Append((samplePtr)outBufLeft, floatSample, outputCount);
377  if(rightTrack)
378  rb.outputRightTrack->Append((samplePtr)outBufRight, floatSample, outputCount);
379 
380  double frac = (double)pos / samplesOut.as_double();
381  int nWhichTrack = mCurTrackNum;
382  if(rightTrack) {
383  nWhichTrack = 2*(mCurTrackNum/2);
384  if (frac < 0.5)
385  frac *= 2.0; // Show twice as far for each track, because we're doing 2 at once.
386  else {
387  nWhichTrack++;
388  frac -= 0.5;
389  frac *= 2.0; // Show twice as far for each track, because we're doing 2 at once.
390  }
391  }
392  if (TrackProgress(nWhichTrack, frac)) {
393  bGoodResult = false;
394  return;
395  }
396  }
397 
398  {
399  auto pException = rb.mpException;
400  rb.mpException = {};
401  if (pException)
402  std::rethrow_exception(pException);
403  }
404 
405  rb.outputLeftTrack->Flush();
406  if(rightTrack)
407  rb.outputRightTrack->Flush();
408 
409  Finalize(leftTrack, rb.outputLeftTrack.get(), warper.get());
410  if(rightTrack)
411  Finalize(rightTrack, rb.outputRightTrack.get(), warper.get());
412  }
413  mCurTrackNum++;
414  },
415  [&](Track *t) {
416  if (mustSync && t->IsSyncLockSelected())
417  {
418  t->SyncLockAdjust(mCurT1, mCurT0 + (mCurT1 - mCurT0) * mTotalStretch);
419  }
420  }
421  );
422 
423  if (bGoodResult) {
424  ReplaceProcessedTracks(bGoodResult);
425  }
426 
427  return bGoodResult;
428 }

References sampleCount::as_float(), bLinkRatePitch, ResampleBuf::blockSize, ResampleBuf::bPitch, bPitchReferenceInput, ResampleBuf::buf, TrackList::Channels(), Effect::CopyInputTracks(), createTimeWarper(), WaveTrack::EmptyCopy(), ResampleBuf::end, Finalize(), floatSample, WaveTrack::GetEndTime(), WaveTrack::GetMaxBlockSize(), WaveTrack::GetRate(), Track::GetSelected(), WaveTrack::GetStartTime(), ResampleBuf::iface, Track::IsSyncLockSelected(), ResampleBuf::leftBuffer, ResampleBuf::leftTrack, limitSampleBufferSize(), mCurT0, mCurT1, mCurTrackNum, Effect::mOutputTracks, ResampleBuf::mpException, Effect::mT0, Effect::mT1, mTotalStretch, ResampleBuf::offset, ResampleBuf::outputLeftTrack, ResampleBuf::outputRightTrack, pitchEnd, pitchSlideType, pitchStart, postResampleCB(), ProcessLabelTrack(), ResampleBuf::quality, rateEnd, rateSlideType, rateStart, ResampleBuf::ratio, ArrayOf< X >::reinit(), Effect::ReplaceProcessedTracks(), resampleCB(), ResampleBuf::resampler, ResampleBuf::rightBuffer, ResampleBuf::rightTrack, ResampleBuf::sbsms, ResampleBuf::SBSMSBlockSize, ResampleBuf::SBSMSBuf, SBSMSOutBlockSize, WaveTrack::TimeToLongSamples(), and Effect::TrackProgress().

Referenced by EffectTimeScale::Process().

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

◆ ProcessLabelTrack()

bool EffectSBSMS::ProcessLabelTrack ( LabelTrack track)
private

Definition at line 192 of file SBSMSEffect.cpp.

193 {
195  RegionTimeWarper warper{ mT0, mT1, std::move(warper1) };
196  lt->WarpLabels(warper);
197  return true;
198 }

References createTimeWarper(), Effect::mT0, Effect::mT1, mTotalStretch, rateEnd, rateSlideType, rateStart, and LabelTrack::WarpLabels().

Referenced by Process().

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

◆ setParameters() [1/2]

void EffectSBSMS::setParameters ( double  rateStart,
double  rateEnd,
double  pitchStart,
double  pitchEnd,
SlideType  rateSlideType,
SlideType  pitchSlideType,
bool  bLinkRatePitch,
bool  bRateReferenceInput,
bool  bPitchReferenceInput 
)

Definition at line 147 of file SBSMSEffect.cpp.

150 {
151  this->rateStart = rateStartIn;
152  this->rateEnd = rateEndIn;
153  this->pitchStart = pitchStartIn;
154  this->pitchEnd = pitchEndIn;
155  this->bLinkRatePitch = bLinkRatePitchIn;
156  this->rateSlideType = rateSlideTypeIn;
157  this->pitchSlideType = pitchSlideTypeIn;
158  this->bRateReferenceInput = bRateReferenceInputIn;
159  this->bPitchReferenceInput = bPitchReferenceInputIn;
160 }

References bLinkRatePitch, bPitchReferenceInput, bRateReferenceInput, pitchEnd, pitchSlideType, pitchStart, rateEnd, rateSlideType, and rateStart.

Referenced by EffectTimeScale::Process(), and setParameters().

Here is the caller graph for this function:

◆ setParameters() [2/2]

void EffectSBSMS::setParameters ( double  tempoRatio,
double  pitchRatio 
)

Definition at line 162 of file SBSMSEffect.cpp.

163 {
164  setParameters(tempoRatio, tempoRatio, pitchRatio, pitchRatio,
165  SlideConstant, SlideConstant, false, false, false);
166 }

References setParameters().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ EffectChangePitch

friend class EffectChangePitch
friend

Definition at line 61 of file SBSMSEffect.h.

◆ EffectChangeTempo

friend class EffectChangeTempo
friend

Definition at line 60 of file SBSMSEffect.h.

Member Data Documentation

◆ bLinkRatePitch

bool EffectSBSMS::bLinkRatePitch
private

Definition at line 52 of file SBSMSEffect.h.

Referenced by Process(), and setParameters().

◆ bPitchReferenceInput

bool EffectSBSMS::bPitchReferenceInput
private

Definition at line 52 of file SBSMSEffect.h.

Referenced by Process(), and setParameters().

◆ bRateReferenceInput

bool EffectSBSMS::bRateReferenceInput
private

Definition at line 52 of file SBSMSEffect.h.

Referenced by setParameters().

◆ mCurT0

double EffectSBSMS::mCurT0
private

Definition at line 56 of file SBSMSEffect.h.

Referenced by Finalize(), and Process().

◆ mCurT1

double EffectSBSMS::mCurT1
private

Definition at line 57 of file SBSMSEffect.h.

Referenced by Finalize(), and Process().

◆ mCurTrackNum

int EffectSBSMS::mCurTrackNum
private

Definition at line 55 of file SBSMSEffect.h.

Referenced by Process().

◆ mProxyEffectName

TranslatableString EffectSBSMS::mProxyEffectName { XO("SBSMS Time / Pitch Stretch") }
protected

Definition at line 41 of file SBSMSEffect.h.

◆ mTotalStretch

float EffectSBSMS::mTotalStretch
private

Definition at line 58 of file SBSMSEffect.h.

Referenced by Process(), and ProcessLabelTrack().

◆ pitchEnd

double EffectSBSMS::pitchEnd
private

Definition at line 51 of file SBSMSEffect.h.

Referenced by Process(), and setParameters().

◆ pitchSlideType

SlideType EffectSBSMS::pitchSlideType
private

Definition at line 54 of file SBSMSEffect.h.

Referenced by Process(), and setParameters().

◆ pitchStart

double EffectSBSMS::pitchStart
private

Definition at line 51 of file SBSMSEffect.h.

Referenced by Process(), and setParameters().

◆ rateEnd

double EffectSBSMS::rateEnd
private

◆ rateSlideType

SlideType EffectSBSMS::rateSlideType
private

Definition at line 53 of file SBSMSEffect.h.

Referenced by Process(), ProcessLabelTrack(), and setParameters().

◆ rateStart

double EffectSBSMS::rateStart
private

The documentation for this class was generated from the following files:
EffectSBSMS::mProxyEffectName
TranslatableString mProxyEffectName
Definition: SBSMSEffect.h:41
EffectSBSMS::rateEnd
double rateEnd
Definition: SBSMSEffect.h:51
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
EffectSBSMS::mTotalStretch
float mTotalStretch
Definition: SBSMSEffect.h:58
EffectSBSMS::bPitchReferenceInput
bool bPitchReferenceInput
Definition: SBSMSEffect.h:52
EffectSBSMS::pitchStart
double pitchStart
Definition: SBSMSEffect.h:51
ResampleBuf::leftBuffer
ArrayOf< float > leftBuffer
Definition: SBSMSEffect.cpp:50
WaveTrack::GetEndTime
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Definition: WaveTrack.cpp:1895
Effect::CopyInputTracks
void CopyInputTracks(bool allSyncLockSelected=false)
Definition: Effect.cpp:2071
EffectSBSMS::mCurT1
double mCurT1
Definition: SBSMSEffect.h:57
TrackList::Channels
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1484
Effect::mT1
double mT1
Definition: Effect.h:467
ArrayOf::reinit
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:57
ResampleBuf::sbsms
std::unique_ptr< SBSMS > sbsms
Definition: SBSMSEffect.cpp:54
SBSMSOutBlockSize
@ SBSMSOutBlockSize
Definition: SBSMSEffect.cpp:27
LabelTrack
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:88
ResampleBuf::mpException
std::exception_ptr mpException
Definition: SBSMSEffect.cpp:64
gap
static const int gap
Definition: MeterPanel.cpp:255
WaveTrack::ClearAndPaste
void ClearAndPaste(double t0, double t1, const Track *src, bool preserve=true, bool merge=true, const TimeWarper *effectWarper=NULL)
Definition: WaveTrack.cpp:847
sampleCount::as_float
float as_float() const
Definition: SampleCount.h:44
Track::IsSyncLockSelected
bool IsSyncLockSelected() const
Definition: Track.cpp:254
WaveTrack::EmptyCopy
Holder EmptyCopy(const SampleBlockFactoryPtr &pFactory={}) const
Definition: WaveTrack.cpp:666
WaveTrack::SplitDelete
void SplitDelete(double t0, double t1)
Definition: WaveTrack.cpp:1010
WaveTrack::SortedClipArray
WaveClipPointers SortedClipArray()
Definition: WaveTrack.cpp:2606
ResampleBuf
Definition: SBSMSEffect.cpp:31
EffectSBSMS::mCurTrackNum
int mCurTrackNum
Definition: SBSMSEffect.h:55
floatSample
@ floatSample
Definition: SampleFormat.h:34
ResampleBuf::rightBuffer
ArrayOf< float > rightBuffer
Definition: SBSMSEffect.cpp:51
ResampleBuf::offset
sampleCount offset
Definition: SBSMSEffect.cpp:48
ResampleBuf::blockSize
size_t blockSize
Definition: SBSMSEffect.cpp:46
Effect::mT0
double mT0
Definition: Effect.h:466
postResampleCB
long postResampleCB(void *cb_data, SBSMSFrame *data)
Definition: SBSMSEffect.cpp:136
WaveTrack::LongSamplesToTime
double LongSamplesToTime(sampleCount pos) const
Convert correctly between a number of samples and an (absolute) time in seconds.
Definition: WaveTrack.cpp:1870
EffectSBSMS::bLinkRatePitch
bool bLinkRatePitch
Definition: SBSMSEffect.h:52
ResampleBuf::quality
std::unique_ptr< SBSMSQuality > quality
Definition: SBSMSEffect.cpp:60
EffectSBSMS::bRateReferenceInput
bool bRateReferenceInput
Definition: SBSMSEffect.h:52
RegionTimeWarper
No change before the specified region; during the region, warp according to the given warper; after t...
Definition: TimeWarper.h:192
ResampleBuf::ratio
double ratio
Definition: SBSMSEffect.cpp:44
ResampleBuf::iface
std::unique_ptr< SBSMSInterface > iface
Definition: SBSMSEffect.cpp:55
Effect::ReplaceProcessedTracks
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: Effect.cpp:2193
Track::Fallthrough
Continuation<> Fallthrough
Type of arguments passed as optional second parameter to TypeSwitch<void>() cases.
Definition: Track.h:504
EffectSBSMS::ProcessLabelTrack
bool ProcessLabelTrack(LabelTrack *track)
Definition: SBSMSEffect.cpp:192
WaveTrack::GetStartTime
double GetStartTime() const override
Get the time at which the first clip in the track starts.
Definition: WaveTrack.cpp:1875
sampleCount::type
long long type
Definition: SampleCount.h:20
TimeWarper::Warp
virtual double Warp(double originalTime) const =0
Effect::mOutputTracks
std::shared_ptr< TrackList > mOutputTracks
Definition: Effect.h:465
EffectSBSMS::rateStart
double rateStart
Definition: SBSMSEffect.h:51
Track::GetSelected
bool GetSelected() const
Definition: Track.h:431
samplePtr
char * samplePtr
Definition: SampleFormat.h:49
WaveTrack::GetMaxBlockSize
size_t GetMaxBlockSize() const
Definition: WaveTrack.cpp:1669
ResampleBuf::leftTrack
WaveTrack * leftTrack
Definition: SBSMSEffect.cpp:52
resampleCB
long resampleCB(void *cb_data, SBSMSFrame *data)
Definition: SBSMSEffect.cpp:88
WaveTrack::TimeToLongSamples
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: WaveTrack.cpp:1865
ResampleBuf::outputLeftTrack
std::shared_ptr< WaveTrack > outputLeftTrack
Definition: SBSMSEffect.cpp:61
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:239
ResampleBuf::outputRightTrack
std::shared_ptr< WaveTrack > outputRightTrack
Definition: SBSMSEffect.cpp:62
ResampleBuf::end
sampleCount end
Definition: SBSMSEffect.cpp:49
ResampleBuf::rightTrack
WaveTrack * rightTrack
Definition: SBSMSEffect.cpp:53
sampleCount
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:18
EffectSBSMS::pitchSlideType
SlideType pitchSlideType
Definition: SBSMSEffect.h:54
EffectSBSMS::mCurT0
double mCurT0
Definition: SBSMSEffect.h:56
EffectSBSMS::Finalize
void Finalize(WaveTrack *orig, WaveTrack *out, const TimeWarper *warper)
Definition: SBSMSEffect.cpp:430
ResampleBuf::buf
ArrayOf< audio > buf
Definition: SBSMSEffect.cpp:43
ResampleBuf::bPitch
bool bPitch
Definition: SBSMSEffect.cpp:42
EffectSBSMS::pitchEnd
double pitchEnd
Definition: SBSMSEffect.h:51
limitSampleBufferSize
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: SampleCount.cpp:23
Effect::TrackProgress
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={})
Definition: Effect.cpp:2025
ResampleBuf::SBSMSBlockSize
long SBSMSBlockSize
Definition: SBSMSEffect.cpp:47
ResampleBuf::SBSMSBuf
ArrayOf< audio > SBSMSBuf
Definition: SBSMSEffect.cpp:56
createTimeWarper
std::unique_ptr< TimeWarper > createTimeWarper(double t0, double t1, double duration, double rateStart, double rateEnd, SlideType rateSlideType)
Definition: SBSMSEffect.cpp:168
EffectSBSMS::rateSlideType
SlideType rateSlideType
Definition: SBSMSEffect.h:53
ResampleBuf::resampler
std::unique_ptr< Resampler > resampler
Definition: SBSMSEffect.cpp:59
EffectSBSMS::setParameters
void setParameters(double rateStart, double rateEnd, double pitchStart, double pitchEnd, SlideType rateSlideType, SlideType pitchSlideType, bool bLinkRatePitch, bool bRateReferenceInput, bool bPitchReferenceInput)
Definition: SBSMSEffect.cpp:147
WaveTrack::GetRate
double GetRate() const
Definition: WaveTrack.cpp:452