# Compressor

amp: | 1 | mix: | 1 | pre_amp: | 1 | threshold: | 0.2
clamp_time: | 0.01 | slope_above: | 0.5 | slope_below: | 1 | relax_time: | 0.01

``

    with_fx :compressor do
      play 50
    end

Compresses the dynamic range of the incoming signal. Equivalent to automatically turning the amp down when the signal gets too loud and then back up again when it’s quiet. Useful for ensuring the containing signal doesn’t overwhelm other aspects of the sound. Also a general purpose hard-knee dynamic range processor which can be tuned via the opts to both expand and compress the signal.

Introduced in v2.0

## Options

amp: | The amplitude of the sound. Typically a value between 0 and 1. Higher amplitudes may be used, but won’t make the sound louder, they will just reduce the quality of all the sounds currently being played (due to compression.) Default: 1 Must be zero or greater May be changed whilst playing Has slide options to shape changes
mix: | The amount (percentage) of FX present in the resulting sound represented as a value between 0 and 1. For example, a mix of 0 means that only the original sound is heard, a mix of 1 means that only the FX is heard (typically the default) and a mix of 0.5 means that half the original and half of the FX is heard. Default: 1 Must be a value between 0 and 1 inclusively May be changed whilst playing
pre_amp: | Amplification applied to the input signal immediately before it is passed to the FX. Default: 1 Must be zero or greater May be changed whilst playing Has slide options to shape changes
threshold: | Threshold value determining the break point between slope_below and slope_above. Default: 0.2 Must be zero or greater May be changed whilst playing Has slide options to shape changes
clamp_time: | Time taken for the amplitude adjustments to kick in fully (in seconds). This is usually pretty small (not much more than 10 milliseconds). Also known as the time of the attack phase Default: 0.01 Must be zero or greater May be changed whilst playing Has slide options to shape changes
slope_above: | Slope of the amplitude curve above the threshold. A value of 1 means that the output of signals with amplitude above the threshold will be unaffected. Greater values will magnify and smaller values will attenuate the signal. Default: 0.5 May be changed whilst playing Has slide options to shape changes
slope_below: | Slope of the amplitude curve below the threshold. A value of 1 means that the output of signals with amplitude below the threshold will be unaffected. Greater values will magnify and smaller values will attenuate the signal. Default: 1 May be changed whilst playing Has slide options to shape changes
relax_time: | Time taken for the amplitude adjustments to be released. Usually a little longer than clamp_time. If both times are too short, you can get some (possibly unwanted) artefacts. Also known as the time of the release phase. Default: 0.01 Must be zero or greater May be changed whilst playing Has slide options to shape changes

## Slide Options

Any parameter that is slidable has three additional options named _slide, _slide_curve, and _slide_shape. For example, 'amp' is slidable, so you can also set amp_slide, amp_slide_curve, and amp_slide_shape with the following effects:

_slide: | Amount of time (in beats) for the parameter value to change. A long parameter_slide value means that the parameter takes a long time to slide from the previous value to the new value. A parameter_slide of 0 means that the parameter instantly changes to the new value. Default: 0
_slide_shape: | Shape of curve. 0: step, 1: linear, 3: sine, 4: welch, 5: custom (use *_slide_curve: opt e.g. amp_slide_curve:), 6: squared, 7: cubed. Default: 5
_slide_curve: | Shape of the slide curve (only honoured if slide shape is 5). 0 means linear and positive and negative numbers curve the segment up and down respectively. Default: 0