Jump to content

Component: Compressor (DSP Operators)

From Flowcode Help
Author Matrix Ltd
Version 1.2
Category DSP Operators


Compressor component

Reduces the dynamic range of a signal by turning down levels above a threshold, with adjustable ratio, attack, release and makeup gain.

Detailed description

No detailed description exists yet for this component

Examples

No additional examples

Macro reference

Compress

Compress
Collects a single value from the input buffer, applies the compressor and passes the result to the output buffer. 
- VOID Return


CompressArray

CompressArray
Passes an entire buffer through the compressor and outputs the compressed version of the buffer at the other end. 
- VOID Return


ControlCompressor

ControlCompressor
Enables or disables the compressor, enabled by default. When disabled samples pass through unchanged. 
- BOOL State
0=Disable, 1=Enable 
- VOID Return


GetEnvelope

GetEnvelope
Float and 32-bit buffer types only. Returns the detected signal level, measured from the signal centre. 
- FLOAT Return


GetEnvelopeInt

GetEnvelopeInt
8/16-bit integer buffer types only. Returns the detected signal level, measured from the signal centre. 
- LONG Return


GetGain

GetGain
Float and 32-bit buffer types only. Returns the gain applied on the last sample, excluding makeup gain. 1.0 = no gain reduction, 0.5 = halved. 
- FLOAT Return


GetGainQ8

GetGainQ8
8/16-bit integer buffer types only. Returns the gain applied on the last sample in 1/256 steps, excluding makeup gain. 256 = no gain reduction, 128 = halved. 
- UINT Return


Reset

Reset
Clears the envelope follower so the compressor starts again from no gain reduction. 
- VOID Return


SetAttackShift

SetAttackShift
8/16-bit integer buffer types only. Sets how quickly the compressor responds to a rising signal. The time constant is 2 ^ Shift samples. 
- BYTE Shift
0 = instant, 1 = 2 samples, 2 = 4 samples ... 15 = 32768 samples 
- VOID Return


SetAttackTime

SetAttackTime
Float and 32-bit buffer types only. Sets how quickly the compressor responds to a signal rising above the threshold. 
- FLOAT Time_ms
Attack time constant in milliseconds, 0 = instant 
- VOID Return


SetMakeupGain

SetMakeupGain
Float and 32-bit buffer types only. Sets the gain applied after compression to restore the overall signal level. 
- FLOAT Multiplier
Linear gain multiplier, 1.0 = no change 
- VOID Return


SetMakeupGainQ8

SetMakeupGainQ8
8/16-bit integer buffer types only. Sets the gain applied after compression in 1/256 steps, e.g. 256 = x1, 384 = x1.5, 512 = x2. 
- UINT Gain
Makeup gain x 256, 0 to 8192 (x32) 
- VOID Return


SetRatio

SetRatio
Float and 32-bit buffer types only. Sets the compression ratio, e.g. 4.0 for 4:1. A level 4dB above the threshold comes out 1dB above it. Large ratios act as a limiter. 
- FLOAT Ratio
Compression ratio, 1.0 or greater. 1.0 = no compression 
- VOID Return


SetRatioShift

SetRatioShift
8/16-bit integer buffer types only. Sets the compression ratio as a power of two: 0 = 1:1, 1 = 2:1, 2 = 4:1, 3 = 8:1, 4 = 16:1, 5 = 32:1, 24 = limiter. 
- BYTE Shift
Ratio = 2 ^ Shift, 0 to 5 or 24 for a limiter 
- VOID Return


SetReleaseShift

SetReleaseShift
8/16-bit integer buffer types only. Sets how quickly the compressor recovers once the signal falls. The time constant is 2 ^ Shift samples. 
- BYTE Shift
0 = instant, 1 = 2 samples, 2 = 4 samples ... 15 = 32768 samples 
- VOID Return


SetReleaseTime

SetReleaseTime
Float and 32-bit buffer types only. Sets how quickly the compressor recovers once the signal falls. 
- FLOAT Time_ms
Release time constant in milliseconds, 0 = instant 
- VOID Return


SetThreshold

SetThreshold
Float and 32-bit buffer types only. Sets the level, measured from the signal centre, above which compression is applied. 
- FLOAT Level
Threshold level in buffer units, must be greater than zero 
- VOID Return


SetThresholdInt

SetThresholdInt
8/16-bit integer buffer types only. Sets the level, measured from the signal centre, above which compression is applied. 
- LONG Level
Threshold level in buffer units, 1 to 65535 
- VOID Return


Property reference

Properties
Connect To
DSP component with output buffer to collect our data from. 
Buffer Size
Number of individual elements the buffer can store, default 1. 
Buffer Type
Sets the buffer data type. Automatically matches the type of the input buffer. 
Direction
Sets the data direction flow of the component 
Compressor
Processing
Set automatically from the buffer type. 8 and 16-bit integer buffers use fixed point maths with no floating point library, ideal for 8-bit devices. 32-bit integer and float buffers use floating point maths. 
Signal Centre
Value representing a zero signal. Levels are measured as the distance from this value. Use 0 for signed buffers, or the mid point for unsigned data, e.g. 512 for a 10-bit ADC or 128 for 8-bit data. 
Threshold
Level, measured from the signal centre, above which compression starts. 1 to 65535. Uses the same units as the buffer data. 
Ratio
Amount of compression applied above the threshold. Fixed point mode works on the linear signal level: the part of the level above the threshold is divided by the ratio. Limiter holds the level at the threshold. 
Attack Shift
Attack time constant as a power of two number of samples, 0 to 15. 0 = instant, 1 = 2 samples, 2 = 4 samples, 3 = 8 samples ... Shifts are used in place of multiplies to keep the maths fast on 8-bit devices. 
Attack Time (ms)
Attack time constant resulting from the attack shift at the specified sample rate. 
Release Shift
Release time constant as a power of two number of samples, 0 to 15. 0 = instant, 1 = 2 samples, 2 = 4 samples, 3 = 8 samples ... 
Release Time (ms)
Release time constant resulting from the release shift at the specified sample rate. 
Makeup Gain
Linear gain multiplier applied after compression to restore the overall level. 1 = no change. In fixed point mode this is converted to a 1/256 step value when compiled, maximum 32. 
Sample Rate (Hz)
Rate at which samples are passed through the compressor. Used to convert between attack and release times and samples. 

Component Source Code

Please click here to download the component source project: FC_Comp_Source_DSP_Compressor.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_DSP_Compressor.fcfx