Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
PaulstretchBase Class Reference

An Extreme Time Stretch and Time Smear effect. More...

#include <PaulstretchBase.h>

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

Public Member Functions

 PaulstretchBase ()
 
virtual ~PaulstretchBase ()
 
ComponentInterfaceSymbol GetSymbol () const override
 
TranslatableString GetDescription () const override
 
ManualPageID ManualPage () const override
 Name of a page in the Audacity alpha manual, default is empty. More...
 
EffectType GetType () const override
 Type determines how it behaves. More...
 
double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const override
 
bool Process (EffectInstance &instance, EffectSettings &settings) override
 
- Public Member Functions inherited from StatefulEffect
 ~StatefulEffect () override
 
std::shared_ptr< EffectInstanceMakeInstance () const override
 Make an object maintaining short-term state of an Effect. More...
 
- Public Member Functions inherited from StatefulEffectBase
virtual bool Init ()
 
virtual bool Process (EffectInstance &instance, EffectSettings &settings)=0
 
virtual bool RealtimeInitialize (EffectSettings &settings, double sampleRate)
 
virtual bool RealtimeAddProcessor (EffectSettings &settings, EffectOutputs *pOutputs, unsigned numChannels, float sampleRate)
 
virtual bool RealtimeSuspend ()
 
virtual bool RealtimeResume ()
 
virtual bool RealtimeProcessStart (MessagePackage &package)
 settings are possibly changed, since last call, by an asynchronous dialog More...
 
virtual size_t RealtimeProcess (size_t group, EffectSettings &settings, const float *const *inBuf, float *const *outBuf, size_t numSamples)
 
virtual bool RealtimeProcessEnd (EffectSettings &settings) noexcept
 settings can be updated to let a dialog change appearance at idle More...
 
virtual bool RealtimeFinalize (EffectSettings &settings) noexcept
 
virtual size_t SetBlockSize (size_t maxBlockSize)
 
virtual size_t GetBlockSize () const
 
virtual unsigned GetAudioInCount () const
 How many input buffers to allocate at once. More...
 
virtual unsigned GetAudioOutCount () const
 How many output buffers to allocate at once. More...
 
virtual sampleCount GetLatency () const
 
virtual bool NeedsDither () const
 
virtual bool ProcessInitialize (EffectSettings &settings, double sampleRate, ChannelNames chanMap=nullptr)
 
virtual bool ProcessFinalize () noexcept
 
- Public Member Functions inherited from Effect
 Effect ()
 
virtual ~Effect ()
 
PluginPath GetPath () const override
 
bool VisitSettings (SettingsVisitor &visitor, EffectSettings &settings) override
 
bool VisitSettings (ConstSettingsVisitor &visitor, const EffectSettings &settings) const override
 
ComponentInterfaceSymbol GetSymbol () const override
 
VendorSymbol GetVendor () const override
 
wxString GetVersion () const override
 
TranslatableString GetDescription () const override
 
EffectFamilySymbol GetFamily () const override
 Report identifier and user-visible name of the effect protocol. More...
 
bool IsInteractive () const override
 Whether the effect needs a dialog for entry of settings. More...
 
bool IsDefault () const override
 Whether the effect sorts "above the line" in the menus. More...
 
RealtimeSince RealtimeSupport () const override
 Since which version of Audacity has the effect supported realtime? More...
 
bool SupportsAutomation () const override
 Whether the effect has any automatable controls. More...
 
bool SaveSettings (const EffectSettings &settings, CommandParameters &parms) const override
 Store settings as keys and values. More...
 
bool LoadSettings (const CommandParameters &parms, EffectSettings &settings) const override
 Restore settings from keys and values. More...
 
OptionalMessage LoadUserPreset (const RegistryPath &name, EffectSettings &settings) const override
 
bool SaveUserPreset (const RegistryPath &name, const EffectSettings &settings) const override
 Save settings in the configuration file as a user-named preset. More...
 
RegistryPaths GetFactoryPresets () const override
 Report names of factory presets. More...
 
OptionalMessage LoadFactoryPreset (int id, EffectSettings &settings) const override
 
OptionalMessage LoadFactoryDefaults (EffectSettings &settings) const override
 
virtual const EffectParameterMethodsParameters () const
 
bool CanExportPresets () const override
 Whether the effect supports export of presets to files, and importing too. More...
 
bool HasOptions () const override
 
const EffectSettingsManagerGetDefinition () const override
 
virtual NumericFormatID GetSelectionFormat ()
 
bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const override
 
OptionalMessage LoadSettingsFromString (const wxString &parms, EffectSettings &settings) const override
 
bool IsBatchProcessing () const override
 
void SetBatchProcessing () override
 
void UnsetBatchProcessing () override
 
unsigned TestUIFlags (unsigned mask)
 
bool Delegate (Effect &delegate, EffectSettings &settings, InstanceFinder finder={})
 Re-invoke DoEffect on another Effect object that implements the work. More...
 
- Public Member Functions inherited from EffectBase
 EffectBase ()
 
 ~EffectBase () override
 
bool IsLinearEffect () const
 
bool PreviewsFullSelection () const
 
void SetTracks (TrackList *pTracks)
 
double GetDefaultDuration ()
 
virtual std::any BeginPreview (const EffectSettings &settings)
 Called when Preview() starts, to allow temporary effect state changes. More...
 
bool DoEffect (EffectSettings &settings, const InstanceFinder &finder, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, const EffectSettingsAccessPtr &pAccess) override
 
virtual double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const =0
 
void CountWaveTracks ()
 
- Public Member Functions inherited from EffectPlugin
EffectPluginoperator= (EffectPlugin &)=delete
 
virtual ~EffectPlugin ()
 
virtual bool HasOptions () const =0
 
virtual bool CanExportPresets () const =0
 Whether the effect supports export of presets to files, and importing too. More...
 
virtual const EffectSettingsManagerGetDefinition () const =0
 
virtual bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const =0
 
virtual OptionalMessage LoadSettingsFromString (const wxString &parms, EffectSettings &settings) const =0
 
virtual bool IsBatchProcessing () const =0
 
virtual void SetBatchProcessing ()=0
 
virtual void UnsetBatchProcessing ()=0
 
virtual bool DoEffect (EffectSettings &settings, const InstanceFinder &finder, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, const EffectSettingsAccessPtr &pAccess=nullptr)=0
 
- Public Member Functions inherited from EffectInstanceFactory
virtual ~EffectInstanceFactory ()
 
virtual std::shared_ptr< EffectInstanceMakeInstance () const =0
 Make an object maintaining short-term state of an Effect. More...
 
- Public Member Functions inherited from EffectSettingsManager
virtual ~EffectSettingsManager ()
 
virtual bool VisitSettings (SettingsVisitor &visitor, EffectSettings &settings)
 
virtual bool VisitSettings (ConstSettingsVisitor &visitor, const EffectSettings &settings) const
 
virtual EffectSettings MakeSettings () const
 
virtual bool CopySettingsContents (const EffectSettings &src, EffectSettings &dst) const
 Update one settings object from another. More...
 
virtual std::unique_ptr< EffectOutputsMakeOutputs () const
 Produce an object to hold values to send to effect output meters. More...
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
virtual EffectType GetType () const =0
 Type determines how it behaves. More...
 
virtual EffectType GetClassification () const
 Determines which menu it appears in; default same as GetType(). More...
 
virtual EffectFamilySymbol GetFamily () const =0
 Report identifier and user-visible name of the effect protocol. More...
 
virtual bool IsInteractive () const =0
 Whether the effect needs a dialog for entry of settings. More...
 
virtual bool IsDefault () const =0
 Whether the effect sorts "above the line" in the menus. More...
 
virtual RealtimeSince RealtimeSupport () const =0
 Since which version of Audacity has the effect supported realtime? More...
 
bool SupportsRealtime () const
 
virtual bool SupportsAutomation () const =0
 Whether the effect has any automatable controls. More...
 
virtual bool EnablesDebug () const
 Whether the effect dialog should have a Debug button; default, always false. More...
 
virtual ManualPageID ManualPage () const
 Name of a page in the Audacity alpha manual, default is empty. More...
 
virtual FilePath HelpPage () const
 Fully qualified local help file name, default is empty. More...
 
virtual bool IsHiddenFromMenus () const
 Default is false. More...
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
virtual PluginPath GetPath () const =0
 
virtual ComponentInterfaceSymbol GetSymbol () const =0
 
virtual VendorSymbol GetVendor () const =0
 
virtual wxString GetVersion () const =0
 
virtual TranslatableString GetDescription () const =0
 
TranslatableString GetName () const
 

Static Public Member Functions

static PaulstretchBaseFetchParameters (PaulstretchBase &e, EffectSettings &)
 
- Static Public Member Functions inherited from Effect
static EffectFetchParameters (Effect &e, EffectSettings &)
 
- Static Public Member Functions inherited from EffectBase
static std::optional< InstancePointerFindInstance (EffectPlugin &plugin)
 
static InstanceFinder DefaultInstanceFinder (EffectPlugin &plugin)
 
- Static Public Member Functions inherited from EffectDefinitionInterface
static Identifier GetSquashedName (const Identifier &ident)
 A utility that strips spaces and CamelCases a name. More...
 

Static Public Attributes

static const ComponentInterfaceSymbol Symbol { XO("Paulstretch") }
 
- Static Public Attributes inherited from EffectPlugin
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>")
 

Protected Member Functions

size_t GetBufferSize (double rate) const
 
bool ProcessOne (const WaveChannel &track, WaveChannel &outputTrack, double t0, double t1, int count)
 
const EffectParameterMethodsParameters () const override
 
- Protected Member Functions inherited from Effect
bool CheckWhetherSkipEffect (const EffectSettings &settings) const override
 Default implementation returns false. More...
 
double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const override
 Default implementation returns previewLength More...
 
bool TotalProgress (double frac, const TranslatableString &={}) const
 
bool TrackProgress (int whichTrack, double frac, const TranslatableString &={}) const
 
bool TrackGroupProgress (int whichGroup, double frac, const TranslatableString &={}) const
 
int GetNumWaveTracks () const
 
int GetNumWaveGroups () const
 
void GetBounds (const WaveTrack &track, sampleCount *start, sampleCount *len)
 
- Protected Member Functions inherited from EffectBase
virtual bool CheckWhetherSkipEffect (const EffectSettings &settings) const =0
 After Init(), tell whether Process() should be skipped. More...
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing () const
 
const TrackListinputTracks () const
 
const AudacityProjectFindProject () const
 

Protected Attributes

float mAmount
 
float mTime_resolution
 
- Protected Attributes inherited from EffectBase
double mF0 {}
 
double mF1 {}
 
wxArrayString mPresetNames
 
unsigned mUIFlags { 0 }
 

Static Protected Attributes

static constexpr EffectParameter Amount
 
static constexpr EffectParameter Time
 

Additional Inherited Members

- Public Types inherited from StatefulEffectBase
using MessagePackage = EffectInstance::MessagePackage
 
- Public Types inherited from EffectPlugin
using EffectSettingsAccessPtr = std::shared_ptr< EffectSettingsAccess >
 
using InstancePointer = std::shared_ptr< EffectInstanceEx >
 
using InstanceFinder = std::function< std::optional< InstancePointer >(EffectSettings &settings) >
 
- Public Types inherited from EffectDefinitionInterface
enum class  RealtimeSince : unsigned { Never , After_3_1 , Always }
 In which versions of Audacity was an effect realtime capable? More...
 
- Public Attributes inherited from EffectBase
std::shared_ptr< TrackListmTracks {}
 
int mNumTracks {}
 
BasicUI::ProgressDialogmProgress {}
 
double mProjectRate {}
 
WaveTrackFactorymFactory {}
 
double mT0 {}
 
double mT1 {}
 
bool mIsPreview { false }
 

Detailed Description

An Extreme Time Stretch and Time Smear effect.

Definition at line 17 of file PaulstretchBase.h.

Constructor & Destructor Documentation

◆ PaulstretchBase()

PaulstretchBase::PaulstretchBase ( )

Definition at line 79 of file PaulstretchBase.cpp.

80{
81 Parameters().Reset(*this);
82
84}
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: EffectBase.cpp:210
virtual void Reset(Effect &effect) const =0
const EffectParameterMethods & Parameters() const override

References Parameters(), EffectParameterMethods::Reset(), and EffectBase::SetLinearEffectFlag().

Here is the call graph for this function:

◆ ~PaulstretchBase()

PaulstretchBase::~PaulstretchBase ( )
virtual

Definition at line 86 of file PaulstretchBase.cpp.

87{
88}

Member Function Documentation

◆ CalcPreviewInputLength()

double PaulstretchBase::CalcPreviewInputLength ( const EffectSettings settings,
double  previewLength 
) const
overridevirtual

Implements EffectBase.

Definition at line 117 of file PaulstretchBase.cpp.

119{
120 // FIXME: Preview is currently at the project rate, but should really be
121 // at the track rate (bugs 1284 and 852).
122 auto minDuration = GetBufferSize(mProjectRate) * 2 + 1;
123
124 // Preview playback may need to be trimmed but this is the smallest selection
125 // that we can use.
126 double minLength =
127 std::max<double>(minDuration / mProjectRate, previewLength / mAmount);
128
129 return minLength;
130}
double mProjectRate
Definition: EffectBase.h:119
size_t GetBufferSize(double rate) const

References GetBufferSize(), mAmount, and EffectBase::mProjectRate.

Here is the call graph for this function:

◆ FetchParameters()

static PaulstretchBase * PaulstretchBase::FetchParameters ( PaulstretchBase e,
EffectSettings  
)
inlinestatic

Definition at line 21 of file PaulstretchBase.h.

22 {
23 return &e;
24 }

◆ GetBufferSize()

size_t PaulstretchBase::GetBufferSize ( double  rate) const
protected

Definition at line 353 of file PaulstretchBase.cpp.

354{
355 // Audacity's fft requires a power of 2
356 float tmp = rate * mTime_resolution / 2.0;
357 tmp = log(tmp) / log(2.0);
358 tmp = pow(2.0, floor(tmp + 0.5));
359
360 auto stmp = size_t(tmp);
361 if (stmp != tmp)
362 // overflow
363 return 0;
364 if (stmp >= 2 * stmp)
365 // overflow
366 return 0;
367
368 return std::max<size_t>(stmp, 128);
369}

References mTime_resolution.

Referenced by CalcPreviewInputLength(), and ProcessOne().

Here is the caller graph for this function:

◆ GetDescription()

TranslatableString PaulstretchBase::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 97 of file PaulstretchBase.cpp.

98{
99 return XO(
100 "Paulstretch is only for an extreme time-stretch or \"stasis\" effect");
101}
XO("Cut/Copy/Paste")

References XO().

Here is the call graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol PaulstretchBase::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 92 of file PaulstretchBase.cpp.

93{
94 return Symbol;
95}
static const ComponentInterfaceSymbol Symbol

References Symbol.

◆ GetType()

EffectType PaulstretchBase::GetType ( ) const
overridevirtual

Type determines how it behaves.

Implements EffectDefinitionInterface.

Definition at line 110 of file PaulstretchBase.cpp.

111{
112 return EffectTypeProcess;
113}
@ EffectTypeProcess

References EffectTypeProcess.

Referenced by Process().

Here is the caller graph for this function:

◆ ManualPage()

ManualPageID PaulstretchBase::ManualPage ( ) const
overridevirtual

Name of a page in the Audacity alpha manual, default is empty.

Reimplemented from EffectDefinitionInterface.

Definition at line 103 of file PaulstretchBase.cpp.

104{
105 return L"Paulstretch";
106}

◆ Parameters()

const EffectParameterMethods & PaulstretchBase::Parameters ( ) const
overrideprotectedvirtual

Reimplemented from Effect.

Definition at line 29 of file PaulstretchBase.cpp.

30{
32 return parameters;
33}
Generates EffectParameterMethods overrides from variadic template arguments.

Referenced by PaulstretchBase().

Here is the caller graph for this function:

◆ Process()

bool PaulstretchBase::Process ( EffectInstance instance,
EffectSettings settings 
)
overridevirtual

Implements StatefulEffectBase.

Definition at line 132 of file PaulstretchBase.cpp.

133{
134 // Pass true because sync lock adjustment is needed
135 EffectOutputTracks outputs { *mTracks, GetType(), { { mT0, mT1 } }, true };
136 auto newT1 = mT1;
137 int count = 0;
138 // Process selected wave tracks first, to find the new t1 value
139 for (const auto track : outputs.Get().Selected<WaveTrack>())
140 {
141 double trackStart = track->GetStartTime();
142 double trackEnd = track->GetEndTime();
143 double t0 = mT0 < trackStart ? trackStart : mT0;
144 double t1 = mT1 > trackEnd ? trackEnd : mT1;
145 if (t1 > t0)
146 {
147 auto tempTrack = track->EmptyCopy();
148 const auto channels = track->Channels();
149 auto iter = tempTrack->Channels().begin();
150 for (const auto pChannel : channels)
151 {
152 if (!ProcessOne(*pChannel, **iter++, t0, t1, count++))
153 return false;
154 }
155 tempTrack->Flush();
156 newT1 = std::max(newT1, mT0 + tempTrack->GetEndTime());
157 PasteTimeWarper warper { t1, t0 + tempTrack->GetEndTime() };
158 constexpr auto preserve = false;
159 constexpr auto merge = true;
160 track->ClearAndPaste(t0, t1, *tempTrack, preserve, merge, &warper);
161 }
162 else
163 count += track->NChannels();
164 }
165
166 // Sync lock adjustment of other tracks
167 outputs.Get().Any().Visit(
168 [&](auto&& fallthrough) {
169 return [&](WaveTrack& track) {
170 if (!track.IsSelected())
171 fallthrough();
172 };
173 },
174 [&](Track& track) {
176 track.SyncLockAdjust(mT1, newT1);
177 });
178 mT1 = newT1;
179
180 outputs.Commit();
181
182 return true;
183}
double mT1
Definition: EffectBase.h:123
std::shared_ptr< TrackList > mTracks
Definition: EffectBase.h:116
double mT0
Definition: EffectBase.h:122
Use this object to copy the input tracks to tentative outputTracks.
Unit slope but with either a jump (pasting more) or a flat interval (pasting less)
Definition: TimeWarper.h:181
bool ProcessOne(const WaveChannel &track, WaveChannel &outputTrack, double t0, double t1, int count)
EffectType GetType() const override
Type determines how it behaves.
static bool IsSyncLockSelected(const Track &track)
Definition: SyncLock.cpp:80
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
A Track that contains audio waveform data.
Definition: WaveTrack.h:203

References GetType(), SyncLock::IsSyncLockSelected(), EffectBase::mT0, EffectBase::mT1, EffectBase::mTracks, and ProcessOne().

Here is the call graph for this function:

◆ ProcessOne()

bool PaulstretchBase::ProcessOne ( const WaveChannel track,
WaveChannel outputTrack,
double  t0,
double  t1,
int  count 
)
protected

Definition at line 185 of file PaulstretchBase.cpp.

188{
189 const auto badAllocMessage = XO("Requested value exceeds memory capacity.");
190
191 const auto rate = track.GetTrack().GetRate();
192 const auto stretch_buf_size = GetBufferSize(rate);
193 if (stretch_buf_size == 0)
194 {
195 BasicUI::ShowMessageBox(badAllocMessage);
196 return {};
197 }
198
199 double amount = this->mAmount;
200
201 auto start = track.TimeToLongSamples(t0);
202 auto end = track.TimeToLongSamples(t1);
203 auto len = end - start;
204
205 const auto minDuration = stretch_buf_size * 2 + 1;
206 if (minDuration < stretch_buf_size)
207 {
208 // overflow!
209 BasicUI::ShowMessageBox(badAllocMessage);
210 return {};
211 }
212
213 if (len < minDuration)
214 { // error because the selection is too short
215
216 float maxTimeRes = log(len.as_double()) / log(2.0);
217 maxTimeRes = pow(2.0, floor(maxTimeRes) + 0.5);
218 maxTimeRes = maxTimeRes / rate;
219
220 using namespace BasicUI;
221 if (this->IsPreviewing())
222 {
223 double defaultPreviewLen;
224 gPrefs->Read(
225 wxT("/AudioIO/EffectsPreviewLen"), &defaultPreviewLen, 6.0);
226
227 if ((minDuration / mProjectRate) < defaultPreviewLen)
228 {
230 /* i18n-hint: 'Time Resolution' is the name of a control in the
231 Paulstretch effect.*/
232 XO("Audio selection too short to preview.\n\n"
233 "Try increasing the audio selection to at least %.1f seconds,\n"
234 "or reducing the 'Time Resolution' to less than %.1f seconds.")
235 .Format(
236 (minDuration / rate) + 0.05, // round up to 1/10 s.
237 floor(maxTimeRes * 10.0) / 10.0),
238 MessageBoxOptions {}.IconStyle(Icon::Warning));
239 }
240 else
241 {
243 /* i18n-hint: 'Time Resolution' is the name of a control in the
244 Paulstretch effect.*/
245 XO("Unable to Preview.\n\n"
246 "For the current audio selection, the maximum\n"
247 "'Time Resolution' is %.1f seconds.")
248 .Format(floor(maxTimeRes * 10.0) / 10.0),
249 MessageBoxOptions {}.IconStyle(Icon::Warning));
250 }
251 }
252 else
253 {
255 /* i18n-hint: 'Time Resolution' is the name of a control in the
256 Paulstretch effect.*/
257 XO("The 'Time Resolution' is too long for the selection.\n\n"
258 "Try increasing the audio selection to at least %.1f seconds,\n"
259 "or reducing the 'Time Resolution' to less than %.1f seconds.")
260 .Format(
261 (minDuration / rate) + 0.05, // round up to 1/10 s.
262 floor(maxTimeRes * 10.0) / 10.0),
263 MessageBoxOptions {}.IconStyle(Icon::Warning));
264 }
265
266 return {};
267 }
268
269 auto dlen = len.as_double();
270 double adjust_amount = dlen / (dlen - ((double)stretch_buf_size * 2.0));
271 amount = 1.0 + (amount - 1.0) * adjust_amount;
272
273 try
274 {
275 // This encloses all the allocations of buffers, including those in
276 // the constructor of the PaulStretch object
277
278 PaulStretch stretch(amount, stretch_buf_size, rate);
279
280 auto nget = stretch.get_nsamples_for_fill();
281
282 auto bufsize = stretch.poolsize;
283 Floats buffer0 { bufsize };
284 float* bufferptr0 = buffer0.get();
285 bool first_time = true;
286
287 const auto fade_len = std::min<size_t>(100, bufsize / 2 - 1);
288 bool cancelled = false;
289
290 {
291 Floats fade_track_smps { fade_len };
292 decltype(len) s = 0;
293
294 while (s < len)
295 {
296 track.GetFloats(bufferptr0, start + s, nget);
297 stretch.process(buffer0.get(), nget);
298
299 if (first_time)
300 {
301 stretch.process(buffer0.get(), 0);
302 };
303
304 s += nget;
305
306 if (first_time)
307 { // blend the start of the selection
308 track.GetFloats(fade_track_smps.get(), start, fade_len);
309 first_time = false;
310 for (size_t i = 0; i < fade_len; i++)
311 {
312 float fi = (float)i / (float)fade_len;
313 stretch.out_buf[i] =
314 stretch.out_buf[i] * fi + (1.0 - fi) * fade_track_smps[i];
315 }
316 }
317 if (s >= len)
318 { // blend the end of the selection
319 track.GetFloats(fade_track_smps.get(), end - fade_len, fade_len);
320 for (size_t i = 0; i < fade_len; i++)
321 {
322 float fi = (float)i / (float)fade_len;
323 auto i2 = bufsize / 2 - 1 - i;
324 stretch.out_buf[i2] =
325 stretch.out_buf[i2] * fi +
326 (1.0 - fi) * fade_track_smps[fade_len - 1 - i];
327 }
328 }
329
330 outputTrack.Append(
331 (samplePtr)stretch.out_buf.get(), floatSample,
332 stretch.out_bufsize);
333
334 nget = stretch.get_nsamples();
335 if (TrackProgress(count, s.as_double() / len.as_double()))
336 {
337 cancelled = true;
338 break;
339 }
340 }
341 }
342
343 if (!cancelled)
344 return true;
345 }
346 catch (const std::bad_alloc&)
347 {
348 BasicUI::ShowMessageBox(badAllocMessage);
349 }
350 return false;
351};
wxT("CloseDown"))
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
char * samplePtr
Definition: SampleFormat.h:57
bool IsPreviewing() const
Definition: EffectBase.h:100
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={}) const
Definition: Effect.cpp:343
Abstract base class used in importing a file.
Class that helps EffectPaulStretch. It does the FFTs and inner loop of the effect.
WaveTrack & GetTrack()
Definition: WaveTrack.h:841
bool Append(constSamplePtr buffer, sampleFormat format, size_t len)
Definition: WaveTrack.cpp:2237
bool GetFloats(float *buffer, sampleCount start, size_t len, fillFormat fill=FillFormat::fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
"narrow" overload fetches from the unique channel
Definition: WaveTrack.h:129
double GetRate() const override
Definition: WaveTrack.cpp:821
sampleCount TimeToLongSamples(double t0) const
virtual bool Read(const wxString &key, bool *value) const =0
MessageBoxResult ShowMessageBox(const TranslatableString &message, MessageBoxOptions options={})
Show a modal message box with either Ok or Yes and No, and optionally Cancel.
Definition: BasicUI.h:287
const char * end(const char *str) noexcept
Definition: StringUtils.h:106
MessageBoxOptions && IconStyle(Icon style) &&
Definition: BasicUI.h:104

References WaveChannel::Append(), details::end(), floatSample, PaulStretch::get_nsamples(), PaulStretch::get_nsamples_for_fill(), GetBufferSize(), WaveChannel::GetFloats(), WaveTrack::GetRate(), WaveChannel::GetTrack(), gPrefs, BasicUI::MessageBoxOptions::IconStyle(), EffectBase::IsPreviewing(), mAmount, EffectBase::mProjectRate, PaulStretch::out_buf, PaulStretch::out_bufsize, PaulStretch::poolsize, PaulStretch::process(), audacity::BasicSettings::Read(), BasicUI::ShowMessageBox(), WideSampleSequence::TimeToLongSamples(), Effect::TrackProgress(), wxT(), and XO().

Referenced by Process().

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

Member Data Documentation

◆ Amount

constexpr EffectParameter PaulstretchBase::Amount
staticconstexprprotected
Initial value:
{
&PaulstretchBase::mAmount, L"Stretch Factor", 10.0f, 1.0, FLT_MAX, 1
}

Definition at line 60 of file PaulstretchBase.h.

◆ mAmount

float PaulstretchBase::mAmount
protected

Definition at line 55 of file PaulstretchBase.h.

Referenced by CalcPreviewInputLength(), and ProcessOne().

◆ mTime_resolution

float PaulstretchBase::mTime_resolution
protected

Definition at line 56 of file PaulstretchBase.h.

Referenced by GetBufferSize().

◆ Symbol

const ComponentInterfaceSymbol PaulstretchBase::Symbol { XO("Paulstretch") }
static

Definition at line 25 of file PaulstretchBase.h.

Referenced by GetSymbol().

◆ Time

constexpr EffectParameter PaulstretchBase::Time
staticconstexprprotected
Initial value:
L"Time Resolution",
0.25f,
0.00099f,
FLT_MAX,
1 }

Definition at line 63 of file PaulstretchBase.h.


The documentation for this class was generated from the following files: