micromod
Class Compressor
java.lang.Object
micromod.WaveShaper
micromod.Compressor
- public class Compressor
- extends WaveShaper
Compressor is an implementation of WaveShaper that utilises
an efficient algorithm I found on www.smartelectronix.com/musicdsp
A compressor improves the sound of distortion and so allows you to
crank up the gain without things sounding too horrible. This algorithm
will work with input amplitudes up to 8x the output.
The use of 32 bit arithmetic has meant that the input must be
quantized to 13 bits. The distortion produced by the compressor
is probably louder than the quantization noise anyway.
Method Summary |
protected static int |
abs(int x)
|
protected static int |
sgn(int x)
|
void |
shapeWaves(int[] inputBuffer,
short[] outputBuffer,
int length)
Perform shaping of the samples in inputBuffer to outputBuffer from 0 to length-1. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Compressor
public Compressor()
shapeWaves
public void shapeWaves(int[] inputBuffer,
short[] outputBuffer,
int length)
- Description copied from class:
WaveShaper
- Perform shaping of the samples in inputBuffer to outputBuffer from 0 to length-1.
- Overrides:
shapeWaves
in class WaveShaper
sgn
protected static int sgn(int x)
- Returns:
- -1 if x negative, 1 if zero or positive
abs
protected static int abs(int x)
- Returns:
- the magnitude of x