Effects
The pulse Architect provides you with a wide range of audio processing effects that can be applied to your audio signals. As input they take a Tuple of the wave Vector and the sample rate, as output they return a Tuple of the modified wave vector and the new sample rate.
A audio effect can be directly called for example via tremolo((wave, fs); strength=0.3, rate=4.0)
or indirectly, by adding it to an AudioChain
via
chain = AudioChain(tremolo; strength=0.3, rate=4.0)
# or by pushing it into an existing chain
push!(chain, tremolo; strength=0.5, rate=2.0)
Below is a list of the available effects:
PulseArchitect.Effects.tremolo
— Functiontremolo(signal; rate=5.0, depth=0.5)
Modulates the input signal’s amplitude using a low-frequency oscillator.
signal
: Input audio array.rate
: (Optional) Modulation frequency in Hz.strength
: (Optional) Modulation strength (0 to 1), where 0 is no modulation.
Returns the modulated signal.
PulseArchitect.Effects.delay_reverb
— Functiondelay_reverb(signal; delay=0.3, feedback=0.4, mix=0.5)
Applies a delay-based reverb by mixing delayed copies with the original signal.
signal
: Input audio array.delay
: (Optional) Delay time in seconds.feedback
: (Optional) Proportion of delayed signal fed back (0 to 1).mix
: (Optional) Dry/wet mix ratio (0 to 1).
Returns the reverberated signal.
PulseArchitect.Effects.compressor
— Functioncompressor(signal; threshold=-20.0, ratio=4.0, attack=0.01, release=0.1)
Compresses the dynamic range by reducing levels above the threshold.
signal
: Input audio array.threshold
: (Optional) Level in dB above which compression occurs.ratio
: (Optional) Compression ratio (e.g., 4 means 4:1 compression).attack
: (Optional) Time in seconds to start compression.release
: (Optional) Time in seconds to cease compression.
Returns the compressed signal.
PulseArchitect.Effects.vibrato
— Functionvibrato(input::Tuple{Vector{Float64}, Int}; strength::Real=0.003, rate::Real=5.0, mod_func::Function = x -> sin(2π * rate * x))
Applies a vibrato effect by modulating the pitch of the input signal.
input
: A tuple where the first element is a vector of audio samples and the second is the sample rate.strength
: Maximum modulation deviation (as a fraction of the sample rate).rate
: Modulation frequency in Hz.mod_func
: Function mapping time to modulation factor (default is a sine wave).
Returns the modulated audio as a tuple.
PulseArchitect.Effects.chorus
— Functionchorus(input::Tuple{Vector{Float64}, Int}; depth::Real=0.003, rate::Real=1.5, mix::Real=0.5)
Creates a chorus effect by mixing the original signal with delayed, modulated copies.
input
: A tuple containing the audio samples and the sample rate.depth
: Maximum delay modulation (in seconds).rate
: Modulation frequency in Hz.mix
: Dry/wet mix ratio (0 to 1).
Returns the processed audio as a tuple.
PulseArchitect.Effects.flanger
— Functionflanger(input::Tuple{Vector{Float64}, Int}; depth::Real=0.002, rate::Real=0.25, mix::Real=0.5, feedback::Real=0.5)
Applies a flanger effect by mixing the signal with a time-delayed version of itself.
input
: A tuple with audio samples and sample rate.depth
: Maximum modulation delay in seconds.rate
: Modulation frequency in Hz.mix
: Blend ratio between dry and flanged signals.feedback
: Proportion of the delayed signal fed back into the input.
Returns the flanged audio as a tuple.
PulseArchitect.Effects.phaser
— Functionphaser(input::Tuple{Vector{Float64}, Int}; depth::Real=0.7, rate::Real=0.5, stages::Int=4)
Creates a phaser effect by applying multiple all-pass filters to shift the phase of the signal.
input
: A tuple containing the audio samples and sample rate.depth
: Intensity of the phase modulation.rate
: Modulation frequency in Hz.stages
: Number of all-pass filter stages.
Returns the phase-shifted audio as a tuple.
PulseArchitect.Effects.distortion
— Functiondistortion(signal; gain=20.0, threshold=0.8)
Applies distortion by amplifying the signal and clipping its peaks.
signal
: Input audio array.gain
: Amplification factor before clipping.threshold
: Clipping threshold (normalized between 0 and 1).
Returns the distorted signal.
PulseArchitect.Effects.bitcrusher
— Functionbitcrusher(input::Tuple{Vector{Float64}, Int}; bitdepth::Int=8, samplerate_reduction::Int=1)
Reduces audio fidelity by quantizing the input signal to a lower bit depth and by reducing its effective sample rate. Assumes that the input samples are normalized in the range [-1, 1].
input
: A tuple where the first element is a vector of audio samples and the second is the sample rate.bit_depth
: The target bit depth (e.g., 8 for 8-bit resolution), which determines the number of quantization levels (2^bit_depth).sample_rate_reduction
: The factor by which to reduce the sample rate. For instance, if set to 2, the function processes the signal in blocks of 2 samples, replacing each block with a single quantized value.
The function first computes the quantization step based on the number of levels, then processes the signal in blocks defined by sample_rate_reduction
. For each block, it quantizes a representative sample (the first sample of the block) and replicates this value over the entire block.
Returns a tuple (crushed_samples, sample_rate)
, where crushed_samples
is the processed audio signal.
PulseArchitect.Effects.pitch_shift
— Functionpitchshift(input::Tuple{Vector{Float64}, Int}, semitones; windowsize=1024, hop_size=256)
Shifts the pitch of the input audio signal by the specified number of semitones using a simplified phase vocoder. The algorithm performs the following steps:
- Computes the short-time Fourier transform (STFT) of the input using a Hann window.
- Time-stretches the signal by a factor of 1/factor (where factor = 2^(semitones/12)) by linearly interpolating between STFT frames.
- Reconstructs the time-domain signal via the inverse STFT (using overlap-add).
- Resamples the resulting signal to match the original length.
input
: A tuple(samples, fs)
wheresamples
is a vector of normalized audio samples (Float64, range [-1,1]) andfs
is the sample rate.semitones
: The number of semitones to shift the pitch (positive to raise, negative to lower).window_size
: Size of the FFT window (default 1024).hop_size
: Hop size between frames (default 256).
Returns a tuple (shifted_signal, fs)
.
PulseArchitect.Effects.lowpass
— Functionlowpass(input::Tuple{Vector{Float64}, Int}; cutoff::Real)
Applies a first‐order lowpass filter to the input signal using an exponential moving average.
input
: Tuple(samples, fs)
wheresamples
is a vector of normalized audio samples (range [-1, 1]) andfs
is the sample rate in Hz.cutoff
: Cutoff frequency in Hz. Frequencies above this are increasingly attenuated.
Returns a tuple (filtered_samples, fs)
.
PulseArchitect.Effects.highpass
— Functionhighpass(input::Tuple{Vector{Float64}, Int}; cutoff::Real)
Applies a first‐order highpass filter to the input signal using a simple recursive formula.
input
: Tuple(samples, fs)
wheresamples
is a vector of normalized audio samples (range [-1, 1]) andfs
is the sample rate in Hz.cutoff
: Cutoff frequency in Hz. Frequencies below this are increasingly attenuated.
Returns a tuple (filtered_samples, fs)
.
PulseArchitect.Effects.bandpass
— Functionbandpass(input::Tuple{Vector{Float64}, Int}; lowcutoff::Real, highcutoff::Real)
Creates a bandpass filter by cascading a highpass and a lowpass filter.
input
: Tuple(samples, fs)
wheresamples
is a vector of normalized audio samples (range [-1, 1]) andfs
is the sample rate in Hz.low_cutoff
: Lower cutoff frequency in Hz (highpass threshold).high_cutoff
: Upper cutoff frequency in Hz (lowpass threshold).
Returns a tuple (filtered_samples, fs)
where only frequencies between low_cutoff
and high_cutoff
are preserved.