109 drive = -drive + 1.0f;
161 virtual void process(
int num_samples)
override;
184 template<poly_
float(*distort)(poly_
float, poly_
float), poly_
float(*scale)(poly_
float)>
A Processor that applies various types of distortion to an audio signal.
Definition distortion.h:16
static force_inline poly_float downSampleScale(poly_float db)
Scales a drive (dB) value for downsampling distortion.
Definition distortion.h:104
virtual void processWithInput(const poly_float *audio_in, int num_samples) override
Processes a block of audio using a provided input buffer.
Definition distortion.cpp:210
@ kAudio
Audio input buffer.
Definition distortion.h:43
@ kType
Distortion type (see Type enum)
Definition distortion.h:44
@ kNumInputs
Definition distortion.h:46
@ kDrive
Drive amount in dB.
Definition distortion.h:45
virtual Processor * clone() const override
Creates a clone of this Processor. (Not implemented for Distortion).
Definition distortion.h:151
static poly_float getDriveValue(int type, poly_float input_drive)
Converts an input drive in dB to a linear multiplier depending on distortion type.
Definition distortion.h:121
virtual void process(int num_samples) override
Processes a block of audio using the stored input buffer.
Definition distortion.cpp:253
static force_inline poly_float driveDbScale(poly_float db)
Scales a drive (dB) value into a linear multiplier for standard distortions.
Definition distortion.h:79
virtual ~Distortion()
Default destructor.
Definition distortion.h:145
static constexpr mono_float kMinDistortionMult
Minimum distortion multiplier used for certain distortion styles (e.g., bitcrush).
Definition distortion.h:36
static constexpr float kPeriodScale
Factor used to scale downsampling period relative to sample rate.
Definition distortion.h:31
static poly_float getDrivenValue(int type, poly_float value, poly_float drive)
Applies the specified distortion to a single sample given the drive multiplier.
Definition distortion.cpp:135
void processTimeInvariant(int num_samples, const poly_float *audio_in, const poly_float *drive, poly_float *audio_out)
Processes samples with a time-invariant distortion function (no dynamic changes).
Definition distortion.cpp:177
@ kDriveOut
Drive values used in calculations (for reference or debugging)
Definition distortion.h:55
@ kAudioOut
Distorted audio output.
Definition distortion.h:54
@ kNumOutputs
Definition distortion.h:56
void processDownSample(int num_samples, const poly_float *audio_in, const poly_float *drive, poly_float *audio_out)
Processes samples using a downsampling approach for distortion.
Definition distortion.cpp:188
static constexpr mono_float kMinDrive
Minimum allowed drive in decibels.
Definition distortion.h:26
Distortion()
Constructs a Distortion object with the default number of inputs/outputs.
Definition distortion.cpp:160
static constexpr mono_float kMaxDrive
Maximum allowed drive in decibels.
Definition distortion.h:21
Type
Distortion algorithms supported by this class.
Definition distortion.h:63
@ kSinFold
Sine-based waveform folding.
Definition distortion.h:67
@ kSoftClip
Soft clipping (tanh-based waveshaping)
Definition distortion.h:64
@ kHardClip
Hard clipping.
Definition distortion.h:65
@ kNumTypes
Definition distortion.h:70
@ kLinearFold
Linear waveform folding.
Definition distortion.h:66
@ kBitCrush
Bitcrushing (quantizing samples)
Definition distortion.h:68
@ kDownSample
Downsampling.
Definition distortion.h:69
static force_inline poly_float bitCrushScale(poly_float db)
Scales a drive (dB) value for bitcrush distortion (controls quantization level).
Definition distortion.h:89
Base class for all signal-processing units in Vital.
Definition processor.h:212
#define VITAL_ASSERT(x)
Definition common.h:11
#define force_inline
Definition common.h:23
Contains faster but less accurate versions of utility math functions, such as exponential,...
force_inline mono_float dbToMagnitude(mono_float decibels)
Converts decibels (dB) to magnitude (linear).
Definition futils.h:217
force_inline poly_float clamp(poly_float value, mono_float min, mono_float max)
Clamps each lane of a vector to [min, max].
Definition poly_utils.h:306
force_inline poly_float max(poly_float left, poly_float right)
Returns the maximum of two poly_floats lane-by-lane.
Definition poly_utils.h:327
Contains classes and functions used within the Vital synthesizer framework.
float mono_float
Definition common.h:33
Declares the Processor class and related structures for handling audio processing in a polyphonic con...
Represents a vector of floating-point values using SIMD instructions.
Definition poly_values.h:600