Csound Csound-dev Csound-tekno Search About

[Cs-dev] ksmps=1 conditional issue

Date2012-05-22 07:31
FromOeyvind Brandtsegg
Subject[Cs-dev] ksmps=1 conditional issue
Hi,
I'm not sure what to make out of this.

For pedagogical purposes, I tried to implement an explicit coding of
hard clip (like the limit opcode).
Using ksmps = 1, I did this:

	k1		downsamp	a1
	if k1 > iClip then
	k1		= iClip
	elseif k1 < -iClip then
	k1		= -iClip	
	endif
	a1		upsamp k1

I can't seem to find anything wrong with the code, but it only limits
the positive part of the waveform,
the negative part remains untouched.
If I replace
	k1		= -iClip	
with
	k1		= -0.5
it will limit, but obviously not the way I wanted.

Could look like a bug ?

best
Oeyvind

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2012-05-22 10:14
FromVictor Lazzarini
Subject[Cs-dev] New Parser bug (csound 5) ( was Re: ksmps=1 conditional issue).
It is a new parser bug (possibly optimisation).  The assignment never occurs with i-vars, but it does with constants and k-vars,
as demonstrated by the CSD below:





instr 1
iClip = 0.9
k1	 oscili 2,440,1
if k1 > iClip then
k1	 = iClip
elseif k1 < -iClip then
k1	 = -iClip
endif
printk 0.01, k1
endin
instr 2
iClip = 0.9
k1	 oscili 2,440,1
if k1 > iClip then
k1	 = iClip
elseif k1 < -iClip then
k1	 = -0.9
endif
printk 0.01, k1
endin
instr 3
kClip = 0.9
k1	 oscili 2,440,1
if k1 > kClip then
k1	 = kClip
elseif k1 < -kClip then
k1	 = -kClip
endif
printk 0.01, k1
endin


f1 0 1024 10 1
i1 0 1
i2 1 1
i3 2 1



Victor


On 22 May 2012, at 07:31, Oeyvind Brandtsegg wrote:

> Hi,
> I'm not sure what to make out of this.
> 
> For pedagogical purposes, I tried to implement an explicit coding of
> hard clip (like the limit opcode).
> Using ksmps = 1, I did this:
> 
> 	k1		downsamp	a1
> 	if k1 > iClip then
> 	k1		= iClip
> 	elseif k1 < -iClip then
> 	k1		= -iClip	
> 	endif
> 	a1		upsamp k1
> 
> I can't seem to find anything wrong with the code, but it only limits
> the positive part of the waveform,
> the negative part remains untouched.
> If I replace
> 	k1		= -iClip	
> with
> 	k1		= -0.5
> it will limit, but obviously not the way I wanted.
> 
> Could look like a bug ?
> 
> best
> Oeyvind
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie




------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2012-05-24 12:50
Fromjohn ffitch
SubjectRe: [Cs-dev] New Parser bug (csound 5) ( was Re: ksmps=1 conditional issue).
As you may be away I never liked the if...then syntax as it is unclear
at what rate it is supposed to work.

Can you describe the case that does not work?

==John ffitch

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2012-05-24 13:40
Fromjpff@cs.bath.ac.uk
SubjectRe: [Cs-dev] New Parser bug (csound 5) ( was Re: ksmps=1 conditional issue).
Follow up

1)old parser is now broken
  Csound version 5.17 beta (double samples) May 24 2012
  0dBFS level = 32768.0
  sr = 44100, kr = 4410, ksmps = 7.410985e-322
  error: invalid ksmps value

2) overwriting sr.kr/ksmps it works

3) Victor's example has 6 cases, one failing, which is
...if k1 < - iClip then ....

Very strange


> As you may be away I never liked the if...then syntax as it is unclear
> at what rate it is supposed to work.
>
> Can you describe the case that does not work?
>
> ==John ffitch
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
>



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2012-05-24 16:25
FromVictor Lazzarini
SubjectRe: [Cs-dev] New Parser bug (csound 5) ( was Re: ksmps=1 conditional issue).
yes, it's instrument 3 that is buggy. I think there is no ambiguity here, somehow the assignment is never done, and that is why I suggested it could be the optimisation.

Regards

Victor
On 24 May 2012, at 13:40, jpff@cs.bath.ac.uk wrote:

> Follow up
> 
> 1)old parser is now broken
>  Csound version 5.17 beta (double samples) May 24 2012
>  0dBFS level = 32768.0
>  sr = 44100, kr = 4410, ksmps = 7.410985e-322
>  error: invalid ksmps value
> 
> 2) overwriting sr.kr/ksmps it works
> 
> 3) Victor's example has 6 cases, one failing, which is
> ...if k1 < - iClip then ....
> 
> Very strange
> 
> 
>> As you may be away I never liked the if...then syntax as it is unclear
>> at what rate it is supposed to work.
>> 
>> Can you describe the case that does not work?
>> 
>> ==John ffitch
>> 
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>> 
>> 
>> 
> 
> 
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie




------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2012-05-24 17:25
Fromjpff@cs.bath.ac.uk
SubjectRe: [Cs-dev] New Parser bug (csound 5) ( was Re: ksmps=1 conditional issue).
> yes, it's instrument 3 that is buggy. I think there is no ambiguity here,
> somehow the assignment is never done, and that is why I suggested it could
> be the optimisation.
>
> Regards
>
> Victor

More information: note the line marked with a *********
It looks as if the assignment is "optimised" from
itmp = (-1)*iClip
k1 = itmp

to

k1 = k(itmp) which happens at i-time.  I guess such anoptimisation is only
valid if rate match.   should optimise to k1 mult.ii -1, iClip which does
not exist.....

Not sure how to fix

==John

Found IF statement
Found if-then
Creating boolean expression
Operator Found: > (k i)
Creating Synthetic T_IDENT: __synthetic_301
Engine/csound_orc_semantics.c(360) line = -1

Creating Synthetic label: __synthetic_301:
Engine/csound_orc_semantics.c(360) line = -1

Creating Synthetic T_IDENT: __synthetic_300
Engine/csound_orc_semantics.c(360) line = -1

Creating simple goto token
Engine/csound_orc_semantics.c(339) line = 16

Creating boolean expression
HANDLING UNARY MINUS!SET_EXPRESSION_TYPE: mul.ii : #i0
Operator Found: < (k i)
Creating Synthetic T_IDENT: __synthetic_302
Engine/csound_orc_semantics.c(360) line = -1

Creating Synthetic label: __synthetic_302:
Engine/csound_orc_semantics.c(360) line = -1

Creating Synthetic T_IDENT: __synthetic_300
Engine/csound_orc_semantics.c(360) line = -1

Creating simple goto token
Creating Synthetic label: __synthetic_300:
Engine/csound_orc_semantics.c(360) line = -1

Found Statement.
Handling Optional Args for opcode cngoto, 2, 2Found Statement.
Found Assignment type: =.k
Handling Optional Args for opcode =.k, 1, 1Found Statement.
Handling Optional Args for opcode kgoto, 1, 1Found Statement.
Handling Optional Args for opcode mul.ii, 2, 2Found Statement.
Handling Optional Args for opcode <, 2, 2Found Statement.
Handling Optional Args for opcode cngoto, 2, 2HANDLING UNARY
MINUS!SET_EXPRESSIO
N_TYPE: mul.ii : #i1
Engine/csound_orc_semantics.c(360) line = 16

Found Statement.
Handling Optional Args for opcode k.i, 1, 1Found Statement.   ***********
Handling Optional Args for opcode kgoto, 1, 1Found Statement.
Handling Optional Args for opcode printk, 2,
3Engine/csound_orc_semantics.c(360)
 line = 17



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2012-05-24 17:50
Fromjpff@cs.bath.ac.uk
SubjectRe: [Cs-dev] New Parser bug (csound 5) ( was Re: ksmps=1 conditional issue).
Fixed -- trivial really....



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2012-05-24 17:57
FromVictor
SubjectRe: [Cs-dev] New Parser bug (csound 5) ( was Re: ksmps=1 conditional issue).
Nothing like really knowing your stuff...



On 24 May 2012, at 17:50, jpff@cs.bath.ac.uk wrote:

> Fixed -- trivial really....
> 
> 
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net