public class CompressorEffect
extends java.lang.Object
Compressor
Constructor and Description |
---|
CompressorEffect(float threshold,
double ratio,
double attack,
double release,
double gain,
boolean autoGain,
java.lang.String detectionType,
int thresholdWidth,
float sampleRate)
Creates a Compressor effect
|
Modifier and Type | Method and Description |
---|---|
float |
gainSideChain(float inputSam,
float attackCoefficient,
float releaseCoefficient,
short[] array,
int n)
Sidechain thing to work out...
|
float |
getRegionAverage(short[] currentChunk,
int currentPosition)
Method to calculate the threshold when 'Regional Average' is selected.
|
float |
getRegionMax(short[] currentChunk,
int currentPosition)
Method to calculate the threshold when 'Regional Max' is selected.
|
float |
getRegionRMS(short[] currentChunk,
int currentPosition)
Method to calculate the threshold when 'Regional RMS' is selected.
|
short[] |
process(short[] input)
Process method that compresses the audio.
|
void |
setAttackTime(double att)
Sets the compressor's attack time in samples, after converting from milliseconds
|
void |
setAutoGain(boolean auto)
Selects if the signal will be normalised before outputting
|
void |
setDetectionType(java.lang.String detect)
Sets the type of threshold calculator that will be used (Peak, RMS, Region Average or Region Max)
|
void |
setGain(double vol)
Sets the make up gain.
|
void |
setRatio(double rat)
Sets the compression ratio.
|
void |
setReleaseTime(double rel)
Sets the compressors release time in samples, after converting from milliseconds
|
void |
setThreshold(float thresh)
Sets the threshold level in DECIBELS.
|
void |
setThresholdWidth(int tWidth)
Sets the threshold width that will be used in samples, after converting from milliseconds.
|
public CompressorEffect(float threshold, double ratio, double attack, double release, double gain, boolean autoGain, java.lang.String detectionType, int thresholdWidth, float sampleRate)
threshold
- the threshold level in (negative) decibels. When the signal goes over this threshold,
compression is appliedratio
- the compression ratio is the ratio of change of the input signal versus the change in the
output signalattack
- the time taken before the compressor kicks into action. In milliseconds.release
- the time taken for the compression to stop after the signal falls below the threshold. In
milliseconds.gain
- make up gain to boost the signal level after comrpessionautoGain
- boolean value to indicate if the user wishes to automatically normalise the audio after
compressiondetectionType
- multiple choice string input which chooses the type of choices by process method to choose
suitable method. Chooses between Peak, Region Average, Region Max, and RMS.thresholdWidth
- the size of the window which is the 'region' being examined too be able to set the
thresholdsampleRate
- the sample rate of the incoming audiopublic void setThreshold(float thresh)
thresh
- this is an integer value, which is converted to a decibel value, relative to the maximum short value
of 32767public void setRatio(double rat)
rat
- this is compression ratio value. Any samples which are over the threshold level are divided by this
value, but first taking into account the attack/release timespublic void setAttackTime(double att)
att
- this is the size of the attack 'delay'. This is used to set delay before the compression is applied, and
create the compression envelopepublic void setReleaseTime(double rel)
rel
- this is the size of the release 'delay'. This is used before the compression is stopped being applied,
and creates the compression release envelopepublic void setGain(double vol)
vol
- this can be used to increase the volume of the signal, after compression. This is in decibels
(logarithmic).public void setDetectionType(java.lang.String detect)
detect
- this is the type of threshold calculator which will be used.public void setThresholdWidth(int tWidth)
tWidth
- this is the threshold width, in milliseconds. This method is used to convert tWidth to samples.public void setAutoGain(boolean auto)
auto
- this is a boolean variable. This is used to to decide if the signal will be normalised to 100%, or if
the make up gain is usedpublic float getRegionMax(short[] currentChunk, int currentPosition)
currentChunk
- the current short array or 'audio chunk' being considered. If chunking is not being used,
this will stay constant.currentPosition
- the current position of the sample being considered in for loop in the process method.public float getRegionAverage(short[] currentChunk, int currentPosition)
currentChunk
- the current short array or 'audio chunk' being considered. If chunking is not being used,
this will stay constant.currentPosition
- the current position of the sample being considered in for loop in the process method.public float getRegionRMS(short[] currentChunk, int currentPosition)
currentChunk
- the current short array or 'audio chunk' being considered. If chunking is not being used,
this will stay constant.currentPosition
- the current position of the sample being considered in for loop in the process method.public float gainSideChain(float inputSam, float attackCoefficient, float releaseCoefficient, short[] array, int n)
public short[] process(short[] input)
input
- short array containing the input data to be manipulated by algorithm