Csound Csound-dev Csound-tekno Search About

[Csnd] Using the previous value of a k-rate variable calculated at the end of an instrument at the beginning

Date2011-10-29 04:52
FromForrest Cahoon
Subject[Csnd] Using the previous value of a k-rate variable calculated at the end of an instrument at the beginning
Here's the current version of the instrument I'm working on, which is supposed to equalize the volume of everything fed into it via the signal flow opcodes:

instr VolLeveller

aInput inleta "in"

iCutoffAmp = ampdbfs(p4)

iGain = p5

kLevel rms aInput

kAmp = (kLevel*iGain < iCutoffAmp) ? kLevel*iGain : iCutoffAmp

aOutput gain aInput, kAmp

kOutLevel rms aOutput

printks "in %.0f tgt %.0f out %.0f\n", 0.5, kLevel, kAmp, kOutLevel-kAmp

out aOutput

endin


It doesn't quite work -- the output, which I'm measuring with kOutLevel still varies considerably from the target output level.


What I'd like to do is use the kOutLevel from the previous k-cycle at the beginning of the instrument to calculate a compensation factor and get a more level output.


How do I do that?


Forrest



Date2011-10-29 07:55
Fromjpff@cs.bath.ac.uk
SubjectRe: [Csnd] Using the previous value of a k-rate variable calculated
set
  koldLevel init 0
at start  and
  koldLevel = kLevel
at the end.

Or have I misunderstood?

> Here's the current version of the instrument I'm working on, which is
> supposed to equalize the volume of everything fed into it via the signal
> flow opcodes:
>
>  instr VolLeveller
>
> aInput inleta "in"
>
> iCutoffAmp = ampdbfs(p4)
>
> iGain = p5
>
> kLevel rms aInput
>
> kAmp = (kLevel*iGain < iCutoffAmp) ? kLevel*iGain : iCutoffAmp
>
> aOutput gain aInput, kAmp
>
> kOutLevel rms aOutput
>
> printks "in %.0f tgt %.0f out %.0f\n", 0.5, kLevel, kAmp, kOutLevel-kAmp
>
> out aOutput
>
> endin
>
>
> It doesn't quite work -- the output, which I'm measuring with kOutLevel
> still varies considerably from the target output level.
>
>
> What I'd like to do is use the kOutLevel from the previous k-cycle at the
> beginning of the instrument to calculate a compensation factor and get a
> more level output.
>
>
> How do I do that?
>
>
> 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"
>
>




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"