22#include <wx/checkbox.h>
24#include <wx/spinctrl.h>
27#include "../ShuttleGui.h"
28#include "../widgets/valnum.h"
51 {
XO(
"Vocal I" ), { 70, 20, 40, 99, 100, 50, -12, 0, 70,
false } },
52 {
XO(
"Vocal II"), { 50, 0, 50, 99, 50, 100, -1, -1, 70,
false } },
53 {
XO(
"Bathroom"), { 16, 8, 80, 0, 0, 100, -6, 0, 100,
false } },
54 {
XO(
"Small Room Bright"), { 30, 10, 50, 50, 50, 100, -1, -1, 100,
false } },
55 {
XO(
"Small Room Dark"), { 30, 10, 50, 50, 100, 0, -1, -1, 100,
false } },
56 {
XO(
"Medium Room"), { 75, 10, 40, 50, 100, 70, -1, -1, 70,
false } },
57 {
XO(
"Large Room"), { 85, 10, 40, 50, 100, 80, 0, -6, 90,
false } },
58 {
XO(
"Church Hall"), { 90, 32, 60, 50, 100, 50, 0, -12, 100,
false } },
59 {
XO(
"Cathedral"), { 90, 16, 90, 50, 100, 0, 0, -20, 100,
false } },
81 std::unique_ptr<Reverb_priv_ex[]>
mP{};
116#define SpinSlider(n) \
117 wxSpinCtrl *m ## n ## T; \
118 wxSlider *m ## n ## S;
132 wxCheckBox* mWetOnlyC;
135#define SpinSliderHandlers(n) \
136 void On ## n ## Slider(wxCommandEvent & evt); \
137 void On ## n ## Text(wxCommandEvent & evt);
149#undef SpinSliderHandlers
151 void OnCheckbox(wxCommandEvent &evt);
161 rs.mPreDelay = mPreDelayS->GetValue();
162 rs.mReverberance = mReverberanceS->GetValue();
163 rs.mHfDamping = mHfDampingS->GetValue();
164 rs.mToneLow = mToneLowS->GetValue();
165 rs.mToneHigh = mToneHighS->GetValue();
166 rs.mWetGain = mWetGainS->GetValue();
167 rs.mDryGain = mDryGainS->GetValue();
168 rs.mStereoWidth = mStereoWidthS->GetValue();
169 rs.mWetOnly = mWetOnlyC->GetValue();
198 const float*
const* inBlock,
float*
const* outBlock,
size_t blockLen)
override;
216 unsigned numChannels,
float sampleRate)
override
224 slave.
mState,
nullptr, (numChannels == 2));
226 mSlaves.push_back( std::move(slave) );
237 const float*
const* inbuf,
float*
const* outbuf,
size_t numSamples)
override
247 for (
unsigned int i = 0; i < slave.mState.mNumChans; i++)
249 auto& reverbCore = slave.mState.mP[i].reverb;
250 const auto& is = incomingSettings;
255 is.mWetGain, is.mReverberance, is.mHfDamping, is.mToneLow, is.mToneHigh);
261 is.mWetGain, is.mRoomSize, is.mReverberance, is.mHfDamping,
262 is.mPreDelay, is.mStereoWidth, is.mToneLow, is.mToneHigh );
281 for (
unsigned int i = 0; i < slave.mState.mNumChans; i++)
305 const float*
const* inBlock,
float*
const* outBlock,
size_t blockLen);
318std::shared_ptr<EffectInstance>
321 return std::make_shared<Instance>(*
this);
343 return XO(
"Adds ambience or a \"hall effect\"");
370 mChannels = rs.mStereoWidth ? 2 : 1;
373 sampleRate,
mState, chanMap,
false);
383 bool isStereo =
false;
392 state.
mP = std::make_unique<Reverb_priv_ex[]>(state.
mNumChans);
394 for (
unsigned int i = 0; i < state.
mNumChans; i++)
403 rs.mStereoWidth * (isStereo ? 1 : 0),
419 const float*
const* inBlock,
float*
const* outBlock,
size_t blockLen)
421 return InstanceProcess(
settings,
mState, inBlock, outBlock, blockLen);
425 const float*
const* inBlock,
float*
const* outBlock,
size_t blockLen)
429 const float *ichans[2] = {NULL, NULL};
430 float *ochans[2] = {NULL, NULL};
432 for (
unsigned int c = 0; c < state.
mNumChans; c++)
434 ichans[c] = inBlock[c];
435 ochans[c] = outBlock[c];
438 float const dryMult = rs.mWetOnly ? 0 :
dB_to_linear(rs.mDryGain);
440 auto remaining = blockLen;
445 for (
unsigned int c = 0; c < state.
mNumChans; c++)
449 state.
mP[c].dry = (
float *)
fifo_write(&state.
mP[c].reverb.input_fifo, len, ichans[c]);
455 for (
decltype(len) i = 0; i < len; i++)
457 for (
int w = 0; w < 2; w++)
459 ochans[w][i] = dryMult *
462 (state.
mP[0].wet[w][i] + state.
mP[1].wet[w][i]);
468 for (
decltype(len) i = 0; i < len; i++)
470 ochans[0][i] = dryMult *
472 state.
mP[0].wet[0][i];
478 for (
unsigned int c = 0; c < state.
mNumChans; c++)
522 auto result = std::make_unique<Validator>(*
this, access, myEffSettings);
523 result->PopulateOrExchange(
S);
532 S.StartMultiColumn(3, wxEXPAND);
536#define SpinSlider(n, p) \
537 m ## n ## T = S.AddSpinCtrl( p, n.def, n.max, n.min); \
538 BindTo(*m ## n ## T, wxEVT_SPINCTRL, &Validator::On ## n ## Text);\
540 m ## n ## S = S.Style(wxSL_HORIZONTAL).AddSlider( {}, n.def, n.max, n.min); \
541 BindTo(*m ## n ## S, wxEVT_SLIDER, &Validator::On ## n ## Slider);
558 S.StartHorizontalLay(wxCENTER,
false);
562 BindTo(*mWetOnlyC, wxEVT_CHECKBOX, &Validator::OnCheckbox);
564 S.EndHorizontalLay();
573 auto& rs = mSettings;
575#define SetSpinSlider(n) \
576 m ## n ## S->SetValue((int) rs.m ## n); \
577 m ## n ## T->SetValue(wxString::Format(wxT("%d"), (int) rs.m ## n));
591 mWetOnlyC->SetValue((
int) rs.mWetOnly);
597#define SpinSliderHandlers(n) \
598 void EffectReverb::Validator::On ## n ## Slider(wxCommandEvent & evt) \
600 if (mProcessingEvent) return; \
601 mProcessingEvent = true; \
602 m ## n ## T->SetValue(wxString::Format(wxT("%d"), evt.GetInt())); \
603 mProcessingEvent = false; \
605 Publish(EffectSettingChanged{}); \
607 void EffectReverb::Validator::On ## n ## Text(wxCommandEvent & evt) \
609 if (mProcessingEvent) return; \
610 mProcessingEvent = true; \
611 m ## n ## S->SetValue(std::clamp<long>(evt.GetInt(), n.min, n.max)); \
612 mProcessingEvent = false; \
614 Publish(EffectSettingChanged{}); \
627void EffectReverb::Validator::OnCheckbox(wxCommandEvent &evt)
633#undef SpinSliderHandlers
657 const bool oneSimpleParameterChanged =
666 const bool allNonSimpleParametersStayedTheSame =
672 return oneSimpleParameterChanged && allNonSimpleParametersStayedTheSame;
std::optional< std::unique_ptr< EffectSettingsAccess::Message > > OptionalMessage
XXO("&Cut/Copy/Paste Toolbar")
std::vector< RegistryPath > RegistryPaths
#define SpinSliderHandlers(n)
static const struct @33 FactoryPresets[]
EffectReverbSettings preset
bool operator==(const EffectReverbSettings &a, const EffectReverbSettings &b)
bool OnlySimpleParametersChanged(const EffectReverbSettings &a, const EffectReverbSettings &b)
const TranslatableString name
static void reverb_init(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)
static void reverb_set_simple_params(reverb_t *p, double sample_rate_Hz, double wet_gain_dB, double reverberance, double hf_damping, double tone_low, double tone_high)
static void reverb_process(reverb_t *p, size_t length)
static void reverb_delete(reverb_t *p)
static void reverb_clear(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)
RealtimeSince
In which versions of Audacity was an effect realtime capable?
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
Hold values to send to effect output meters.
Interface for manipulations of an Effect's settings.
const EffectParameterMethods & Parameters() const override
RealtimeSince RealtimeSupport() const override
Since which version of Audacity has the effect supported realtime?
OptionalMessage LoadFactoryPreset(int id, EffectSettings &settings) 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
std::unique_ptr< EffectUIValidator > PopulateOrExchange(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) override
Add controls to effect panel; always succeeds.
static constexpr EffectParameter HfDamping
static constexpr EffectParameter ToneHigh
static constexpr EffectParameter WetOnly
TranslatableString GetDescription() const override
ManualPageID ManualPage() const override
Name of a page in the Audacity alpha manual, default is empty.
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.
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.
const PerTrackEffect & mProcessor
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
BuiltinEffectsModule::Registration< EffectReverb > reg
const Type def
Default value.
unsigned GetAudioOutCount() const override
How many output buffers to allocate at once.
bool ProcessInitialize(EffectSettings &settings, double sampleRate, ChannelNames chanMap) override
size_t RealtimeProcess(size_t group, EffectSettings &settings, const float *const *inbuf, float *const *outbuf, size_t numSamples) override
unsigned GetAudioInCount() const override
How many input buffers to allocate at once.
EffectReverbSettings mLastAppliedSettings
bool InstanceInit(EffectSettings &settings, double sampleRate, EffectReverbState &data, ChannelNames chanMap, bool forceStereo)
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)
std::vector< EffectReverb::Instance > mSlaves
bool RealtimeSuspend() override
bool RealtimeInitialize(EffectSettings &settings, double sampleRate) override
Instance(const PerTrackEffect &effect)
bool RealtimeAddProcessor(EffectSettings &settings, EffectOutputs *, unsigned numChannels, float sampleRate) override
bool RealtimeFinalize(EffectSettings &settings) noexcept override
bool ProcessFinalize(void) 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
Message sent by validator when a setting is changed by a user.
Externalized state of a plug-in.