Audacity 3.2.0
Noise.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Noise.cpp
6
7 Dominic Mazzoni
8
9*******************************************************************//*******************************************************************/
15#include "Noise.h"
16#include "EffectEditor.h"
17#include "LoadEffects.h"
18
19#include <wx/choice.h>
20#include <wx/textctrl.h>
21#include <wx/valgen.h>
22
23#include "Prefs.h"
24#include "ShuttleGui.h"
25#include "../widgets/valnum.h"
26#include "../widgets/NumericTextCtrl.h"
27
29
30std::unique_ptr<EffectEditor> EffectNoise::PopulateOrExchange(
32 const EffectOutputs *)
33{
34 mUIParent = S.GetParent();
35
36 wxASSERT(nTypes == WXSIZEOF(kTypeStrings));
37
38 S.StartMultiColumn(2, wxCENTER);
39 {
40 S.Validator<wxGenericValidator>(&mType)
41 .AddChoice(XXO("&Noise type:"), Msgids(kTypeStrings, nTypes));
42
43 S
44 .Validator<FloatingPointValidator<double>>(
45 6, &mAmp, NumValidatorStyle::NO_TRAILING_ZEROES, Amp.min, Amp.max )
46 .AddTextBox(XXO("&Amplitude (0-1):"), L"", 12);
47
48 S.AddPrompt(XXO("&Duration:"));
49 auto &extra = access.Get().extra;
52 S.GetParent(), wxID_ANY,
54 extra.GetDurationFormat(),
55 extra.GetDuration(),
57 .AutoPos(true));
58 S.Name(XO("Duration"))
59 .Position(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL)
60 .AddWindow(mNoiseDurationT);
61 }
62 S.EndMultiColumn();
63 return nullptr;
64}
65
67{
68 if (!mUIParent->TransferDataToWindow())
69 {
70 return false;
71 }
72
73 mNoiseDurationT->SetValue(settings.extra.GetDuration());
74 return true;
75}
76
78{
79 if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
80 {
81 return false;
82 }
83
84 settings.extra.SetDuration(mNoiseDurationT->GetValue());
85 return true;
86}
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define safenew
Definition: MemoryX.h:10
const NumericConverterType & NumericConverterType_TIME()
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
#define S(N)
Definition: ToChars.cpp:64
static Settings & settings()
Definition: TrackInfo.cpp:51
double mProjectRate
Definition: EffectBase.h:119
Performs effect computation.
bool TransferDataFromWindow(EffectSettings &settings) override
Definition: Noise.cpp:77
std::unique_ptr< EffectEditor > PopulateOrExchange(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) override
Add controls to effect panel; always succeeds.
Definition: Noise.cpp:30
NumericTextCtrl * mNoiseDurationT
Definition: Noise.h:33
wxWeakRef< wxWindow > mUIParent
Definition: Noise.h:34
bool TransferDataToWindow(const EffectSettings &settings) override
Definition: Noise.cpp:66
Hold values to send to effect output meters.
virtual const EffectSettings & Get()=0
static FormatterContext SampleRateContext(double sampleRate)
static const EnumValueSymbol kTypeStrings[nTypes]
Definition: NoiseBase.h:63
int mType
Definition: NoiseBase.h:49
static constexpr EffectParameter Amp
Definition: NoiseBase.h:68
double mAmp
Definition: NoiseBase.h:50
void SetValue(double newValue)
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
BuiltinEffectsModule::Registration< EffectNoise > reg
Definition: Noise.cpp:28
const Type min
Minimum value.
const Type max
Maximum value.
Externalized state of a plug-in.
EffectSettingsExtra extra
Options & AutoPos(bool enable)