class RemiAudio::DSP::SoftClipper

Overview

The SoftClipper class implements a type of limiter with a type of distortion that tends to be more pleasant to the ears than straight clipping. This will round off the peaks of the audio signal that pass above the maximum amplitude rather than cut them off flat.

A simplified diagram can be found here.

Defined in:

remiaudio/dsp/softclipping.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(*, oversampling : UInt16 = 1_u16, channels : Int32 = 2, mode : RemiAudio::Resampler::Type = RemiAudio::Resampler::Type::Linear) #

Creates a new SoftClipper instance that will work with the givven number of channels, and with the given amount of oversampling. The oversampling amount cannot be zero.

When oversampling is 1, then no oversampling is performed. This is the default to match the behavior of older versions of RemiAudio.


[View source]

Class Method Detail

def self.process(maxAmplitude : Float32 | Float64, sample : Float64) : Float64 #

Applies soft clipping to a single sample. No oversampling is performed.


[View source]
def self.process(maxAmplitude : Float32 | Float64, sample : Float32) : Float32 #

Applies soft clipping to a single sample. No oversampling is performed.


[View source]
def self.process(maxAmplitude : Float32 | Float64, samples : Array(Float64) | Slice(Float64)) : Nil #

Applies soft clipping to a buffer of audio. No oversampling is performed.


[View source]
def self.process(maxAmplitude : Float32 | Float64, samples : Array(Float32) | Slice(Float32)) : Nil #

Applies soft clipping to a buffer of audio. No oversampling is performed.


[View source]

Instance Method Detail


[View source]
def mode=(mode : RemiAudio::Resampler::Type) : Nil #

Sets the resampling mode. This is not thread-safe.


[View source]
def oversampling : UInt16 #

[View source]
def oversampling=(oversampling : UInt16) : UInt16 #

Sets a new oversampling amount. This cannot be zero.


[View source]
def process(maxAmplitude : Float32 | Float64, block : Array(Float64) | Slice(Float64)) : Nil #

Applies soft clipping to a block of audio.


[View source]
def process(maxAmplitude : Float32 | Float64, block : Array(Float32) | Slice(Float32)) : Nil #

Applies soft clipping to a block of audio.


[View source]