22#include <wx/checkbox.h>
25#include <wx/spinctrl.h>
28#include "../ShuttleGui.h"
29#include "../widgets/valnum.h"
52 {
XO(
"Vocal I" ), { 70, 20, 40, 99, 100, 50, -12, 0, 70,
false } },
53 {
XO(
"Vocal II"), { 50, 0, 50, 99, 50, 100, -1, -1, 70,
false } },
54 {
XO(
"Bathroom"), { 16, 8, 80, 0, 0, 100, -6, 0, 100,
false } },
55 {
XO(
"Small Room Bright"), { 30, 10, 50, 50, 50, 100, -1, -1, 100,
false } },
56 {
XO(
"Small Room Dark"), { 30, 10, 50, 50, 100, 0, -1, -1, 100,
false } },
57 {
XO(
"Medium Room"), { 75, 10, 40, 50, 100, 70, -1, -1, 70,
false } },
58 {
XO(
"Large Room"), { 85, 10, 40, 50, 100, 80, 0, -6, 90,
false } },
59 {
XO(
"Church Hall"), { 90, 32, 60, 50, 100, 50, 0, -12, 100,
false } },
60 {
XO(
"Cathedral"), { 90, 16, 90, 50, 100, 0, 0, -20, 100,
false } },
82 std::unique_ptr<Reverb_priv_ex[]>
mP{};
117#define SpinSlider(n) \
118 wxSpinCtrl *m ## n ## T; \
119 wxSlider *m ## n ## S;
133 wxCheckBox* mWetOnlyC;
136#define SpinSliderHandlers(n) \
137 void On ## n ## Slider(wxCommandEvent & evt); \
138 void On ## n ## Text(wxCommandEvent & evt);
150#undef SpinSliderHandlers
152 void OnCheckbox(wxCommandEvent &evt);
162 rs.mPreDelay = mPreDelayS->GetValue();
163 rs.mReverberance = mReverberanceS->GetValue();
164 rs.mHfDamping = mHfDampingS->GetValue();
165 rs.mToneLow = mToneLowS->GetValue();
166 rs.mToneHigh = mToneHighS->GetValue();
167 rs.mWetGain = mWetGainS->GetValue();
168 rs.mDryGain = mDryGainS->GetValue();
169 rs.mStereoWidth = mStereoWidthS->GetValue();
170 rs.mWetOnly = mWetOnlyC->GetValue();
198 const float*
const* inBlock,
float*
const* outBlock,
size_t blockLen)
override;
212 unsigned numChannels,
float sampleRate)
override
220 slave,
nullptr, (numChannels == 2));
222 mSlaves.push_back( std::move(slave) );
233 const float*
const* inbuf,
float*
const* outbuf,
size_t numSamples)
override
244 const float*
const* inBlock,
float*
const* outBlock,
size_t blockLen);
252std::shared_ptr<EffectInstance>
255 return std::make_shared<Instance>(*
this);
277 return XO(
"Adds ambience or a \"hall effect\"");
308 sampleRate, mMaster, chanMap,
false);
318 bool isStereo =
false;
327 state.
mP = std::make_unique<Reverb_priv_ex[]>(state.
mNumChans);
329 for (
unsigned int i = 0; i < state.
mNumChans; i++)
338 rs.mStereoWidth * (isStereo ? 1 : 0),
354 const float*
const* inBlock,
float*
const* outBlock,
size_t blockLen)
356 return InstanceProcess(
settings, mMaster, inBlock, outBlock, blockLen);
360 const float*
const* inBlock,
float*
const* outBlock,
size_t blockLen)
364 const float *ichans[2] = {NULL, NULL};
365 float *ochans[2] = {NULL, NULL};
367 for (
unsigned int c = 0; c < state.
mNumChans; c++)
369 ichans[c] = inBlock[c];
370 ochans[c] = outBlock[c];
373 float const dryMult = rs.mWetOnly ? 0 :
dB_to_linear(rs.mDryGain);
375 auto remaining = blockLen;
380 for (
unsigned int c = 0; c < state.
mNumChans; c++)
384 state.
mP[c].dry = (
float *)
fifo_write(&state.
mP[c].reverb.input_fifo, len, ichans[c]);
390 for (
decltype(len) i = 0; i < len; i++)
392 for (
int w = 0; w < 2; w++)
394 ochans[w][i] = dryMult *
397 (state.
mP[0].wet[w][i] + state.
mP[1].wet[w][i]);
403 for (
decltype(len) i = 0; i < len; i++)
405 ochans[0][i] = dryMult *
407 state.
mP[0].wet[0][i];
413 for (
unsigned int c = 0; c < state.
mNumChans; c++)
455 auto result = std::make_unique<Validator>(*
this, access, myEffSettings);
456 result->PopulateOrExchange(
S);
465 S.StartMultiColumn(3, wxEXPAND);
469#define SpinSlider(n, p) \
470 m ## n ## T = S.AddSpinCtrl( p, n.def, n.max, n.min); \
471 BindTo(*m ## n ## T, wxEVT_SPINCTRL, &Validator::On ## n ## Text);\
473 m ## n ## S = S.Style(wxSL_HORIZONTAL).AddSlider( {}, n.def, n.max, n.min); \
474 BindTo(*m ## n ## S, wxEVT_SLIDER, &Validator::On ## n ## Slider);
491 S.StartHorizontalLay(wxCENTER,
false);
495 BindTo(*mWetOnlyC, wxEVT_CHECKBOX, &Validator::OnCheckbox);
497 S.EndHorizontalLay();
506 auto& rs = mSettings;
508#define SetSpinSlider(n) \
509 m ## n ## S->SetValue((int) rs.m ## n); \
510 m ## n ## T->SetValue(wxString::Format(wxT("%d"), (int) rs.m ## n));
524 mWetOnlyC->SetValue((
int) rs.mWetOnly);
530#define SpinSliderHandlers(n) \
531 void EffectReverb::Validator::On ## n ## Slider(wxCommandEvent & evt) \
533 if (mProcessingEvent) return; \
534 mProcessingEvent = true; \
535 m ## n ## T->SetValue(wxString::Format(wxT("%d"), evt.GetInt())); \
536 mProcessingEvent = false; \
539 void EffectReverb::Validator::On ## n ## Text(wxCommandEvent & evt) \
541 if (mProcessingEvent) return; \
542 mProcessingEvent = true; \
543 m ## n ## S->SetValue(std::clamp<long>(evt.GetInt(), n.min, n.max)); \
544 mProcessingEvent = false; \
558void EffectReverb::Validator::OnCheckbox(wxCommandEvent &evt)
563#undef SpinSliderHandlers
enum ChannelName * ChannelNames
std::vector< RegistryPath > RegistryPaths
static const struct @36 FactoryPresets[]
#define SpinSliderHandlers(n)
EffectReverbSettings preset
const TranslatableString name
static void reverb_process(reverb_t *p, size_t length)
static void reverb_delete(reverb_t *p)
static void reverb_create(reverb_t *p, double sample_rate_Hz, double wet_gain_dB, double room_scale, double reverberance, double hf_damping, double pre_delay_ms, double stereo_depth, double tone_low, double tone_high, size_t buffer_size, float **out)
static void * fifo_write(fifo_t *f, FIFO_SIZE_T n, void const *data)
static Settings & settings()
Generates EffectParameterMethods overrides from variadic template arguments.
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
void SetLinearEffectFlag(bool linearEffectFlag)
Base class for many of the effects in Audacity.
bool ValidateUI(EffectSettings &) override
Performs effect computation.
Inherit to add a state variable to an EffectInstance subclass.
size_t SetBlockSize(size_t maxBlockSize) override
Interface for manipulations of an Effect's settings.
const EffectParameterMethods & Parameters() const override
EffectType GetType() const override
Type determines how it behaves.
static constexpr EffectParameter ToneLow
static constexpr EffectParameter PreDelay
static constexpr EffectParameter RoomSize
ComponentInterfaceSymbol GetSymbol() const override
static constexpr EffectParameter StereoWidth
static const ComponentInterfaceSymbol Symbol
static constexpr EffectParameter Reverberance
static constexpr EffectParameter WetGain
unsigned GetAudioOutCount() const override
How many output buffers to allocate at once.
static constexpr EffectParameter HfDamping
static constexpr EffectParameter ToneHigh
static constexpr EffectParameter WetOnly
unsigned GetAudioInCount() const override
How many input buffers to allocate at once.
TranslatableString GetDescription() const override
ManualPageID ManualPage() const override
Name of a page in the Audacity alpha manual, default is empty.
std::unique_ptr< EffectUIValidator > PopulateOrExchange(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access) override
Add controls to effect panel; always succeeds.
static constexpr EffectParameter DryGain
std::shared_ptr< EffectInstance > MakeInstance() const override
Make an object maintaining short-term state of an Effect.
RegistryPaths GetFactoryPresets() const override
Report names of factory presets.
bool LoadFactoryPreset(int id, EffectSettings &settings) const override
Change settings to the preset whose name is GetFactoryPresets()[id]
void ModifySettings(Function &&function)
Do a correct read-modify-write of settings.
virtual const EffectSettings & Get()=0
EffectUIClientInterface is an abstract base class to populate a UI and validate UI values....
Interface for transferring values from a panel of effect controls.
EffectSettingsAccess & mAccess
EffectUIClientInterface & mEffect
static EffectReverbSettings & GetSettings(EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
Base class for many of the effects in Audacity.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Holds a msgid for the translation catalog; may also bind format arguments.
wxString Translation() const
Positions or offsets within audio files need a wide type.
BuiltinEffectsModule::Registration< EffectReverb > reg
const Type def
Default value.
size_t RealtimeProcess(size_t group, EffectSettings &settings, const float *const *inbuf, float *const *outbuf, size_t numSamples) override
bool InstanceInit(EffectSettings &settings, double sampleRate, EffectReverbState &data, ChannelNames chanMap, bool forceStereo)
EffectReverbState mMaster
size_t ProcessBlock(EffectSettings &settings, const float *const *inBlock, float *const *outBlock, size_t blockLen) override
Called for destructive effect computation.
size_t InstanceProcess(EffectSettings &settings, EffectReverbState &data, const float *const *inBlock, float *const *outBlock, size_t blockLen)
bool ProcessInitialize(EffectSettings &settings, double sampleRate, sampleCount totalLen, ChannelNames chanMap) override
std::vector< EffectReverbState > mSlaves
bool RealtimeAddProcessor(EffectSettings &settings, unsigned numChannels, float sampleRate) override
Instance(const PerTrackEffect &effect)
bool RealtimeInitialize(EffectSettings &settings, double) override
bool ProcessFinalize(void) override
bool RealtimeFinalize(EffectSettings &settings) noexcept override
SpinSliderHandlers(RoomSize) SpinSliderHandlers(PreDelay) SpinSliderHandlers(Reverberance) SpinSliderHandlers(HfDamping) SpinSliderHandlers(ToneLow) SpinSliderHandlers(ToneHigh) SpinSliderHandlers(WetGain) SpinSliderHandlers(DryGain) SpinSliderHandlers(StereoWidth) void OnCheckbox(wxCommandEvent &evt)
void PopulateOrExchange(ShuttleGui &S)
EffectReverbSettings mSettings
virtual ~Validator()=default
bool ValidateUI() override
Get settings data from the panel; may make error dialogs and return false.
Effect & GetEffect() const
Validator(EffectUIClientInterface &effect, EffectSettingsAccess &access, const EffectReverbSettings &settings)
SpinSlider(RoomSize) SpinSlider(PreDelay) SpinSlider(Reverberance) SpinSlider(HfDamping) SpinSlider(ToneLow) SpinSlider(ToneHigh) SpinSlider(WetGain) SpinSlider(DryGain) SpinSlider(StereoWidth) wxCheckBox *mWetOnlyC
bool UpdateUI() override
Update appearance of the panel for changes in settings.
std::unique_ptr< Reverb_priv_ex[]> mP
Externalized state of a plug-in.