Csound Csound-dev Csound-tekno Search About

[Csnd] clip formula

Date2009-09-03 12:18
From"Paolo Dell'Osso"
Subject[Csnd] clip formula
Hi,
I would like to know the exact math expression for the Bram the Jong method (imeth = 0) of the clip opcode. I really can't understand this line in the manual:
|x| > a:     f(x) = sin(x) * (a+(x-a)/(1+((x-a)/(1-a))2 |x| > 1: f(x) = sin(x) * (a+1)/2
There are three parameters to determine the clip: asig, ilimit, iarg. In the expression above there are only two values: a, x. Is there something missing?
What are the exact intervals for x?
There is a problem with non-closed parenthesis in the first "f(x) = ...".

Thanks,
Paolo

Date2009-09-03 12:40
FromOeyvind Brandtsegg
Subject[Csnd] Re: clip formula
I think "a" is the clipping threshold, and "x" is the audio input signal.
I'm not sure where iarg comes into this, I was not aware that there
was an additional argument to the method.
Also, I'm not totally sure where the missing closing parenthesis should go.
Thanks for bringing it up, maybe John knows something more about this?
Oeyvind

2009/9/3 Paolo Dell'Osso :
> Hi,
> I would like to know the exact math expression for the Bram the Jong method
> (imeth = 0) of the clip opcode. I really can't understand this line in the
> manual:
>>
>> |x| > a:     f(x) = sin(x) * (a+(x-a)/(1+((x-a)/(1-a))2 |x| > 1: f(x) =
>> sin(x) * (a+1)/2
>
> There are three parameters to determine the clip: asig, ilimit, iarg. In the
> expression above there are only two values: a, x. Is there something
> missing?
> What are the exact intervals for x?
> There is a problem with non-closed parenthesis in the first "f(x) = ...".
>
> Thanks,
> Paolo
>

Date2009-09-03 14:31
FromPablo Frank
Subject[Csnd] RE: clip formula
probably you should ask in the forum of one/both of these sites:
 http://www.musicdsp.org/
http://www.dspmusic.org/


Date: Thu, 3 Sep 2009 13:18:10 +0200
From: dello@luccalug.it
To: csound@lists.bath.ac.uk
Subject: [Csnd] clip formula

Hi,
I would like to know the exact math expression for the Bram the Jong method (imeth = 0) of the clip opcode. I really can't understand this line in the manual:
|x| > a:     f(x) = sin(x) * (a+(x-a)/(1+((x-a)/(1-a))2 |x| > 1: f(x) = sin(x) * (a+1)/2
There are three parameters to determine the clip: asig, ilimit, iarg. In the expression above there are only two values: a, x. Is there something missing?
What are the exact intervals for x?
There is a problem with non-closed parenthesis in the first "f(x) = ...".

Thanks,
Paolo


What can you do with the new Windows Live? Find out

Date2009-09-03 16:12
From"Paolo Dell'Osso"
Subject[Csnd] Re: RE: clip formula
Ok, thanks to all.
I think 'a' is not properly 'iarg' but something like 'iarg*ilim', so that 'iarg' is sensible to values in the range 0 - 1 (0: softer, 1:harder).
Paolo

2009/9/3 Pablo Frank <frank_pablo@hotmail.com>
probably you should ask in the forum of one/both of these sites:
 http://www.musicdsp.org/
http://www.dspmusic.org/


Date: Thu, 3 Sep 2009 13:18:10 +0200
From: dello@luccalug.it
To: csound@lists.bath.ac.uk
Subject: [Csnd] clip formula


Hi,
I would like to know the exact math expression for the Bram the Jong method (imeth = 0) of the clip opcode. I really can't understand this line in the manual:
|x| > a:     f(x) = sin(x) * (a+(x-a)/(1+((x-a)/(1-a))2 |x| > 1: f(x) = sin(x) * (a+1)/2
There are three parameters to determine the clip: asig, ilimit, iarg. In the expression above there are only two values: a, x. Is there something missing?
What are the exact intervals for x?
There is a problem with non-closed parenthesis in the first "f(x) = ...".

Thanks,
Paolo


What can you do with the new Windows Live? Find out


Date2009-09-03 16:21
Fromvictor
Subject[Csnd] Re: Re: RE: clip formula
No, iarg is 'a'  and 'ilim' is the limit as I explained. This is what
the code does, I looked at the sources.
 
Victor
----- Original Message -----
Sent: Thursday, September 03, 2009 4:12 PM
Subject: [Csnd] Re: RE: clip formula

Ok, thanks to all.
I think 'a' is not properly 'iarg' but something like 'iarg*ilim', so that 'iarg' is sensible to values in the range 0 - 1 (0: softer, 1:harder).
Paolo

2009/9/3 Pablo Frank <frank_pablo@hotmail.com>
probably you should ask in the forum of one/both of these sites:
 http://www.musicdsp.org/
http://www.dspmusic.org/


Date: Thu, 3 Sep 2009 13:18:10 +0200
From: dello@luccalug.it
To: csound@lists.bath.ac.uk
Subject: [Csnd] clip formula


Hi,
I would like to know the exact math expression for the Bram the Jong method (imeth = 0) of the clip opcode. I really can't understand this line in the manual:
|x| > a:     f(x) = sin(x) * (a+(x-a)/(1+((x-a)/(1-a))2 |x| > 1: f(x) = sin(x) * (a+1)/2
There are three parameters to determine the clip: asig, ilimit, iarg. In the expression above there are only two values: a, x. Is there something missing?
What are the exact intervals for x?
There is a problem with non-closed parenthesis in the first "f(x) = ...".

Thanks,
Paolo


What can you do with the new Windows Live? Find out


Date2009-09-03 16:46
From"Paolo Dell'Osso"
Subject[Csnd] Re: Re: Re: RE: clip formula
Uhm, that's strange: so what happens if iarg>ilim?

I tried with a sine normalized to 1 in asig, ilim=0.1, iarg=0.11 (iarg>ilim). I can see a soft clipped sine. With the same conditions but iarg=1 I can see a hard clipped sine.

Paolo

2009/9/3 victor <Victor.Lazzarini@nuim.ie>
No, iarg is 'a'  and 'ilim' is the limit as I explained. This is what
the code does, I looked at the sources.
 
Victor
----- Original Message -----
Sent: Thursday, September 03, 2009 4:12 PM
Subject: [Csnd] Re: RE: clip formula

Ok, thanks to all.
I think 'a' is not properly 'iarg' but something like 'iarg*ilim', so that 'iarg' is sensible to values in the range 0 - 1 (0: softer, 1:harder).
Paolo

2009/9/3 Pablo Frank <frank_pablo@hotmail.com>
probably you should ask in the forum of one/both of these sites:
 http://www.musicdsp.org/
http://www.dspmusic.org/


Date: Thu, 3 Sep 2009 13:18:10 +0200
From: dello@luccalug.it
To: csound@lists.bath.ac.uk
Subject: [Csnd] clip formula


Hi,
I would like to know the exact math expression for the Bram the Jong method (imeth = 0) of the clip opcode. I really can't understand this line in the manual:
|x| > a:     f(x) = sin(x) * (a+(x-a)/(1+((x-a)/(1-a))2 |x| > 1: f(x) = sin(x) * (a+1)/2
There are three parameters to determine the clip: asig, ilimit, iarg. In the expression above there are only two values: a, x. Is there something missing?
What are the exact intervals for x?
There is a problem with non-closed parenthesis in the first "f(x) = ...".

Thanks,
Paolo


What can you do with the new Windows Live? Find out



Date2009-09-03 17:18
Fromvictor
Subject[Csnd] Re: Re: Re: Re: RE: clip formula
This is the code:
 
 if (x>=FL(0.0)) {
          if (UNLIKELY(x>limit)) x = k2;
          else if (x>a)
            x = a + (x-a)/(FL(1.0)+(x-a)*(x-a)*k1);
        }
        else {
          if (UNLIKELY(x<-limit))
            x = -k2;
          else if (-x>a)
            x = -a + (x+a)/(FL(1.0)+(x+a)*(x+a)*k1);
        }
 
If iarg > ilim, then, according to the code, we will
set f(x) = (lim+a)/2  (that is what k2 is).
 
Victor
 
 
----- Original Message -----
Sent: Thursday, September 03, 2009 4:46 PM
Subject: [Csnd] Re: Re: Re: RE: clip formula

Uhm, that's strange: so what happens if iarg>ilim?

I tried with a sine normalized to 1 in asig, ilim=0.1, iarg=0.11 (iarg>ilim). I can see a soft clipped sine. With the same conditions but iarg=1 I can see a hard clipped sine.

Paolo

2009/9/3 victor <Victor.Lazzarini@nuim.ie>
No, iarg is 'a'  and 'ilim' is the limit as I explained. This is what
the code does, I looked at the sources.
 
Victor
----- Original Message -----
Sent: Thursday, September 03, 2009 4:12 PM
Subject: [Csnd] Re: RE: clip formula

Ok, thanks to all.
I think 'a' is not properly 'iarg' but something like 'iarg*ilim', so that 'iarg' is sensible to values in the range 0 - 1 (0: softer, 1:harder).
Paolo

2009/9/3 Pablo Frank <frank_pablo@hotmail.com>
probably you should ask in the forum of one/both of these sites:
 http://www.musicdsp.org/
http://www.dspmusic.org/


Date: Thu, 3 Sep 2009 13:18:10 +0200
From: dello@luccalug.it
To: csound@lists.bath.ac.uk
Subject: [Csnd] clip formula


Hi,
I would like to know the exact math expression for the Bram the Jong method (imeth = 0) of the clip opcode. I really can't understand this line in the manual:
|x| > a:     f(x) = sin(x) * (a+(x-a)/(1+((x-a)/(1-a))2 |x| > 1: f(x) = sin(x) * (a+1)/2
There are three parameters to determine the clip: asig, ilimit, iarg. In the expression above there are only two values: a, x. Is there something missing?
What are the exact intervals for x?
There is a problem with non-closed parenthesis in the first "f(x) = ...".

Thanks,
Paolo


What can you do with the new Windows Live? Find out



Date2009-09-04 02:27
From"Paolo Dell'Osso"
Subject[Csnd] Re: Re: Re: Re: Re: RE: clip formula
I really understand nothing about but I think you should also watch some lines above (in pitch.c):

lines 1467 - 1468:

    p->arg = *p->iarg;
    p->lim = *p->limit;

lines 1472 - 1473:

      if (p->arg > FL(1.0) || p->arg < FL(0.0)) p->arg = FL(0.999);
      p->arg = p->lim * p->arg;

line 1494:

     MYFLT a = p->arg, k1 = p->k1, k2 = p->k2;

 Paolo

2009/9/3 victor <Victor.Lazzarini@nuim.ie>
This is the code:
 
 if (x>=FL(0.0)) {
          if (UNLIKELY(x>limit)) x = k2;
          else if (x>a)
            x = a + (x-a)/(FL(1.0)+(x-a)*(x-a)*k1);
        }
        else {
          if (UNLIKELY(x<-limit))
            x = -k2;
          else if (-x>a)
            x = -a + (x+a)/(FL(1.0)+(x+a)*(x+a)*k1);
        }
 
If iarg > ilim, then, according to the code, we will
set f(x) = (lim+a)/2  (that is what k2 is).
 
Victor
 
 
----- Original Message -----
Sent: Thursday, September 03, 2009 4:46 PM
Subject: [Csnd] Re: Re: Re: RE: clip formula

Uhm, that's strange: so what happens if iarg>ilim?

I tried with a sine normalized to 1 in asig, ilim=0.1, iarg=0.11 (iarg>ilim). I can see a soft clipped sine. With the same conditions but iarg=1 I can see a hard clipped sine.

Paolo

2009/9/3 victor <Victor.Lazzarini@nuim.ie>
No, iarg is 'a'  and 'ilim' is the limit as I explained. This is what
the code does, I looked at the sources.
 
Victor
----- Original Message -----
Sent: Thursday, September 03, 2009 4:12 PM
Subject: [Csnd] Re: RE: clip formula

Ok, thanks to all.
I think 'a' is not properly 'iarg' but something like 'iarg*ilim', so that 'iarg' is sensible to values in the range 0 - 1 (0: softer, 1:harder).
Paolo

2009/9/3 Pablo Frank <frank_pablo@hotmail.com>
probably you should ask in the forum of one/both of these sites:
 http://www.musicdsp.org/
http://www.dspmusic.org/


Date: Thu, 3 Sep 2009 13:18:10 +0200
From: dello@luccalug.it
To: csound@lists.bath.ac.uk
Subject: [Csnd] clip formula


Hi,
I would like to know the exact math expression for the Bram the Jong method (imeth = 0) of the clip opcode. I really can't understand this line in the manual:
|x| > a:     f(x) = sin(x) * (a+(x-a)/(1+((x-a)/(1-a))2 |x| > 1: f(x) = sin(x) * (a+1)/2
There are three parameters to determine the clip: asig, ilimit, iarg. In the expression above there are only two values: a, x. Is there something missing?
What are the exact intervals for x?
There is a problem with non-closed parenthesis in the first "f(x) = ...".

Thanks,
Paolo


What can you do with the new Windows Live? Find out




Date2009-09-04 08:04
Fromvictor
Subject[Csnd] Re: Re: Re: Re: Re: Re: RE: clip formula
Yes, that tells us what I have been saying here: iarg is a, ilim is the lim.
However, if the lim is not 1, a gets scaled accordingly (which brings us back to
the original formula, in a way)
 
 
----- Original Message -----
Sent: Friday, September 04, 2009 2:27 AM
Subject: [Csnd] Re: Re: Re: Re: Re: RE: clip formula

I really understand nothing about but I think you should also watch some lines above (in pitch.c):

lines 1467 - 1468:

    p->arg = *p->iarg;
    p->lim = *p->limit;

lines 1472 - 1473:

      if (p->arg > FL(1.0) || p->arg < FL(0.0)) p->arg = FL(0.999);
      p->arg = p->lim * p->arg;

line 1494:

     MYFLT a = p->arg, k1 = p->k1, k2 = p->k2;

 Paolo

2009/9/3 victor <Victor.Lazzarini@nuim.ie>
This is the code:
 
 if (x>=FL(0.0)) {
          if (UNLIKELY(x>limit)) x = k2;
          else if (x>a)
            x = a + (x-a)/(FL(1.0)+(x-a)*(x-a)*k1);
        }
        else {
          if (UNLIKELY(x<-limit))
            x = -k2;
          else if (-x>a)
            x = -a + (x+a)/(FL(1.0)+(x+a)*(x+a)*k1);
        }
 
If iarg > ilim, then, according to the code, we will
set f(x) = (lim+a)/2  (that is what k2 is).
 
Victor
 
 
----- Original Message -----
Sent: Thursday, September 03, 2009 4:46 PM
Subject: [Csnd] Re: Re: Re: RE: clip formula

Uhm, that's strange: so what happens if iarg>ilim?

I tried with a sine normalized to 1 in asig, ilim=0.1, iarg=0.11 (iarg>ilim). I can see a soft clipped sine. With the same conditions but iarg=1 I can see a hard clipped sine.

Paolo

2009/9/3 victor <Victor.Lazzarini@nuim.ie>
No, iarg is 'a'  and 'ilim' is the limit as I explained. This is what
the code does, I looked at the sources.
 
Victor
----- Original Message -----
Sent: Thursday, September 03, 2009 4:12 PM
Subject: [Csnd] Re: RE: clip formula

Ok, thanks to all.
I think 'a' is not properly 'iarg' but something like 'iarg*ilim', so that 'iarg' is sensible to values in the range 0 - 1 (0: softer, 1:harder).
Paolo

2009/9/3 Pablo Frank <frank_pablo@hotmail.com>
probably you should ask in the forum of one/both of these sites:
 http://www.musicdsp.org/
http://www.dspmusic.org/


Date: Thu, 3 Sep 2009 13:18:10 +0200
From: dello@luccalug.it
To: csound@lists.bath.ac.uk
Subject: [Csnd] clip formula


Hi,
I would like to know the exact math expression for the Bram the Jong method (imeth = 0) of the clip opcode. I really can't understand this line in the manual:
|x| > a:     f(x) = sin(x) * (a+(x-a)/(1+((x-a)/(1-a))2 |x| > 1: f(x) = sin(x) * (a+1)/2
There are three parameters to determine the clip: asig, ilimit, iarg. In the expression above there are only two values: a, x. Is there something missing?
What are the exact intervals for x?
There is a problem with non-closed parenthesis in the first "f(x) = ...".

Thanks,
Paolo


What can you do with the new Windows Live? Find out




Date2009-09-04 12:45
FromPINOT Francois
Subject[Csnd] Re: Re: clip formula
Hello Victor,

after reading carefully the code it seems that limit appears in the 
formula as a scaling factor for a but not for the whole expression, so 
it must appear explicitly in the formula. Moreover, there's a typo in 
the three formulas: sign(x) is written as sin(x)!

I propose those corrections:

method 0:
|x|>= 0 and |x|<= a, f(x)=f(x)
|x|>a and |x|<=limit, 
f(x)=sign(x)*(limit*a+(x-limit*a)/(1+((x-limit*a)/(limit*(1-a))^2)))
|x|>limit, f(x)=sign(x)*(limit*(1+a))/2

method 1:
|x|=limit, f(x)=limit*sign(x)

method 2:
|x|=limit, f(x)=limit*sign(x)

If you agree with this, I'll commit the modifications to the manual 
article in cvs.

Best regards

François Pinot

victor a écrit :
> Yes, that tells us what I have been saying here: iarg is a, ilim is 
> the lim.
> However, if the lim is not 1, a gets scaled accordingly (which brings 
> us back to
> the original formula, in a way)
>  
>  
>
>     ----- Original Message -----
>     *From:* Paolo Dell'Osso 
>     *To:* csound@lists.bath.ac.uk 
>     *Sent:* Friday, September 04, 2009 2:27 AM
>     *Subject:* [Csnd] Re: Re: Re: Re: Re: RE: clip formula
>
>     I really understand nothing about but I think you should also
>     watch some lines above (in pitch.c):
>
>     lines 1467 - 1468:
>
>             p->arg = *p->iarg;
>             p->lim = *p->limit;
>
>
>     lines 1472 - 1473:
>
>               if (p->arg > FL(1.0) || p->arg < FL(0.0)) p->arg =
>         FL(0.999);
>               *p->arg = p->lim * p->arg*;
>
>
>     line 1494:
>
>              MYFLT *a = p->arg*, k1 = p->k1, k2 = p->k2;
>
>
>      Paolo
>
>     2009/9/3 victor      >
>
>         This is the code:
>          
>          if (x>=FL(0.0)) {
>                   if (UNLIKELY(x>limit)) x = k2;
>                   else if (x>a)
>                     x = a + (x-a)/(FL(1.0)+(x-a)*(x-a)*k1);
>                 }
>                 else {
>                   if (UNLIKELY(x<-limit))
>                     x = -k2;
>                   else if (-x>a)
>                     x = -a + (x+a)/(FL(1.0)+(x+a)*(x+a)*k1);
>                 }
>          
>         If iarg > ilim, then, according to the code, we will
>         set f(x) = (lim+a)/2  (that is what k2 is).
>          
>         Victor
>          
>          
>
>             ----- Original Message -----
>             *From:* Paolo Dell'Osso 
>             *To:* csound@lists.bath.ac.uk
>             
>             *Sent:* Thursday, September 03, 2009 4:46 PM
>             *Subject:* [Csnd] Re: Re: Re: RE: clip formula
>
>             Uhm, that's strange: so what happens if iarg>ilim?
>
>             I tried with a sine normalized to 1 in asig, ilim=0.1,
>             iarg=0.11 (iarg>ilim). I can see a soft clipped sine. With
>             the same conditions but iarg=1 I can see a hard clipped sine.
>
>             Paolo
>
>             2009/9/3 victor              >
>
>                 No, iarg is 'a'  and 'ilim' is the limit as I
>                 explained. This is what
>                 the code does, I looked at the sources.
>                  
>                 Victor
>
>                     ----- Original Message -----
>                     *From:* Paolo Dell'Osso 
>                     *To:* csound@lists.bath.ac.uk
>                     
>                     *Sent:* Thursday, September 03, 2009 4:12 PM
>                     *Subject:* [Csnd] Re: RE: clip formula
>
>                     Ok, thanks to all.
>                     I think 'a' is not properly 'iarg' but something
>                     like 'iarg*ilim', so that 'iarg' is sensible to
>                     values in the range 0 - 1 (0: softer, 1:harder).
>                     Paolo
>
>                     2009/9/3 Pablo Frank                      >
>
>                         probably you should ask in the forum of
>                         one/both of these sites:
>                          http://www.musicdsp.org/
>                         http://www.dspmusic.org/
>
>                         ------------------------------------------------------------------------
>                         Date: Thu, 3 Sep 2009 13:18:10 +0200
>                         From: dello@luccalug.it 
>                         To: csound@lists.bath.ac.uk
>                         
>                         Subject: [Csnd] clip formula
>
>
>                         Hi,
>                         I would like to know the exact math expression
>                         for the Bram the Jong method (imeth = 0) of
>                         the clip opcode. I really can't understand
>                         this line in the manual:
>
>                             |/x/| > /a/:     f(/x/) = sin(/x/) * (a+(/x-a/)/(1+((/x-a/)/(1-/a/))^2  |/x/| > 1: f(/x/) = sin(/x/) * (/a/+1)/2
>
>                         There are three parameters to determine the
>                         clip: asig, ilimit, iarg. In the expression
>                         above there are only two values: a, x. Is
>                         there something missing?
>                         What are the exact intervals for x?
>                         There is a problem with non-closed parenthesis
>                         in the first "f(x) = ...".
>
>                         Thanks,
>                         Paolo
>
>                         ------------------------------------------------------------------------
>                         What can you do with the new Windows Live?
>                         Find out
>                         
>
>
>
>


Date2009-09-04 14:35
FromVictor Lazzarini
Subject[Csnd] Re: Re: Re: clip formula
That looks correct to me, thanks.

At 12:45 04/09/2009, you wrote:
>Hello Victor,
>
>after reading carefully the code it seems that 
>limit appears in the formula as a scaling factor 
>for a but not for the whole expression, so it 
>must appear explicitly in the formula. Moreover, 
>there's a typo in the three formulas: sign(x) is written as sin(x)!
>
>I propose those corrections:
>
>method 0:
>|x|>= 0 and |x|<= a, f(x)=f(x)
>|x|>a and |x|<=limit, 
>f(x)=sign(x)*(limit*a+(x-limit*a)/(1+((x-limit*a)/(limit*(1-a))^2)))
>|x|>limit, f(x)=sign(x)*(limit*(1+a))/2
>
>method 1:
>|x||x|>=limit, f(x)=limit*sign(x)
>
>method 2:
>|x||x|>=limit, f(x)=limit*sign(x)
>
>If you agree with this, I'll commit the 
>modifications to the manual article in cvs.
>
>Best regards
>
>François Pinot
>
>victor a écrit :
>>Yes, that tells us what I have been saying here: iarg is a, ilim is the lim.
>>However, if the lim is not 1, a gets scaled 
>>accordingly (which brings us back to
>>the original formula, in a way)
>>
>>
>>
>>     ----- Original Message -----
>>     *From:* Paolo Dell'Osso 
>>     *To:* csound@lists.bath.ac.uk 
>>     *Sent:* Friday, September 04, 2009 2:27 AM
>>     *Subject:* [Csnd] Re: Re: Re: Re: Re: RE: clip formula
>>
>>     I really understand nothing about but I think you should also
>>     watch some lines above (in pitch.c):
>>
>>     lines 1467 - 1468:
>>
>>             p->arg = *p->iarg;
>>             p->lim = *p->limit;
>>
>>
>>     lines 1472 - 1473:
>>
>>               if (p->arg > FL(1.0) || p->arg < FL(0.0)) p->arg =
>>         FL(0.999);
>>               *p->arg = p->lim * p->arg*;
>>
>>
>>     line 1494:
>>
>>              MYFLT *a = p->arg*, k1 = p->k1, k2 = p->k2;
>>
>>
>>      Paolo
>>
>>     2009/9/3 victor >     >
>>
>>         This is the code:
>>
>>          if (x>=FL(0.0)) {
>>                   if (UNLIKELY(x>limit)) x = k2;
>>                   else if (x>a)
>>                     x = a + (x-a)/(FL(1.0)+(x-a)*(x-a)*k1);
>>                 }
>>                 else {
>>                   if (UNLIKELY(x<-limit))
>>                     x = -k2;
>>                   else if (-x>a)
>>                     x = -a + (x+a)/(FL(1.0)+(x+a)*(x+a)*k1);
>>                 }
>>
>>         If iarg > ilim, then, according to the code, we will
>>         set f(x) = (lim+a)/2  (that is what k2 is).
>>
>>         Victor
>>
>>
>>
>>             ----- Original Message -----
>>             *From:* Paolo Dell'Osso 
>>             *To:* csound@lists.bath.ac.uk
>>             
>>             *Sent:* Thursday, September 03, 2009 4:46 PM
>>             *Subject:* [Csnd] Re: Re: Re: RE: clip formula
>>
>>             Uhm, that's strange: so what happens if iarg>ilim?
>>
>>             I tried with a sine normalized to 1 in asig, ilim=0.1,
>>             iarg=0.11 (iarg>ilim). I can see a soft clipped sine. With
>>             the same conditions but iarg=1 I can see a hard clipped sine.
>>
>>             Paolo
>>
>>             2009/9/3 victor >             >
>>
>>                 No, iarg is 'a'  and 'ilim' is the limit as I
>>                 explained. This is what
>>                 the code does, I looked at the sources.
>>
>>                 Victor
>>
>>                     ----- Original Message -----
>>                     *From:* Paolo Dell'Osso 
>>                     *To:* csound@lists.bath.ac.uk
>>                     
>>                     *Sent:* Thursday, September 03, 2009 4:12 PM
>>                     *Subject:* [Csnd] Re: RE: clip formula
>>
>>                     Ok, thanks to all.
>>                     I think 'a' is not properly 'iarg' but something
>>                     like 'iarg*ilim', so that 'iarg' is sensible to
>>                     values in the range 0 - 1 (0: softer, 1:harder).
>>                     Paolo
>>
>>                     2009/9/3 Pablo Frank >                     >
>>
>>                         probably you should ask in the forum of
>>                         one/both of these sites:
>>                          http://www.musicdsp.org/
>>                         http://www.dspmusic.org/
>>
>> 
>>------------------------------------------------------------------------
>>                         Date: Thu, 3 Sep 2009 13:18:10 +0200
>>                         From: dello@luccalug.it 
>>                         To: csound@lists.bath.ac.uk
>>                         
>>                         Subject: [Csnd] clip formula
>>
>>
>>                         Hi,
>>                         I would like to know the exact math expression
>>                         for the Bram the Jong method (imeth = 0) of
>>                         the clip opcode. I really can't understand
>>                         this line in the manual:
>>
>>                             |/x/| > 
>> /a/:     f(/x/) = sin(/x/) * 
>> (a+(/x-a/)/(1+((/x-a/)/(1-/a/))^2  |/x/| > 1: f(/x/) = sin(/x/) * (/a/+1)/2
>>
>>                         There are three parameters to determine the
>>                         clip: asig, ilimit, iarg. In the expression
>>                         above there are only two values: a, x. Is
>>                         there something missing?
>>                         What are the exact intervals for x?
>>                         There is a problem with non-closed parenthesis
>>                         in the first "f(x) = ...".
>>
>>                         Thanks,
>>                         Paolo
>>
>> 
>>------------------------------------------------------------------------
>>                         What can you do with the new Windows Live?
>>                         Find out
>> 
>>
>>
>>
>>
>
>
>
>Send bugs reports to this list.
>To unsubscribe, send email 
>sympa@lists.bath.ac.uk with body "unsubscribe csound"

Victor Lazzarini
Music Technology Laboratory
Music Department
National University of Ireland, Maynooth 



Date2009-09-04 15:47
From"Paolo Dell'Osso"
Subject[Csnd] Re: Re: Re: clip formula
To achieve the best understanding you can also replace those letters in the formulas with the words in the syntax:
x -> asig
limit -> ilimit
a -> iarg

or put a little legend.

Paolo

2009/9/4 PINOT Francois <fggpinot@gmail.com>
Hello Victor,

after reading carefully the code it seems that limit appears in the formula as a scaling factor for a but not for the whole expression, so it must appear explicitly in the formula. Moreover, there's a typo in the three formulas: sign(x) is written as sin(x)!

I propose those corrections:

method 0:
|x|>= 0 and |x|<= a, f(x)=f(x)
|x|>a and |x|<=limit, f(x)=sign(x)*(limit*a+(x-limit*a)/(1+((x-limit*a)/(limit*(1-a))^2)))
|x|>limit, f(x)=sign(x)*(limit*(1+a))/2

method 1:
|x|<limit, f(x)=limit*sin(pi*x/(2*limit))
|x|>=limit, f(x)=limit*sign(x)

method 2:
|x|<limit, f(x)=limit*tanh(x/limit)/tanh(1)
|x|>=limit, f(x)=limit*sign(x)

If you agree with this, I'll commit the modifications to the manual article in cvs.

Best regards

François Pinot

victor a écrit :
Yes, that tells us what I have been saying here: iarg is a, ilim is the lim.
However, if the lim is not 1, a gets scaled accordingly (which brings us back to
the original formula, in a way)
  
   ----- Original Message -----
   *From:* Paolo Dell'Osso <mailto:dello@luccalug.it>
   *To:* csound@lists.bath.ac.uk <mailto:csound@lists.bath.ac.uk>
   *Sent:* Friday, September 04, 2009 2:27 AM
   *Subject:* [Csnd] Re: Re: Re: Re: Re: RE: clip formula

   I really understand nothing about but I think you should also
   watch some lines above (in pitch.c):

   lines 1467 - 1468:

           p->arg = *p->iarg;
           p->lim = *p->limit;


   lines 1472 - 1473:

             if (p->arg > FL(1.0) || p->arg < FL(0.0)) p->arg =
       FL(0.999);
             *p->arg = p->lim * p->arg*;


   line 1494:

            MYFLT *a = p->arg*, k1 = p->k1, k2 = p->k2;


    Paolo

   2009/9/3 victor <Victor.Lazzarini@nuim.ie
   <mailto:Victor.Lazzarini@nuim.ie>>


       This is the code:
                if (x>=FL(0.0)) {
                 if (UNLIKELY(x>limit)) x = k2;
                 else if (x>a)
                   x = a + (x-a)/(FL(1.0)+(x-a)*(x-a)*k1);
               }
               else {
                 if (UNLIKELY(x<-limit))
                   x = -k2;
                 else if (-x>a)
                   x = -a + (x+a)/(FL(1.0)+(x+a)*(x+a)*k1);
               }
               If iarg > ilim, then, according to the code, we will
       set f(x) = (lim+a)/2  (that is what k2 is).
               Victor
               
           ----- Original Message -----
           *From:* Paolo Dell'Osso <mailto:dello@luccalug.it>
           *To:* csound@lists.bath.ac.uk
           <mailto:csound@lists.bath.ac.uk>
           *Sent:* Thursday, September 03, 2009 4:46 PM
           *Subject:* [Csnd] Re: Re: Re: RE: clip formula

           Uhm, that's strange: so what happens if iarg>ilim?

           I tried with a sine normalized to 1 in asig, ilim=0.1,
           iarg=0.11 (iarg>ilim). I can see a soft clipped sine. With
           the same conditions but iarg=1 I can see a hard clipped sine.

           Paolo

           2009/9/3 victor <Victor.Lazzarini@nuim.ie
           <mailto:Victor.Lazzarini@nuim.ie>>


               No, iarg is 'a'  and 'ilim' is the limit as I
               explained. This is what
               the code does, I looked at the sources.
                               Victor

                   ----- Original Message -----
                   *From:* Paolo Dell'Osso <mailto:dello@luccalug.it>
                   *To:* csound@lists.bath.ac.uk
                   <mailto:csound@lists.bath.ac.uk>
                   *Sent:* Thursday, September 03, 2009 4:12 PM
                   *Subject:* [Csnd] Re: RE: clip formula

                   Ok, thanks to all.
                   I think 'a' is not properly 'iarg' but something
                   like 'iarg*ilim', so that 'iarg' is sensible to
                   values in the range 0 - 1 (0: softer, 1:harder).
                   Paolo

                   2009/9/3 Pablo Frank <frank_pablo@hotmail.com
                   <mailto:frank_pablo@hotmail.com>>


                       probably you should ask in the forum of
                       one/both of these sites:
                        http://www.musicdsp.org/
                       http://www.dspmusic.org/

                       ------------------------------------------------------------------------
                       Date: Thu, 3 Sep 2009 13:18:10 +0200
                       From: dello@luccalug.it <mailto:dello@luccalug.it>

                       To: csound@lists.bath.ac.uk
                       <mailto:csound@lists.bath.ac.uk>

                       Subject: [Csnd] clip formula


                       Hi,
                       I would like to know the exact math expression
                       for the Bram the Jong method (imeth = 0) of
                       the clip opcode. I really can't understand
                       this line in the manual:

                           |/x/| > /a/:     f(/x/) = sin(/x/) * (a+(/x-a/)/(1+((/x-a/)/(1-/a/))^2  |/x/| > 1: f(/x/) = sin(/x/) * (/a/+1)/2

                       There are three parameters to determine the
                       clip: asig, ilimit, iarg. In the expression
                       above there are only two values: a, x. Is
                       there something missing?
                       What are the exact intervals for x?
                       There is a problem with non-closed parenthesis
                       in the first "f(x) = ...".

                       Thanks,
                       Paolo

                       ------------------------------------------------------------------------
                       What can you do with the new Windows Live?
                       Find out
                       <http://www.microsoft.com/windows/windowslive/default.aspx>







Send bugs reports to this list.
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


Date2009-09-04 20:46
FromPINOT Francois
Subject[Csnd] Re: Re: Re: Re: clip formula
Done in cvs.

François Pinot

Paolo Dell'Osso a écrit :
> To achieve the best understanding you can also replace those letters 
> in the formulas with the words in the syntax:
> x -> asig
> limit -> ilimit
> a -> iarg
>
> or put a little legend.
>
> Paolo
>
> 2009/9/4 PINOT Francois >
>
>     Hello Victor,
>
>     after reading carefully the code it seems that limit appears in
>     the formula as a scaling factor for a but not for the whole
>     expression, so it must appear explicitly in the formula. Moreover,
>     there's a typo in the three formulas: sign(x) is written as sin(x)!
>
>     I propose those corrections:
>
>     method 0:
>     |x|>= 0 and |x|<= a, f(x)=f(x)
>     |x|>a and |x|<=limit,
>     f(x)=sign(x)*(limit*a+(x-limit*a)/(1+((x-limit*a)/(limit*(1-a))^2)))
>     |x|>limit, f(x)=sign(x)*(limit*(1+a))/2
>
>     method 1:
>     |x|     |x|>=limit, f(x)=limit*sign(x)
>
>     method 2:
>     |x|     |x|>=limit, f(x)=limit*sign(x)
>
>     If you agree with this, I'll commit the modifications to the
>     manual article in cvs.
>
>     Best regards
>
>     François Pinot
>
>     victor a écrit :
>
>         Yes, that tells us what I have been saying here: iarg is a,
>         ilim is the lim.
>         However, if the lim is not 1, a gets scaled accordingly (which
>         brings us back to
>         the original formula, in a way)
>           
>            ----- Original Message -----
>            *From:* Paolo Dell'Osso          >
>            *To:* csound@lists.bath.ac.uk
>         
>         >
>            *Sent:* Friday, September 04, 2009 2:27 AM
>            *Subject:* [Csnd] Re: Re: Re: Re: Re: RE: clip formula
>
>            I really understand nothing about but I think you should also
>            watch some lines above (in pitch.c):
>
>            lines 1467 - 1468:
>
>                    p->arg = *p->iarg;
>                    p->lim = *p->limit;
>
>
>            lines 1472 - 1473:
>
>                      if (p->arg > FL(1.0) || p->arg < FL(0.0)) p->arg =
>                FL(0.999);
>                      *p->arg = p->lim * p->arg*;
>
>
>            line 1494:
>
>                     MYFLT *a = p->arg*, k1 = p->k1, k2 = p->k2;
>
>
>             Paolo
>
>            2009/9/3 victor          
>                     >>
>
>
>                This is the code:
>                         if (x>=FL(0.0)) {
>                          if (UNLIKELY(x>limit)) x = k2;
>                          else if (x>a)
>                            x = a + (x-a)/(FL(1.0)+(x-a)*(x-a)*k1);
>                        }
>                        else {
>                          if (UNLIKELY(x<-limit))
>                            x = -k2;
>                          else if (-x>a)
>                            x = -a + (x+a)/(FL(1.0)+(x+a)*(x+a)*k1);
>                        }
>                        If iarg > ilim, then, according to the code, we
>         will
>                set f(x) = (lim+a)/2  (that is what k2 is).
>                        Victor
>                        
>                    ----- Original Message -----
>                    *From:* Paolo Dell'Osso          >
>                    *To:* csound@lists.bath.ac.uk
>         
>                             >
>                    *Sent:* Thursday, September 03, 2009 4:46 PM
>                    *Subject:* [Csnd] Re: Re: Re: RE: clip formula
>
>                    Uhm, that's strange: so what happens if iarg>ilim?
>
>                    I tried with a sine normalized to 1 in asig, ilim=0.1,
>                    iarg=0.11 (iarg>ilim). I can see a soft clipped
>         sine. With
>                    the same conditions but iarg=1 I can see a hard
>         clipped sine.
>
>                    Paolo
>
>                    2009/9/3 victor          
>                             >>
>
>
>                        No, iarg is 'a'  and 'ilim' is the limit as I
>                        explained. This is what
>                        the code does, I looked at the sources.
>                                        Victor
>
>                            ----- Original Message -----
>                            *From:* Paolo Dell'Osso
>         >
>                            *To:* csound@lists.bath.ac.uk
>         
>                                     >
>                            *Sent:* Thursday, September 03, 2009 4:12 PM
>                            *Subject:* [Csnd] Re: RE: clip formula
>
>                            Ok, thanks to all.
>                            I think 'a' is not properly 'iarg' but
>         something
>                            like 'iarg*ilim', so that 'iarg' is sensible to
>                            values in the range 0 - 1 (0: softer,
>         1:harder).
>                            Paolo
>
>                            2009/9/3 Pablo Frank
>         
>                                     >>
>
>
>                                probably you should ask in the forum of
>                                one/both of these sites:
>                                 http://www.musicdsp.org/
>                                http://www.dspmusic.org/
>
>                              
>          ------------------------------------------------------------------------
>                                Date: Thu, 3 Sep 2009 13:18:10 +0200
>                                From: dello@luccalug.it
>                   >
>
>                                To: csound@lists.bath.ac.uk
>         
>                                         >
>
>                                Subject: [Csnd] clip formula
>
>
>                                Hi,
>                                I would like to know the exact math
>         expression
>                                for the Bram the Jong method (imeth = 0) of
>                                the clip opcode. I really can't understand
>                                this line in the manual:
>
>                                    |/x/| > /a/:     f(/x/) = sin(/x/)
>         * (a+(/x-a/)/(1+((/x-a/)/(1-/a/))^2  |/x/| > 1: f(/x/) =
>         sin(/x/) * (/a/+1)/2
>
>                                There are three parameters to determine the
>                                clip: asig, ilimit, iarg. In the expression
>                                above there are only two values: a, x. Is
>                                there something missing?
>                                What are the exact intervals for x?
>                                There is a problem with non-closed
>         parenthesis
>                                in the first "f(x) = ...".
>
>                                Thanks,
>                                Paolo
>
>                              
>          ------------------------------------------------------------------------
>                                What can you do with the new Windows Live?
>                                Find out
>                              
>          
>
>
>
>
>
>
>
>     Send bugs reports to this list.
>     To unsubscribe, send email sympa@lists.bath.ac.uk
>      with body "unsubscribe csound"
>
>