Audacity  3.0.3
Fade.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  Fade.cpp
6 
7  Robert Leidle
8 
9 *******************************************************************//*******************************************************************/
15 
16 
17 #include "Fade.h"
18 
19 #include <wx/intl.h>
20 
21 #include "LoadEffects.h"
22 
24 { XO("Fade In") };
25 
27 
29 { XO("Fade Out") };
30 
32 
34 {
35  mFadeIn = fadeIn;
36 }
37 
39 {
40 }
41 
42 // ComponentInterface implementation
43 
45 {
46  return mFadeIn
49 }
50 
52 {
53  return mFadeIn
54  ? XO("Applies a linear fade-in to the selected audio")
55  : XO("Applies a linear fade-out to the selected audio");
56 }
57 
58 // EffectDefinitionInterface implementation
59 
61 {
62  return EffectTypeProcess;
63 }
64 
66 {
67  return false;
68 }
69 
70 // EffectClientInterface implementation
71 
73 {
74  return 1;
75 }
76 
78 {
79  return 1;
80 }
81 
82 bool EffectFade::ProcessInitialize(sampleCount WXUNUSED(totalLen), ChannelNames WXUNUSED(chanMap))
83 {
84  mSample = 0;
85 
86  return true;
87 }
88 
89 size_t EffectFade::ProcessBlock(float **inBlock, float **outBlock, size_t blockLen)
90 {
91  float *ibuf = inBlock[0];
92  float *obuf = outBlock[0];
93 
94  if (mFadeIn)
95  {
96  for (decltype(blockLen) i = 0; i < blockLen; i++)
97  {
98  obuf[i] =
99  (ibuf[i] * ( mSample++ ).as_float()) /
101  }
102  }
103  else
104  {
105  for (decltype(blockLen) i = 0; i < blockLen; i++)
106  {
107  obuf[i] = (ibuf[i] *
108  ( mSampleCnt - 1 - mSample++ ).as_float()) /
110  }
111  }
112 
113  return blockLen;
114 }
Effect::mSampleCnt
sampleCount mSampleCnt
Definition: Effect.h:482
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
EffectFade::ProcessInitialize
bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap=NULL) override
Definition: Fade.cpp:82
EffectFadeIn::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: Fade.h:49
EffectFade::mSample
sampleCount mSample
Definition: Fade.h:43
EffectTypeProcess
@ EffectTypeProcess
Definition: EffectInterface.h:59
EffectFade::GetAudioOutCount
unsigned GetAudioOutCount() override
Definition: Fade.cpp:77
EffectFade::GetSymbol
ComponentInterfaceSymbol GetSymbol() override
Definition: Fade.cpp:44
anonymous_namespace{Fade.cpp}::reg2
BuiltinEffectsModule::Registration< EffectFadeOut > reg2
Definition: Fade.cpp:31
XO
#define XO(s)
Definition: Internat.h:31
EffectFadeOut::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: Fade.h:58
anonymous_namespace{Fade.cpp}::reg
BuiltinEffectsModule::Registration< EffectFadeIn > reg
Definition: Fade.cpp:26
sampleCount::as_float
float as_float() const
Definition: SampleCount.h:44
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterfaceSymbol.h:27
EffectFade::IsInteractive
bool IsInteractive() override
Definition: Fade.cpp:65
EffectFade::GetType
EffectType GetType() override
Definition: Fade.cpp:60
ChannelNames
enum ChannelName * ChannelNames
EffectFade::~EffectFade
virtual ~EffectFade()
Definition: Fade.cpp:38
LoadEffects.h
EffectFade::ProcessBlock
size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override
Definition: Fade.cpp:89
EffectFade::EffectFade
EffectFade(bool fadeIn=false)
Definition: Fade.cpp:33
BuiltinEffectsModule::Registration
Definition: LoadEffects.h:40
EffectFade::GetDescription
TranslatableString GetDescription() override
Definition: Fade.cpp:51
sampleCount
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:18
EffectType
EffectType
Definition: EffectInterface.h:55
EffectFade::mFadeIn
bool mFadeIn
Definition: Fade.h:42
EffectFade::GetAudioInCount
unsigned GetAudioInCount() override
Definition: Fade.cpp:72
Fade.h