21#include <wx/checkbox.h>
23#include <wx/spinctrl.h>
27#include "../widgets/valnum.h"
50 {
XO(
"Vocal I" ), { 70, 20, 40, 99, 100, 50, -12, 0, 70,
false } },
51 {
XO(
"Vocal II"), { 50, 0, 50, 99, 50, 100, -1, -1, 70,
false } },
52 {
XO(
"Bathroom"), { 16, 8, 80, 0, 0, 100, -6, 0, 100,
false } },
53 {
XO(
"Small Room Bright"), { 30, 10, 50, 50, 50, 100, -1, -1, 100,
false } },
54 {
XO(
"Small Room Dark"), { 30, 10, 50, 50, 100, 0, -1, -1, 100,
false } },
55 {
XO(
"Medium Room"), { 75, 10, 40, 50, 100, 70, -1, -1, 70,
false } },
56 {
XO(
"Large Room"), { 85, 10, 40, 50, 100, 80, 0, -6, 90,
false } },
57 {
XO(
"Church Hall"), { 90, 32, 60, 50, 100, 50, 0, -12, 100,
false } },
58 {
XO(
"Cathedral"), { 90, 16, 90, 50, 100, 0, 0, -20, 100,
false } },
80 std::unique_ptr<Reverb_priv_ex[]>
mP{};
113#define SpinSlider(n) \
114 wxSpinCtrl *m ## n ## T; \
115 wxSlider *m ## n ## S;
129 wxCheckBox* mWetOnlyC;
132#define SpinSliderHandlers(n) \
133 void On ## n ## Slider(wxCommandEvent & evt); \
134 void On ## n ## Text(wxCommandEvent & evt);
146#undef SpinSliderHandlers
148 void OnCheckbox(wxCommandEvent &evt);
158 rs.mPreDelay = mPreDelayS->GetValue();
159 rs.mReverberance = mReverberanceS->GetValue();
160 rs.mHfDamping = mHfDampingS->GetValue();
161 rs.mToneLow = mToneLowS->GetValue();
162 rs.mToneHigh = mToneHighS->GetValue();
163 rs.mWetGain = mWetGainS->GetValue();
164 rs.mDryGain = mDryGainS->GetValue();
165 rs.mStereoWidth = mStereoWidthS->GetValue();
166 rs.mWetOnly = mWetOnlyC->GetValue();
195 const float*
const* inBlock,
float*
const* outBlock,
size_t blockLen)
override;
213 unsigned numChannels,
float sampleRate)
override
221 slave.
mState,
nullptr, (numChannels == 2));
223 mSlaves.push_back( std::move(slave) );
234 const float*
const* inbuf,
float*
const* outbuf,
size_t numSamples)
override
244 for (
unsigned int i = 0; i < slave.mState.mNumChans; i++)
246 auto& reverbCore = slave.mState.mP[i].reverb;
247 const auto& is = incomingSettings;
252 is.mWetGain, is.mReverberance, is.mHfDamping, is.mToneLow, is.mToneHigh);
258 is.mWetGain, is.mRoomSize, is.mReverberance, is.mHfDamping,
259 is.mPreDelay, is.mStereoWidth, is.mToneLow, is.mToneHigh );
278 for (
unsigned int i = 0; i < slave.mState.mNumChans; i++)
302 const float*
const* inBlock,
float*
const* outBlock,
size_t blockLen);
315std::shared_ptr<EffectInstance>
318 return std::make_shared<Instance>(*
this);
340 return XO(
"Adds ambience or a \"hall effect\"");
367 mChannels = rs.mStereoWidth ? 2 : 1;
370 sampleRate,
mState, chanMap,
false);
380 bool isStereo =
false;
389 state.
mP = std::make_unique<Reverb_priv_ex[]>(state.
mNumChans);
391 for (
unsigned int i = 0; i < state.
mNumChans; i++)
400 rs.mStereoWidth * (isStereo ? 1 : 0),
416 const float*
const* inBlock,
float*
const* outBlock,
size_t blockLen)
418 return InstanceProcess(
settings,
mState, inBlock, outBlock, blockLen);
422 const float*
const* inBlock,
float*
const* outBlock,
size_t blockLen)
426 const float *ichans[2] = {NULL, NULL};
427 float *ochans[2] = {NULL, NULL};
429 for (
unsigned int c = 0; c < state.
mNumChans; c++)
431 ichans[c] = inBlock[c];
432 ochans[c] = outBlock[c];
435 float const dryMult = rs.mWetOnly ? 0 :
dB_to_linear(rs.mDryGain);
437 auto remaining = blockLen;
442 for (
unsigned int c = 0; c < state.
mNumChans; c++)
446 state.
mP[c].dry = (
float *)
fifo_write(&state.
mP[c].reverb.input_fifo, len, ichans[c]);
452 for (
decltype(len) i = 0; i < len; i++)
454 for (
int w = 0; w < 2; w++)
456 ochans[w][i] = dryMult *
459 (state.
mP[0].wet[w][i] + state.
mP[1].wet[w][i]);
465 for (
decltype(len) i = 0; i < len; i++)
467 ochans[0][i] = dryMult *
469 state.
mP[0].wet[0][i];
475 for (
unsigned int c = 0; c < state.
mNumChans; c++)
519 auto result = std::make_unique<Editor>(*
this, access, myEffSettings);
520 result->PopulateOrExchange(
S);
529 S.StartMultiColumn(3, wxEXPAND);
533#define SpinSlider(n, p) \
534 m ## n ## T = S.AddSpinCtrl( p, n.def, n.max, n.min); \
535 BindTo(*m ## n ## T, wxEVT_SPINCTRL, &Editor::On ## n ## Text);\
537 m ## n ## S = S.Style(wxSL_HORIZONTAL).AddSlider( {}, n.def, n.max, n.min); \
538 BindTo(*m ## n ## S, wxEVT_SLIDER, &Editor::On ## n ## Slider);
555 S.StartHorizontalLay(wxCENTER,
false);
559 BindTo(*mWetOnlyC, wxEVT_CHECKBOX, &Editor::OnCheckbox);
561 S.EndHorizontalLay();
570 auto& rs = mSettings;
572#define SetSpinSlider(n) \
573 m ## n ## S->SetValue((int) rs.m ## n); \
574 m ## n ## T->SetValue(wxString::Format(wxT("%d"), (int) rs.m ## n));
588 mWetOnlyC->SetValue((
int) rs.mWetOnly);
594#define SpinSliderHandlers(n) \
595 void EffectReverb::Editor::On ## n ## Slider(wxCommandEvent & evt) \
597 if (mProcessingEvent) return; \
598 mProcessingEvent = true; \
599 m ## n ## T->SetValue(wxString::Format(wxT("%d"), evt.GetInt())); \
600 mProcessingEvent = false; \
602 Publish(EffectSettingChanged{}); \
604 void EffectReverb::Editor::On ## n ## Text(wxCommandEvent & evt) \
606 if (mProcessingEvent) return; \
607 mProcessingEvent = true; \
608 m ## n ## S->SetValue(std::clamp<long>(evt.GetInt(), n.min, n.max)); \
609 mProcessingEvent = false; \
611 Publish(EffectSettingChanged{}); \
624void EffectReverb::Editor::OnCheckbox(wxCommandEvent &evt)
630#undef SpinSliderHandlers
654 const bool oneSimpleParameterChanged =
663 const bool allNonSimpleParametersStayedTheSame =
669 return oneSimpleParameterChanged && allNonSimpleParametersStayedTheSame;
std::optional< std::unique_ptr< EffectSettingsAccess::Message > > OptionalMessage
XXO("&Cut/Copy/Paste Toolbar")
std::vector< RegistryPath > RegistryPaths
#define SpinSliderHandlers(n)
EffectReverbSettings preset
static const struct @32 FactoryPresets[]
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()
bool ValidateUI(const EffectPlugin &context, EffectSettings &) const override
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?
EffectSettingsAccess & mAccess
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
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.
static constexpr EffectParameter RoomSize
ComponentInterfaceSymbol GetSymbol() const override
static constexpr EffectParameter StereoWidth
static const ComponentInterfaceSymbol Symbol
static constexpr EffectParameter Reverberance
static constexpr EffectParameter WetGain
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
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.
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.
EffectReverbSettings mSettings
bool ValidateUI() override
Get settings data from the panel; may make error dialogs and return false.
Editor(const EffectUIServices &services, EffectSettingsAccess &access, const EffectReverbSettings &settings)
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)
virtual ~Editor()=default
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
std::unique_ptr< Reverb_priv_ex[]> mP
Message sent by EffectEditor when a setting is changed by the user.
Externalized state of a plug-in.