Csound Csound-dev Csound-tekno Search About

[Csnd-dev] Why does the portk opcode not accept a negative isig?

Date2022-06-05 01:40
Fromandy fillebrown
Subject[Csnd-dev] Why does the portk opcode not accept a negative isig?
I'm trying to use the pork opcode with a negative isig but the
internal feedback value is not being set. It only gets set if the
value is greater than or equal to zero.

See https://github.com/csound/csound/blob/2e324328d0bf8b446b6c20082224de311982c4bb/OOps/ugens5.c#L41-L42.

Date2022-06-05 11:33
FromEduardo Moguillansky
SubjectRe: [Csnd-dev] Why does the portk opcode not accept a negative isig?
Attachmentsportk-lag-comp.csd  
This looks like a bug in the code. Since isig defaults to 0 when not 
passed, the initial state should always be set to the isig value.

You can always use the lag opcode instead, which allows to ramp from any 
value, and if not given an initial value, it ramps from the first value 
of ksig (this is often what you want). lag is almost a drop-in 
replacement, the only difference being that the lagtime is calculated 
differently, so for "lag" you should multiply the value passed to port 
by a factor of ~8.6 to replicate the exact ramp curve of port.

Run the attached .csd in csoundqt to see a plot of "port" against "lag"


On 05.06.22 02:40, andy fillebrown wrote:
> I'm trying to use the pork opcode with a negative isig but the
> internal feedback value is not being set. It only gets set if the
> value is greater than or equal to zero.
>
> See https://github.com/csound/csound/blob/2e324328d0bf8b446b6c20082224de311982c4bb/OOps/ugens5.c#L41-L42.
>
> Why is a negative isig skipped in the code?

Date2022-06-05 13:56
Fromandy fillebrown
SubjectRe: [Csnd-dev] Why does the portk opcode not accept a negative isig?
Thank you. I will use the lag opcode instead.

On Sun, Jun 5, 2022 at 6:33 AM Eduardo Moguillansky
 wrote:
>
> This looks like a bug in the code. Since isig defaults to 0 when not
> passed, the initial state should always be set to the isig value.
>
> You can always use the lag opcode instead, which allows to ramp from any
> value, and if not given an initial value, it ramps from the first value
> of ksig (this is often what you want). lag is almost a drop-in
> replacement, the only difference being that the lagtime is calculated
> differently, so for "lag" you should multiply the value passed to port
> by a factor of ~8.6 to replicate the exact ramp curve of port.
>
> Run the attached .csd in csoundqt to see a plot of "port" against "lag"
>
>
> On 05.06.22 02:40, andy fillebrown wrote:
> > I'm trying to use the pork opcode with a negative isig but the
> > internal feedback value is not being set. It only gets set if the
> > value is greater than or equal to zero.
> >
> > See https://github.com/csound/csound/blob/2e324328d0bf8b446b6c20082224de311982c4bb/OOps/ugens5.c#L41-L42.
> >

Date2022-06-05 20:34
FromJohn ff
SubjectRe: [Csnd-dev] Why does the portk opcode not accept a negative isig?
That definition of portk dates back to before 1988 so that has been incorrectly documented.  I believe the intent is to be able to start from a previous instantiation if the filter if using us negative.

==John ff

On 5 Jun 2022, at 11:34, Eduardo Moguillansky <eduardo.moguillansky@gmail.com> wrote:
This looks like a bug in the code. Since isig defaults to 0 when not 
passed, the initial state should always be set to the isig value.

You can always use the lag opcode instead, which allows to ramp from any
value, and if not given an initial value, it ramps from the first value
of ksig (this is often what you want). lag is almost a drop-in
replacement, the only difference being that the lagtime is calculated
differently, so for "lag" you should multiply the value passed to port
by a factor of ~8.6 to replicate the exact ramp curve of port.

Run the attached .csd in csoundqt to see a plot of "port" against "lag"


On 05.06.22 02:40, andy fillebrown wrote:
I'm trying to use the pork opcode with a negative isig but the
internal feedback value is not being set. It only gets set if the
value is greater than or equal to zero.

See https://github.com/csound/csound/blob/2e324328d0bf8b446b6c20082224de311982c4bb/OOps/ugens5.c#L41-L42.

Why is a negative isig skipped in the code?

Date2022-06-05 22:58
FromVictor Lazzarini
SubjectRe: [Csnd-dev] [EXTERNAL] Re: [Csnd-dev] Why does the portk opcode not accept a negative isig?
yes. The code checks for isig >= 0 and uses it, otherwise the value stored is kept.

    if (LIKELY(*p->isig >= FL(0.0)))
      p->yt1 = (double)(*p->isig);
 
It's not a bug, it's what it's supposed to do. The normal use of port/portk is with non-negative input, and so it was designed to have a means to preserve the value from a previous instance.

If the manual needs to be corrected, then it should.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 5 Jun 2022, at 20:35, John ff <jpff@codemist.co.uk> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

That definition of portk dates back to before 1988 so that has been incorrectly documented.  I believe the intent is to be able to start from a previous instantiation if the filter if using us negative.

==John ff

On 5 Jun 2022, at 11:34, Eduardo Moguillansky <eduardo.moguillansky@gmail.com> wrote:
This looks like a bug in the code. Since isig defaults to 0 when not 
passed, the initial state should always be set to the isig value.

You can always use the lag opcode instead, which allows to ramp from any
value, and if not given an initial value, it ramps from the first value
of ksig (this is often what you want). lag is almost a drop-in
replacement, the only difference being that the lagtime is calculated
differently, so for "lag" you should multiply the value passed to port
by a factor of ~8.6 to replicate the exact ramp curve of port.

Run the attached .csd in csoundqt to see a plot of "port" against "lag"


On 05.06.22 02:40, andy fillebrown wrote:
I'm trying to use the pork opcode with a negative isig but the
internal feedback value is not being set. It only gets set if the
value is greater than or equal to zero.

See https://github.com/csound/csound/blob/2e324328d0bf8b446b6c20082224de311982c4bb/OOps/ugens5.c#L41-L42.

Why is a negative isig skipped in the code?