Csound Csound-dev Csound-tekno Search About

noob question about rms and half power point

Date2016-07-27 22:01
FromKevin Welsh
Subjectnoob question about rms and half power point
I'm attempting to use the rms opcode to detect clipping in an
instrument.  The opcode allows you to optionally set a half power
point, with the default value being 10.

I've noticed that detecting clipping with the "hpp" set at 10 is very
ineffective... and after some experimentation it seems that setting it
much higher (currently set to 22050 but that is purely arbitrary and
doesn't seem to need to be related to "sr") yields much better results
in my detection of the clipping.  If I understand what is happening,
using the hpp of 10 means I would only be detecting clipping in the
lower end (probably subaudible) end of the spectrum.

First and most importantly, is setting the hpp so high a bad idea from
a performance standpoint?  I don't want to cause rms to use more
resources than needed, since the end goal is to use this in cabbage
plugins in a DAW with lots of other processing happening real time.  I
don't think it should matter one bit as it's basically just changing a
filter cutoff point, but I'm hoping someone who knows that for a fact
can confirm that I'm not doing something silly.

Second, is there a more "ideal" hpp setting for detecting clipping in
a harmonically rich setting?  Or maybe another way to do this entirely
that might be more efficient?

Thanks for any pointers and advice!

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-07-27 22:17
FromSteven Yi
SubjectRe: noob question about rms and half power point
Hi Kevin,

The code for rms is available at:

https://github.com/csound/csound/blob/develop/OOps/ugens5.c#L1197-L1207

https://github.com/csound/csound/blob/develop/OOps/ugens5.c#L1233-L1252

The first link is for rmsset, the initialization code, and the second
link is for the perf-time code.

>From what I understand, the value of ihp has zero effect on
performance. It is only used to calculate c1 and c2 coefficients
internally.

Beyond that, I haven't studied the processing code so I can not give any advice.

steven

On Wed, Jul 27, 2016 at 5:01 PM, Kevin Welsh  wrote:
> I'm attempting to use the rms opcode to detect clipping in an
> instrument.  The opcode allows you to optionally set a half power
> point, with the default value being 10.
>
> I've noticed that detecting clipping with the "hpp" set at 10 is very
> ineffective... and after some experimentation it seems that setting it
> much higher (currently set to 22050 but that is purely arbitrary and
> doesn't seem to need to be related to "sr") yields much better results
> in my detection of the clipping.  If I understand what is happening,
> using the hpp of 10 means I would only be detecting clipping in the
> lower end (probably subaudible) end of the spectrum.
>
> First and most importantly, is setting the hpp so high a bad idea from
> a performance standpoint?  I don't want to cause rms to use more
> resources than needed, since the end goal is to use this in cabbage
> plugins in a DAW with lots of other processing happening real time.  I
> don't think it should matter one bit as it's basically just changing a
> filter cutoff point, but I'm hoping someone who knows that for a fact
> can confirm that I'm not doing something silly.
>
> Second, is there a more "ideal" hpp setting for detecting clipping in
> a harmonically rich setting?  Or maybe another way to do this entirely
> that might be more efficient?
>
> Thanks for any pointers and advice!
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-07-28 00:28
FromOeyvind Brandtsegg
SubjectRe: noob question about rms and half power point
Could you not just use the absolute value of the audio signal to
detect clipping?

2016-07-27 23:01 GMT+02:00 Kevin Welsh :
> I'm attempting to use the rms opcode to detect clipping in an
> instrument.  The opcode allows you to optionally set a half power
> point, with the default value being 10.
>
> I've noticed that detecting clipping with the "hpp" set at 10 is very
> ineffective... and after some experimentation it seems that setting it
> much higher (currently set to 22050 but that is purely arbitrary and
> doesn't seem to need to be related to "sr") yields much better results
> in my detection of the clipping.  If I understand what is happening,
> using the hpp of 10 means I would only be detecting clipping in the
> lower end (probably subaudible) end of the spectrum.
>
> First and most importantly, is setting the hpp so high a bad idea from
> a performance standpoint?  I don't want to cause rms to use more
> resources than needed, since the end goal is to use this in cabbage
> plugins in a DAW with lots of other processing happening real time.  I
> don't think it should matter one bit as it's basically just changing a
> filter cutoff point, but I'm hoping someone who knows that for a fact
> can confirm that I'm not doing something silly.
>
> Second, is there a more "ideal" hpp setting for detecting clipping in
> a harmonically rich setting?  Or maybe another way to do this entirely
> that might be more efficient?
>
> Thanks for any pointers and advice!
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here


Date2016-07-28 05:03
FromKevin Welsh
SubjectRe: noob question about rms and half power point
Thanks Steven, at least that confirms I'm not being *too* stupid with
my parameters.

Oeyvind: I had considered that approach, but since I'm using this as a
binary signal into chnset to turn on and off a clip "light" in
cabbage, I was concerned that the simple comparison would be too
instantaneous.  Admittedly tho, I haven't actually tried that way yet,
but it's probably worth a shot.  Thanks for the suggestion.

On Wed, Jul 27, 2016 at 7:28 PM, Oeyvind Brandtsegg
 wrote:
> Could you not just use the absolute value of the audio signal to
> detect clipping?
>
> 2016-07-27 23:01 GMT+02:00 Kevin Welsh :
>> I'm attempting to use the rms opcode to detect clipping in an
>> instrument.  The opcode allows you to optionally set a half power
>> point, with the default value being 10.
>>
>> I've noticed that detecting clipping with the "hpp" set at 10 is very
>> ineffective... and after some experimentation it seems that setting it
>> much higher (currently set to 22050 but that is purely arbitrary and
>> doesn't seem to need to be related to "sr") yields much better results
>> in my detection of the clipping.  If I understand what is happening,
>> using the hpp of 10 means I would only be detecting clipping in the
>> lower end (probably subaudible) end of the spectrum.
>>
>> First and most importantly, is setting the hpp so high a bad idea from
>> a performance standpoint?  I don't want to cause rms to use more
>> resources than needed, since the end goal is to use this in cabbage
>> plugins in a DAW with lots of other processing happening real time.  I
>> don't think it should matter one bit as it's basically just changing a
>> filter cutoff point, but I'm hoping someone who knows that for a fact
>> can confirm that I'm not doing something silly.
>>
>> Second, is there a more "ideal" hpp setting for detecting clipping in
>> a harmonically rich setting?  Or maybe another way to do this entirely
>> that might be more efficient?
>>
>> Thanks for any pointers and advice!
>>
>> Csound mailing list
>> Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> Send bugs reports to
>>         https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
>
>
>
> --
>
> Oeyvind Brandtsegg
> Professor of Music Technology
> NTNU
> 7491 Trondheim
> Norway
> Cell: +47 92 203 205
>
> http://www.partikkelaudio.com/
> http://soundcloud.com/brandtsegg
> http://flyndresang.no/
> http://soundcloud.com/t-emp
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here