New effect idea for this component: Simple limiter (better off to be bundled with foo_dsp_effect rather than its own DSP component)
Based on Winamp EQ's limiter (according to this part) and my own re-implementation of it (with added channel linking and made threshold/ceiling and release time configurable) as AudioWorkletProcessor:
class WinampEQLimiter extends AudioWorkletProcessor {
static get parameterDescriptors() {
return [{
name: 'threshold',
defaultValue: 0
},{
name: 'ceiling',
defaultValue: 0
},{
name: 'release',
defaultValue: 700,
minValue: 0
},{
name: 'channelLink',
defaultValue: 100,
minValue: 0,
maxValue: 100
}];
}
constructor() {
super();
this.envelopeValues = [];
this.ampTodB = x => {
return 20*Math.log10(x);
};
this.dBToAmp = x => {
return 10 ** (x/20);
}
}
process(inputs, outputs, parameters) {
const input = inputs[0],
output = outputs[0],
relTime = 0.001 ** (1/(parameters.release[0]*sampleRate/1000));
this.envelopeValues.length = input.length;
const globalValue = [];
input.forEach((channel, x) => {
for (let i = 0; i < channel.length; i++) {
globalValue[i] = Math.max(isFinite(globalValue[i]) ? globalValue[i] : 0, Math.abs(channel[i])) * (parameters.channelLink[0] / 100);
}
});
input.forEach((channel, x) => {
for (let i = 0; i < channel.length; i++) {
const preamp = this.dBToAmp(-parameters.threshold[0]),
ceiling = this.dBToAmp(parameters.ceiling[0]),
amp = Math.max(Math.abs(input[x][i]), isFinite(globalValue[i]) ? globalValue[i] : 0) * preamp / ceiling;
this.envelopeValues[x] = Math.max(isFinite(this.envelopeValues[x]) ? this.envelopeValues[x] * relTime : isFinite(amp) ? amp : 0, isFinite(amp) ? amp : 0);
output[x][i] = input[x][i] * preamp * Math.min(1/this.envelopeValues[x], 1);
}
});
return true;
}
}
registerProcessor('waeqlim-dsp', WinampEQLimiter);
with the default setting is the same as it is in Winamp asides channel linking and sound similarly to "Advanced Limiter" DSP bundled with foobar2000 as I've made and tested this over my own sandbox project for testing AudioWorklet-based effects
@mudlord, feel free to omit "threshold" parameter (which does the similar thing on maximizer VST plugins, increase the volume based on the "threshold" parameter before being fed into a peak limiter) and keep the rest of the parameters as it can be done with "Gain/Scale" effect from foo_dsp_utility anyway, when comes to re-implementing my own re-implementation as a foobar2000 DSP effect