15 Saturation (
const ProcessorSetup &psetup) :
22 info.
label =
"Saturation";
27 enum Params { MODE = 1, MIX, DRIVE };
31 stereoin =
add_input_bus (
"Stereo In", SpeakerArrangement::STEREO);
32 stereout =
add_output_bus (
"Stereo Out", SpeakerArrangement::STEREO);
35 pmap.
group =
"Settings";
38 centries += {
"Soft/tanh",
"Soft Saturation using the tanh function" };
39 centries += {
"Hard",
"Hard clipping" };
40 pmap[MODE] =
Param {
"mode",
"Mode",
"Mode", 0,
"", std::move (centries),
"", {
String (
"blurb=") +
_(
"Saturation Function"), } };
41 pmap[MIX] =
Param {
"mix",
"Mix dry/wet",
"Mix", 100,
"%", { 0, 100 } };
42 pmap[DRIVE] =
Param {
"drive",
"Drive",
"Drive", 0,
"dB", { -6, 36 } };
52 return SaturationDSP::Mode::HARD_CLIP;
53 return SaturationDSP::Mode::TANH_CHEAP;
56 adjust_param (uint32_t tag)
override
60 case DRIVE: saturation.set_drive (get_param (DRIVE),
false);
62 case MIX: saturation.set_mix (get_param (MIX),
false);
64 case MODE: saturation.set_mode (map_mode (get_param (MODE)));
69 reset (
uint64 target_stamp)
override
71 saturation.reset (sample_rate());
75 render_audio (
float *left_in,
float *right_in,
float *left_out,
float *right_out,
uint n_frames)
80 saturation.process<
true> (left_in, right_in, left_out, right_out, n_frames);
83 render (
uint n_frames)
override
85 float *left_in =
const_cast<float*
> (
ifloats (stereoin, 0));
86 float *right_in =
const_cast<float*
> (
ifloats (stereoin, 1));
87 float *left_out =
oblock (stereout, 0);
88 float *right_out =
oblock (stereout, 1);
92 for (
const auto &ev : evinput)
95 render_audio (left_in + offset, right_in + offset, left_out + offset, right_out + offset, ev.frame - offset);
100 case MidiMessage::PARAM_VALUE:
102 adjust_param (ev.param);
108 render_audio (left_in + offset, right_in + offset, left_out + offset, right_out + offset, n_frames - offset);
111static auto saturation = register_audio_processor<Saturation> (
"Ase::Devices::Saturation");
Audio signal AudioProcessor base class, implemented by all effects and instruments.
const float * ifloats(IBusId b, uint c) const
Access readonly float buffer of input bus b, channel c, see also ofloats().
void prepare_event_input()
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.
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.