Audacity 3.2.0
Compressor.cpp
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 Compressor.cpp
7
8 Matthieu Hodgkinson
9
10**********************************************************************/
11
12#include "Compressor.h"
13#include "CompressorEditor.h"
14#include "CompressorInstance.h"
18#include "LoadEffects.h"
19#include "ShuttleAutomation.h"
20
22
23namespace
24{
26} // namespace
27
29{
30 static CapturedParameters<
37 parameters;
38 return parameters;
39}
40
41std::shared_ptr<EffectInstance> EffectCompressor::MakeInstance() const
42{
43 return std::make_shared<CompressorInstance>(*this);
44}
45
46std::unique_ptr<EffectOutputs> EffectCompressor::MakeOutputs() const
47{
48 return std::make_unique<DynamicRangeProcessorDummyOutputs>();
49}
50
52 const EffectSettings& settings) const
53{
54 const auto& compressorSettings = GetSettings(settings);
55 return compressorSettings.compressionRatio == 1 &&
56 compressorSettings.makeupGainDb == 0 &&
57 // Also look-ahead, as this adds delay when used on a real-time input
58 // (mic).
59 compressorSettings.lookaheadMs == 0;
60}
61
63{
65}
66
68{
69 return Symbol;
70}
71
73{
74 return XO(
75 "Reduces \"dynamic range\", or differences between loud and quiet parts.");
76}
77
79{
80 // TODO: add manual page
81 return L"";
82}
83
85{
86 return EffectTypeProcess;
87}
88
90{
92}
93
95{
97 RegistryPaths paths(presets.size());
98 std::transform(
99 presets.begin(), presets.end(), paths.begin(), [](const auto& preset) {
100 return RegistryPath { preset.name.Translation() };
101 });
102 return paths;
103}
104
107{
109 if (id < 0 || id >= presets.size())
110 return {};
111 EffectCompressor::GetSettings(settings) = presets[id].preset;
112 return { nullptr };
113}
114
115std::unique_ptr<EffectEditor> EffectCompressor::MakeEditor(
116 ShuttleGui& S, EffectInstance& instance, EffectSettingsAccess& access,
117 const EffectOutputs* pOutputs) const
118{
120 S, instance, access, *this, pOutputs, GetSettings(access.Get()));
121}
EffectType
@ EffectTypeProcess
std::optional< std::unique_ptr< EffectSettingsAccess::Message > > OptionalMessage
XO("Cut/Copy/Paste")
std::vector< RegistryPath > RegistryPaths
Definition: Identifier.h:219
ReverbSettings preset
Definition: ReverbBase.cpp:25
#define S(N)
Definition: ToChars.cpp:64
static Settings & settings()
Definition: TrackInfo.cpp:51
int id
Generates EffectParameterMethods overrides from variadic template arguments.
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
static constexpr CompressorParameter releaseMs
static constexpr CompressorParameter compressionRatio
static constexpr CompressorParameter thresholdDb
static constexpr CompressorParameter lookaheadMs
static constexpr CompressorParameter showInput
static constexpr CompressorParameter showActual
static constexpr CompressorParameter showTarget
static constexpr CompressorParameter makeupGainDb
static constexpr CompressorParameter attackMs
static constexpr CompressorParameter kneeWidthDb
static constexpr CompressorParameter showOutput
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: EffectBase.cpp:210
const EffectParameterMethods & Parameters() const override
Definition: Compressor.cpp:28
std::unique_ptr< EffectEditor > MakeEditor(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) const override
Called only from PopulateUI, to add controls to effect panel.
Definition: Compressor.cpp:115
std::unique_ptr< EffectOutputs > MakeOutputs() const override
Produce an object to hold values to send to effect output meters.
Definition: Compressor.cpp:46
EffectType GetType() const override
Type determines how it behaves.
Definition: Compressor.cpp:84
OptionalMessage LoadFactoryPreset(int id, EffectSettings &settings) const override
Definition: Compressor.cpp:106
static const ComponentInterfaceSymbol Symbol
Definition: Compressor.h:22
RealtimeSince RealtimeSupport() const override
Since which version of Audacity has the effect supported realtime?
Definition: Compressor.cpp:89
RegistryPaths GetFactoryPresets() const override
Report names of factory presets.
Definition: Compressor.cpp:94
ComponentInterfaceSymbol GetSymbol() const override
Definition: Compressor.cpp:67
TranslatableString GetDescription() const override
Definition: Compressor.cpp:72
ManualPageID ManualPage() const override
Name of a page in the Audacity alpha manual, default is empty.
Definition: Compressor.cpp:78
bool CheckWhetherSkipEffect(const EffectSettings &settings) const override
After Init(), tell whether Process() should be skipped.
Definition: Compressor.cpp:51
std::shared_ptr< EffectInstance > MakeInstance() const override
Make an object maintaining short-term state of an Effect.
Definition: Compressor.cpp:41
RealtimeSince
In which versions of Audacity was an effect realtime capable?
Performs effect computation.
Hold values to send to effect output meters.
Interface for manipulations of an Effect's settings.
virtual const EffectSettings & Get()=0
static CompressorSettings & GetSettings(EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
Definition: Effect.h:166
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
Holds a msgid for the translation catalog; may also bind format arguments.
std::unique_ptr< EffectEditor > MakeCompressorEditor(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectUIServices &services, const EffectOutputs *pOutputs, CompressorSettings settings)
DYNAMIC_RANGE_PROCESSOR_API std::vector< CompressorPreset > GetCompressorPresets()
BuiltinEffectsModule::Registration< EffectCompressor > reg
Definition: Compressor.cpp:25
Externalized state of a plug-in.