20 bool mix_smooth_reset_ =
false;
22 Freeverb (
const ProcessorSetup &psetup) :
29 info.
label =
"Freeverb3";
34 enum Params { MODE = 1, MIX, ROOMSIZE, DAMPING, WIDTH };
40 stereoin =
add_input_bus (
"Stereo In", SpeakerArrangement::STEREO);
41 stereout =
add_output_bus (
"Stereo Out", SpeakerArrangement::STEREO);
45 pmap.
group =
_(
"Reverb Settings");
46 pmap[MIX] =
Param {
"mix",
"Mix dry/wet",
"Mix", 30,
"%", { 0, 100 } };
49 centries += {
"Signflip 2000",
_(
"Preserve May 2000 Freeverb damping sign flip") };
50 centries += {
"VLC Damping",
_(
"The VLC Freeverb version disables one damping feedback chain") };
51 centries += {
"Normal Damping",
_(
"Damping with sign correction as implemented in STK Freeverb") };
52 pmap[MODE] =
Param (
"mode",
_(
"Mode"),
_(
"Mode"), 2,
"", std::move (centries),
"",
53 {
String (
"blurb=") +
_(
"Damping mode found in different Freeverb variants"), });
55 pmap.
group =
_(
"Room Settings");
56 pmap[ROOMSIZE] =
Param (
"roomsize",
_(
"Room size"),
_(
"RS"), offsetroom + scaleroom * initialroom,
_(
"size"), { offsetroom, offsetroom + scaleroom });
57 pmap[WIDTH] =
Param (
"width",
_(
"Width"),
_(
"W"), 100 * initialwidth,
"%", { 0, 100 });
58 pmap[DAMPING] =
Param (
"damping",
_(
"Damping"),
_(
"D"), 100 * initialdamp,
"%", { 0, 100 });
63 adjust_param (uint32_t paramid)
override
65 switch (Params (paramid))
67 case MIX: mix_smooth_.set (get_param (paramid) * 0.01, mix_smooth_reset_);
68 mix_smooth_reset_ =
false;
70 case ROOMSIZE:
return model.setroomsize ((get_param (paramid) - offsetroom) / scaleroom);
71 case WIDTH:
return model.setwidth (0.01 * get_param (paramid));
73 case DAMPING:
return model.setdamp (0.01 * get_param (
ParamId (DAMPING)),
78 reset (
uint64 target_stamp)
override
84 mix_smooth_.reset (sample_rate(), 0.020);
85 mix_smooth_reset_ =
true;
89 render_audio (
float *input0,
float *input1,
float *output0,
float *output1,
uint n_frames)
95 model.processreplace (input0, input1, output0, output1, n_frames, 1);
97 if (mix_smooth_.is_constant())
99 float mix = mix_smooth_.get_next();
100 for (
uint i = 0; i < n_frames; i++)
102 output0[i] = input0[i] * (1 - mix) + output0[i] * mix;
103 output1[i] = input1[i] * (1 - mix) + output1[i] * mix;
108 for (
uint i = 0; i < n_frames; i++)
110 float mix = mix_smooth_.get_next();
111 output0[i] = input0[i] * (1 - mix) + output0[i] * mix;
112 output1[i] = input1[i] * (1 - mix) + output1[i] * mix;
117 render (
uint n_frames)
override
119 float *input0 =
const_cast<float*
> (
ifloats (stereoin, 0));
120 float *input1 =
const_cast<float*
> (
ifloats (stereoin, 1));
121 float *output0 =
oblock (stereout, 0);
122 float *output1 =
oblock (stereout, 1);
126 for (
const auto &ev : evinput)
129 render_audio (input0 + offset, input1 + offset, output0 + offset, output1 + offset, ev.frame - offset);
132 switch (ev.message())
134 case MidiMessage::PARAM_VALUE:
136 adjust_param (ev.param);
142 render_audio (input0 + offset, input1 + offset, output0 + offset, output1 + offset, n_frames - offset);
145static auto freeverb = register_audio_processor<Freeverb> (
"Ase::Devices::Freeverb");
Audio signal AudioProcessor base class, implemented by all effects and instruments.
void remove_all_buses()
Remove existing bus configurations, useful at the start of configure().
const float * ifloats(IBusId b, uint c) const
Access readonly float buffer of input bus b, channel c, see also ofloats().
MidiEventInput midi_event_input()
Access the current MidiEvent inputs during render(), needs prepare_event_input().
OBusId add_output_bus(CString uilabel, SpeakerArrangement speakerarrangement, const String &hints="", const String &blurb="")
Add an output bus with uilabel and channels configured via speakerarrangement.
virtual void initialize(SpeakerArrangement busses)=0
void apply_event(const MidiEvent &event)
Assign MidiEvent::PARAM_VALUE event values to parameters.
IBusId add_input_bus(CString uilabel, SpeakerArrangement speakerarrangement, const String &hints="", const String &blurb="")
Add an input bus with uilabel and channels configured via speakerarrangement.
void install_params(const AudioParams::Map ¶ms)
Reset list of parameters, enqueues parameter value initializaiton events.
float * oblock(OBusId b, uint c)
#define _(...)
Retrieve the translation of a C or C++ string.
The Anklang C++ API namespace.
CString website_url
Website of/about this AudioProcessor.
uint64_t uint64
A 64-bit unsigned integer, use PRI*64 in format strings.
IBusId
ID type for AudioProcessor input buses, buses are numbered with increasing index.
OBusId
ID type for AudioProcessor output buses, buses are numbered with increasing index.
CString version
Version identifier.
ParamId
ID type for AudioProcessor parameters, the ID numbers are user assignable.
CString creator_name
Name of the creator.
CString label
Preferred user interface name.
std::string String
Convenience alias for std::string.
uint32_t uint
Provide 'uint' as convenience type.
CString category
Category to allow grouping for processors of similar function.
Detailed information and common properties of AudioProcessor subclasses.
Structured initializer for Parameter.
Parameter list construction helper.
String group
Group to be applied to all newly inserted Parameter objects.