Audacity 3.2.0
Fade.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Fade.cpp
6
7 Dominic Mazzoni
8
9**********************************************************************/
10
11#include "Fade.h"
12
14{
16}
17
19{
20}
21
22// EffectDefinitionInterface implementation
23
25{
26 return EffectTypeProcess;
27}
28
30{
31 return false;
32}
33
34unsigned Fade::GetAudioInCount() const
35{
36 return 1;
37}
38
39unsigned Fade::GetAudioOutCount() const
40{
41 return 1;
42}
43
45{
46 mSample = 0;
47 return true;
48}
49
51 EffectSettings&, const float* const* inBlock, float* const* outBlock,
52 size_t blockLen)
53{
54 const float* ibuf = inBlock[0];
55 float* obuf = outBlock[0];
56
57 if (mFadeIn)
58 {
59 for (decltype(blockLen) i = 0; i < blockLen; i++)
60 {
61 obuf[i] = (ibuf[i] * (mSample++).as_float()) / mSampleCnt.as_float();
62 }
63 }
64 else
65 {
66 for (decltype(blockLen) i = 0; i < blockLen; i++)
67 {
68 obuf[i] = (ibuf[i] * (mSampleCnt - 1 - mSample++).as_float()) /
70 }
71 }
72
73 return blockLen;
74}
75
76const ComponentInterfaceSymbol FadeIn::Symbol { XO("Fade In") };
77
79 : Fade { true }
80{
81}
82
84{
85 return Symbol;
86}
87
89{
90 return XO("Applies a linear fade-in to the selected audio");
91}
92
93const ComponentInterfaceSymbol FadeOut::Symbol { XO("Fade Out") };
94
96 : Fade { false }
97{
98}
99
101{
102 return Symbol;
103}
104
106{
107 return XO("Applies a linear fade-out to the selected audio");
108}
EffectType
@ EffectTypeProcess
ChannelName
XO("Cut/Copy/Paste")
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: Fade.h:15
bool ProcessInitialize(EffectSettings &settings, double sampleRate, ChannelNames chanMap) override
Definition: Fade.cpp:44
Fade(bool fadeIn=false)
Definition: Fade.cpp:13
bool IsInteractive() const override
Whether the effect needs a dialog for entry of settings.
Definition: Fade.cpp:29
bool mFadeIn
Definition: Fade.h:37
virtual ~Fade() override
Definition: Fade.cpp:18
sampleCount mSample
Definition: Fade.h:38
unsigned GetAudioInCount() const override
How many input buffers to allocate at once.
Definition: Fade.cpp:34
EffectType GetType() const override
Type determines how it behaves.
Definition: Fade.cpp:24
unsigned GetAudioOutCount() const override
How many output buffers to allocate at once.
Definition: Fade.cpp:39
size_t ProcessBlock(EffectSettings &settings, const float *const *inBlock, float *const *outBlock, size_t blockLen) override
Called for destructive effect computation.
Definition: Fade.cpp:50
TranslatableString GetDescription() const override
Definition: Fade.cpp:88
FadeIn()
Definition: Fade.cpp:78
static const ComponentInterfaceSymbol Symbol
Definition: Fade.h:44
ComponentInterfaceSymbol GetSymbol() const override
Definition: Fade.cpp:83
FadeOut()
Definition: Fade.cpp:95
ComponentInterfaceSymbol GetSymbol() const override
Definition: Fade.cpp:100
TranslatableString GetDescription() const override
Definition: Fade.cpp:105
static const ComponentInterfaceSymbol Symbol
Definition: Fade.h:56
sampleCount mSampleCnt
Holds a msgid for the translation catalog; may also bind format arguments.
float as_float() const
Definition: SampleCount.h:45
BuiltinEffectsModule::Registration< FadeIn > fadeIn
Externalized state of a plug-in.