__GG wrote:
..
Post by __GGHere's another thought: If I were to use instantaneous peak detection
instead of RMS or other slower envelope, then lookahead would not be
necessary. The attack would track instantly.
ref: http://www.musicdsp.org/archive.php?classid=0#19
That should use very few cycles.
What is the flaw here? If I don't need musical-sounding output, just
maximized clean signal, is there any drawback to simply
feed-forwarding the peak-detected, slower-decay envelope to a virtual
VCA?
Any compressor is a non-linear effect, that modulates the source (watch out for
aliasing if the "corners" of the envelope are too sharp) and one way or another
will always have some sort of personality, which may or may not be deemed "musical".
I think you really need to try all these ideas out for yourself, and decide! I
doubt you will get a complete answer here "do it this way" (but I do suggest you
ask on the music-dsp list, and check the list archives, there were major
discussions about compressors a few months ago). Different sources and
requirements indicate different compression techniques, so that in a practical
compressor you will need to offer at least peak and RMS options, and very
possibly average too. Offering Peak and average might be OK, especially if you
want minimum CPU cost. The high-end models of course offer multi-band
compression, and/or seek to emulate analog optical compressors, but the basic
algorithms such as you find in the music-dsp archive are very useful starting
points.
Post by __GGWhat is the best way to control decay/release? Given that the release
does not have to be micro-second accurate, I could add groups of, say,
100 sample abs values, then feed each into a fifo. Accumulate the
total in the FIFO by adding each new value, subtracting each old value
as it gets bumped. The groups of 100 would eliminate the need for a
long buffer. Possible stepping noise due to time granularity from
grouping?
Yes, that is a standard "closed-form" of averaging.
Envelope detection is a form of filtering, and filters can have all sorts of
slopes. The answers you seek may not be solely technical ones. For some
material, one style will work, for another it won't. The window over which
samples are scanned is itelf an important parameter, when doing averaging or
RMS. You need an envelope extractor, which is a filter of one form or another,
and an envelope synthesiser that generates the final envelope to be applied to
the source sound. There is more than one way of designing both, and the criteria
may be CPU load, etc, but may also likely be aesthetic ("hey this works on drums
but is bad on a voice/sax/whatever"), so you really will have to try ideas out
the hard way.
One approach you might like to consider is to start by inspecting the behaviour
of some published compressors (download a few demos!), by feeding in a special
stereo source: one track contains simple dynamically changing waveforms (even a
signal modulated with a plain LF square wave is useful; but it can be even more
useful to have steps at a range of amplitudes, especially when evaluating the
relationship between A/R slopes and threshold); the other a constant-amplitude
sine, and make sure the compressor links the channels. The output on channel 2
will effectively show the envelope the compressor is applying, and you can check
it directly against the source on the other channel. Then correlate your
observations with musical evaluation. This is simple to do in an offline editor
hosting VST plugins; load in your custom file, run the effect, and inspect the
output waveform at your leisure. How the host manages (or not) delay
compensation naturally matters too.
And (ahem) when the product is launched for which I was commissioned to supply a
"simple" compressor, you will be able to analyse that too! As a primarily
classically-oriented musician, I don't make much use of compressors, so it was
always a bit nerve-wracking designing something destined for unfamiliar musical
styles, but I was told by my commissioner that the result was very good, and
especially so on drums <grin>. For me in the end the hardest part was simply
finding a wide enough range of sound sources (voice, slap bass guitar, Bach?) to
test the da*** thing with; with synthetic test waveforms it all ~looked~ OK...
Richard Dobson