Csound Csound-dev Csound-tekno Search About

[Csnd] kans parameter of OSClisten sometimes does not change, data does change

Date2014-09-09 22:46
Fromzappfinger
Subject[Csnd] kans parameter of OSClisten sometimes does not change, data does change
With OSCListen in the following code, I get many times an output as below.
code:

kans1   OSClisten giosc1, "/freq1", "f", kvalin
printk2 kvalin,0
printk2 kans1,10

output:

 i1   219.00000
 i1               1.00000
 i1               0.00000
 i1   221.00000            <== OK: value changes
 i1               1.00000    <== kans reflects this
 i1               0.00000
 i1   219.00000          
 i1               1.00000
 i1   214.00000          <== Not OK, value changes
 i1               0.00000 <== kans does not
 i1   210.00000
 i1               1.00000
 i1               0.00000


Richard



--
View this message in context: http://csound.1045644.n5.nabble.com/kans-parameter-of-OSClisten-sometimes-does-not-change-data-does-change-tp5737393.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2014-09-09 23:14
FromVictor Lazzarini
SubjectRe: [Csnd] kans parameter of OSClisten sometimes does not change,
kans1 is non-zero if there is still something in the buffer. With your code (at least the bit you are showing), because there is no loop,
you are only fetching one value per k-period. When kans1 is non-zero, you are throwing away any remaining data in the buffer.


========================
Dr Victor Lazzarini
Dean of Arts, Philosophy and Celtic Studies,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952 








On 9 Sep 2014, at 22:46, zappfinger  wrote:

> With OSCListen in the following code, I get many times an output as below.
> code:
> 
> kans1   OSClisten giosc1, "/freq1", "f", kvalin
> printk2 kvalin,0
> printk2 kans1,10
> 
> output:
> 
> i1   219.00000
> i1               1.00000
> i1               0.00000
> i1   221.00000            <== OK: value changes
> i1               1.00000    <== kans reflects this
> i1               0.00000
> i1   219.00000          
> i1               1.00000
> i1   214.00000          <== Not OK, value changes
> i1               0.00000 <== kans does not
> i1   210.00000
> i1               1.00000
> i1               0.00000
> 
> 
> Richard
> 
> 
> 
> --
> View this message in context: http://csound.1045644.n5.nabble.com/kans-parameter-of-OSClisten-sometimes-does-not-change-data-does-change-tp5737393.html
> Sent from the Csound - General mailing list archive at Nabble.com.
> 
> 
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
> 
> 
> 



Date2014-09-10 08:54
Fromzappfinger
Subject[Csnd] Re: kans parameter of OSClisten sometimes does not change,
Yes, I probably should be using some loop.
Below is some more code. What I am trying to do is lineair extrapolation:
the OSC values come in at a much lower rate than k-rate. So I am calculating
the slope to fill in every k value, until a new OSC value comes in...(I
think there is no opcode for that?)

kans1   OSClisten giosc1, "/freq1", "f", kvalin
printk2 kvalin,0
printk2 kans1,10

;	start of extrapolation

;if (kvalin == kvalinold) then
if (kans1 == 0) then
	kcount = kcount + 1
	kval = kval + kdelta
else	;	a change in input
	;printk2 kcount,20
	kdelta = (kvalin - kvalinold)/kcount
	;printk2 kdelta,30
	kvalinold = kvalin
	kcount = 1
	kval = kvalin
endif

Richard



--
View this message in context: http://csound.1045644.n5.nabble.com/kans-parameter-of-OSClisten-sometimes-does-not-change-data-does-change-tp5737393p5737401.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2014-09-10 09:27
FromVictor Lazzarini
SubjectRe: [Csnd] kans parameter of OSClisten sometimes does not change,
Not sure how best to do the extrapolation, but if it’s linear, I guess you need to base it in the last 
recorded slope. 

With regards to kans, it is not an indicator of whether a message has arrived, but of whether there
are still messages in the buffer to be read at that k-period. I would suggest that the “changed” opcode
is probably what you want to see if there is a different value coming in. Since your parameter could
potentially be sent unchanged (for a straight line), maybe the best thing is to send in a message with
a tag that can be used to index it. So the tag will increase by 1 for every message you send in, and
you can then use changed on this.

Regards
========================
Dr Victor Lazzarini
Dean of Arts, Philosophy and Celtic Studies,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952 








On 10 Sep 2014, at 08:54, zappfinger  wrote:

> Yes, I probably should be using some loop.
> Below is some more code. What I am trying to do is lineair extrapolation:
> the OSC values come in at a much lower rate than k-rate. So I am calculating
> the slope to fill in every k value, until a new OSC value comes in...(I
> think there is no opcode for that?)
> 
> kans1   OSClisten giosc1, "/freq1", "f", kvalin
> printk2 kvalin,0
> printk2 kans1,10
> 
> ;	start of extrapolation
> 
> ;if (kvalin == kvalinold) then
> if (kans1 == 0) then
> 	kcount = kcount + 1
> 	kval = kval + kdelta
> else	;	a change in input
> 	;printk2 kcount,20
> 	kdelta = (kvalin - kvalinold)/kcount
> 	;printk2 kdelta,30
> 	kvalinold = kvalin
> 	kcount = 1
> 	kval = kvalin
> endif
> 
> Richard
> 
> 
> 
> --
> View this message in context: http://csound.1045644.n5.nabble.com/kans-parameter-of-OSClisten-sometimes-does-not-change-data-does-change-tp5737393p5737401.html
> Sent from the Csound - General mailing list archive at Nabble.com.
> 
> 
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
> 
> 
>