Csound Csound-dev Csound-tekno Search About

[Csnd] equalizing volume with compress?

Date2011-10-20 03:30
FromForrest Cahoon
Subject[Csnd] equalizing volume with compress?
I want to create a processor which will take whatever input and continually adjust the amplitude so that the final output amplitude is as close as possible to constant.

I am experimenting with the compress opcode now, but I can't seem to achieve my desired effect.

I'm using the signal flow opcodes to route my instruments into this final processor, which looks like this:

alwayson "VolLeveller", 0

giSine ftgen 0, 0, 1024, 10, 1

...


; Equalize volume over all notes

instr VolLeveller

aInput inleta "in"

iAmp = ampdbfs(p4)

aCtl oscil iAmp, 10240, giSine

aOutput compress aInput, aCtl, 0, 0, 0, 1, 0.01, 0.1, 0.5

out aOutput

endin


The idea is that the control signal (acsig in the compress doc, aCtl here) is a constant amplitude signal, so I thought if I could get the other parameters correct I could get the final output to match the amplitude envelope of this signal precisely -- my desired result.


I have spent a considerable amount of time fiddling with the other numbers, but alas, as the sound of multiple input notes add up, the overall volume still increases.


I realize there's a problem in that when there's no input at all, the volume can't be pulled up, and that's a problem with my scheme. What I'd probably like is for the volume to jump from 0 to 1 once there's any signal input, and use further post-processing to address any clicks or other weirdness that causes.


Am I totally misunderstanding the compress opcode? Is there any way to accomplish this goal?


Forrest




Date2011-10-20 09:59
FromRory Walsh
SubjectRe: [Csnd] equalizing volume with compress?
On 20 October 2011 03:30, Forrest Cahoon  wrote:
> I want to create a processor which will take whatever input and continually
> adjust the amplitude so that the final output amplitude is as close as
> possible to constant.

A simple solution, but perhaps more restricting in the long run, would
be to use the balance opcode. Just use a constant signal as the
comparator.

Rory.


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"

Date2011-10-21 08:24
FromAndres Cabrera
SubjectRe: [Csnd] equalizing volume with compress?
Hi,

This is actually quite tricky, since most compressors will have some
attack time, which "softens" the effect of the compressor, but that
will let fast transients through. If you make the attack time shorter,
the compressor tends to become a waveshaper (so you are in fact
distorting rather than reducing the level of high sections). Also
since most compressors use some kind of averaging like RMS, they will
not measure digital peaks directly, so they will not actually control
the amplitude peaks.

There are some limiters that can do some tricks like lookahead which
can help, but I'm not sure there's an opcode in Csound that will do
brick-wall limiting. An effective technique can be to apply a
compressor with lookahead (I think compress or compress2 can do that)
which is set to be a limiter (high compression ratio), and pass the
output through a waveshaper to take out the remaining peaks. Always be
careful with this process as reducing the dynamic range of a signal
can impact it very negatively, sometimes in ways you will only notice
months later if you don't know where to look for the effects of
compression.

Cheers,
Andrés

On Thu, Oct 20, 2011 at 3:30 AM, Forrest Cahoon
 wrote:
> I want to create a processor which will take whatever input and continually
> adjust the amplitude so that the final output amplitude is as close as
> possible to constant.
>
> I am experimenting with the compress opcode now, but I can't seem to achieve
> my desired effect.
>
> I'm using the signal flow opcodes to route my instruments into this final
> processor, which looks like this:
>
> alwayson "VolLeveller", 0
>
> giSine ftgen 0, 0, 1024, 10, 1
>
> ...
>
> ; Equalize volume over all notes
>
> instr VolLeveller
>
> aInput inleta "in"
>
> iAmp = ampdbfs(p4)
>
> aCtl oscil iAmp, 10240, giSine
>
> aOutput compress aInput, aCtl, 0, 0, 0, 1, 0.01, 0.1, 0.5
>
> out aOutput
>
> endin
>
> The idea is that the control signal (acsig in the compress doc, aCtl here)
> is a constant amplitude signal, so I thought if I could get the other
> parameters correct I could get the final output to match the amplitude
> envelope of this signal precisely -- my desired result.
>
> I have spent a considerable amount of time fiddling with the other numbers,
> but alas, as the sound of multiple input notes add up, the overall volume
> still increases.
>
> I realize there's a problem in that when there's no input at all, the volume
> can't be pulled up, and that's a problem with my scheme. What I'd probably
> like is for the volume to jump from 0 to 1 once there's any signal input,
> and use further post-processing to address any clicks or other weirdness
> that causes.
>
> Am I totally misunderstanding the compress opcode? Is there any way to
> accomplish this goal?
>
> Forrest
>
>


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"