Csound Csound-dev Csound-tekno Search About

[Cs-dev] tabw not writing correctly to non-pow-of-2 tables

Date2010-11-19 09:36
Fromjoachim heintz
Subject[Cs-dev] tabw not writing correctly to non-pow-of-2 tables
AttachmentsBild 2.png  tabw.csd  None  None  
i wanted to write a UDO for recording audio input into a function  
table. tabw should be the appropriate opcode because it does not  
require a power-of-two table.
but i heard a terrible noise at certain table sizes. in short, it  
looks like tabw does not work properly for non-pow-of-2 tables.
this is very sad, because there is no other possibility for flexible  
live recording (like Max' record~ or PD's tabwrite~ objects) except  
via tabw, as far as i see.
a .csd is attached. you can hear the noise when the third buffer is  
read. 3 audio files are written to show the results; the third one  
("giBuf3.wav") shows irregular (but symmetric?!?) jumps to the zero  
axis:


i will be happy if i am wrong. i am on osx 10.5 (csound 5.12).

	joachim



Date2010-11-19 13:51
FromVictor Lazzarini
SubjectRe: [Cs-dev] tabw not writing correctly to non-pow-of-2 tables
I see the problem, will investigate.

Victor
On 19 Nov 2010, at 09:36, joachim heintz wrote:

> 


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2010-11-19 16:39
FromVictor Lazzarini
SubjectRe: [Cs-dev] tabw not writing correctly to non-pow-of-2 tables
This seems to be related to the index variable to tabw, rather than a  
bug with it (I checked the code and it
does not appear to have any problems. For instance if you set ksmps=1  
and use this instrument

instr 1 ;writes values to buffers
prints	 "Writing to buffer %d!\n", p4
apos init 0
ilen	 =	 ftlen(p4)
ain	 oscils	 1, 400, 0
apos = apos + 1
kpos downsamp apos
if kpos >= ilen then ;don't start from the beginning
turnoff
endif
tabw	 ain, apos, p4
endin

or even (with any ksmps):

instr 1 ;writes values to buffers
prints	 "Writing to buffer %d!\n", p4
ilen	 =	 ftlen(p4)
ain	 oscils	 1, 400, 0
apos line 0, ilen/sr, ilen
kpos downsamp apos
if kpos >= ilen then ;don't start from the beginning
turnoff
endif
tabw	 ain, apos, p4
endin

then there is no problem. I have not found out exactly why the phasor  
is not doing the job properly,
but I think it might be with the way it calculates the sampling  
increment, some rounding problem.

Victor

On 19 Nov 2010, at 13:51, Victor Lazzarini wrote:

> I see the problem, will investigate.
>
> Victor
> On 19 Nov 2010, at 09:36, joachim heintz wrote:
>
>> 
>
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
> Spend less time writing and  rewriting code and more time creating  
> great
> experiences on the web. Be a part of the beta today
> http://p.sf.net/sfu/msIE9-sfdev2dev
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2010-11-19 18:27
Fromjoachim heintz
SubjectRe: [Cs-dev] tabw not writing correctly to non-pow-of-2 tables
thanks for having such a quick look, victor. these are good news, and  
i can confirm that it works if i use raw index values. so this is a  
way to sail round this problem.
should we write a warning in the manual, that imode=1 seems to bring  
problems? for table instead of tab, the phasor works perfectly.

	joachim


Am 19.11.2010 um 17:39 schrieb Victor Lazzarini:

> This seems to be related to the index variable to tabw, rather than a
> bug with it (I checked the code and it
> does not appear to have any problems. For instance if you set ksmps=1
> and use this instrument
>
> instr 1 ;writes values to buffers
> prints	 "Writing to buffer %d!\n", p4
> apos init 0
> ilen	 =	 ftlen(p4)
> ain	 oscils	 1, 400, 0
> apos = apos + 1
> kpos downsamp apos
> if kpos >= ilen then ;don't start from the beginning
> turnoff
> endif
> tabw	 ain, apos, p4
> endin
>
> or even (with any ksmps):
>
> instr 1 ;writes values to buffers
> prints	 "Writing to buffer %d!\n", p4
> ilen	 =	 ftlen(p4)
> ain	 oscils	 1, 400, 0
> apos line 0, ilen/sr, ilen
> kpos downsamp apos
> if kpos >= ilen then ;don't start from the beginning
> turnoff
> endif
> tabw	 ain, apos, p4
> endin
>
> then there is no problem. I have not found out exactly why the phasor
> is not doing the job properly,
> but I think it might be with the way it calculates the sampling
> increment, some rounding problem.
>
> Victor
>
> On 19 Nov 2010, at 13:51, Victor Lazzarini wrote:
>
>> I see the problem, will investigate.
>>
>> Victor
>> On 19 Nov 2010, at 09:36, joachim heintz wrote:
>>
>>> 
>>
>>
>> ------------------------------------------------------------------------------
>> Beautiful is writing same markup. Internet Explorer 9 supports
>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
>> Spend less time writing and  rewriting code and more time creating
>> great
>> experiences on the web. Be a part of the beta today
>> http://p.sf.net/sfu/msIE9-sfdev2dev
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
> Spend less time writing and  rewriting code and more time creating  
> great
> experiences on the web. Be a part of the beta today
> http://p.sf.net/sfu/msIE9-sfdev2dev
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2010-11-19 19:12
FromVictor Lazzarini
SubjectRe: [Cs-dev] tabw not writing correctly to non-pow-of-2 tables
Attachmentstabw.csd  None  None  
No, I don't think that is the problem. I have tested with normalised  
indexes and it appears to be OK. There is something
funny though, with the way your table-to-file works. See the attached  
CSD, the output is OK and so is the reading,
but the file that is written from the table has some zero samples in  
it (as before). However, I'm quite sure the table
is OK (as the output is OK). I'm using normalised indexing.

Victor




On 19 Nov 2010, at 18:27, joachim heintz wrote:

> thanks for having such a quick look, victor. these are good news, and
> i can confirm that it works if i use raw index values. so this is a
> way to sail round this problem.
> should we write a warning in the manual, that imode=1 seems to bring
> problems? for table instead of tab, the phasor works perfectly.
>
> 	joachim
>
>
> Am 19.11.2010 um 17:39 schrieb Victor Lazzarini:
>
>> This seems to be related to the index variable to tabw, rather than a
>> bug with it (I checked the code and it
>> does not appear to have any problems. For instance if you set ksmps=1
>> and use this instrument
>>
>> instr 1 ;writes values to buffers
>> prints	 "Writing to buffer %d!\n", p4
>> apos init 0
>> ilen	 =	 ftlen(p4)
>> ain	 oscils	 1, 400, 0
>> apos = apos + 1
>> kpos downsamp apos
>> if kpos >= ilen then ;don't start from the beginning
>> turnoff
>> endif
>> tabw	 ain, apos, p4
>> endin
>>
>> or even (with any ksmps):
>>
>> instr 1 ;writes values to buffers
>> prints	 "Writing to buffer %d!\n", p4
>> ilen	 =	 ftlen(p4)
>> ain	 oscils	 1, 400, 0
>> apos line 0, ilen/sr, ilen
>> kpos downsamp apos
>> if kpos >= ilen then ;don't start from the beginning
>> turnoff
>> endif
>> tabw	 ain, apos, p4
>> endin
>>
>> then there is no problem. I have not found out exactly why the phasor
>> is not doing the job properly,
>> but I think it might be with the way it calculates the sampling
>> increment, some rounding problem.
>>
>> Victor
>>
>> On 19 Nov 2010, at 13:51, Victor Lazzarini wrote:
>>
>>> I see the problem, will investigate.
>>>
>>> Victor
>>> On 19 Nov 2010, at 09:36, joachim heintz wrote:
>>>
>>>> 
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Beautiful is writing same markup. Internet Explorer 9 supports
>>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
>>> Spend less time writing and  rewriting code and more time creating
>>> great
>>> experiences on the web. Be a part of the beta today
>>> http://p.sf.net/sfu/msIE9-sfdev2dev
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>>
>> ------------------------------------------------------------------------------
>> Beautiful is writing same markup. Internet Explorer 9 supports
>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
>> Spend less time writing and  rewriting code and more time creating
>> great
>> experiences on the web. Be a part of the beta today
>> http://p.sf.net/sfu/msIE9-sfdev2dev
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
> Spend less time writing and  rewriting code and more time creating  
> great
> experiences on the web. Be a part of the beta today
> http://p.sf.net/sfu/msIE9-sfdev2dev
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


Date2010-11-19 20:40
Fromjoachim heintz
SubjectRe: [Cs-dev] tabw not writing correctly to non-pow-of-2 tables
Attachmentstabw3.csd  None  None  
but if you replace the line
apos line 0,(ilen/sr),1
with the line
apos	 phasor	 1/(ftlen(p4)/sr)
then you hear the distorted signal again. so it must have something to  
do with the phasor as index, doesn't it?

	joachim





Am 19.11.2010 um 20:12 schrieb Victor Lazzarini:

> No, I don't think that is the problem. I have tested with normalised  
> indexes and it appears to be OK. There is something
> funny though, with the way your table-to-file works. See the  
> attached CSD, the output is OK and so is the reading,
> but the file that is written from the table has some zero samples in  
> it (as before). However, I'm quite sure the table
> is OK (as the output is OK). I'm using normalised indexing.
>
> Victor
> 
>
>
>
> On 19 Nov 2010, at 18:27, joachim heintz wrote:
>
>> thanks for having such a quick look, victor. these are good news, and
>> i can confirm that it works if i use raw index values. so this is a
>> way to sail round this problem.
>> should we write a warning in the manual, that imode=1 seems to bring
>> problems? for table instead of tab, the phasor works perfectly.
>>
>> 	joachim
>>
>>
>> Am 19.11.2010 um 17:39 schrieb Victor Lazzarini:
>>
>>> This seems to be related to the index variable to tabw, rather  
>>> than a
>>> bug with it (I checked the code and it
>>> does not appear to have any problems. For instance if you set  
>>> ksmps=1
>>> and use this instrument
>>>
>>> instr 1 ;writes values to buffers
>>> prints	 "Writing to buffer %d!\n", p4
>>> apos init 0
>>> ilen	 =	 ftlen(p4)
>>> ain	 oscils	 1, 400, 0
>>> apos = apos + 1
>>> kpos downsamp apos
>>> if kpos >= ilen then ;don't start from the beginning
>>> turnoff
>>> endif
>>> tabw	 ain, apos, p4
>>> endin
>>>
>>> or even (with any ksmps):
>>>
>>> instr 1 ;writes values to buffers
>>> prints	 "Writing to buffer %d!\n", p4
>>> ilen	 =	 ftlen(p4)
>>> ain	 oscils	 1, 400, 0
>>> apos line 0, ilen/sr, ilen
>>> kpos downsamp apos
>>> if kpos >= ilen then ;don't start from the beginning
>>> turnoff
>>> endif
>>> tabw	 ain, apos, p4
>>> endin
>>>
>>> then there is no problem. I have not found out exactly why the  
>>> phasor
>>> is not doing the job properly,
>>> but I think it might be with the way it calculates the sampling
>>> increment, some rounding problem.
>>>
>>> Victor
>>>
>>> On 19 Nov 2010, at 13:51, Victor Lazzarini wrote:
>>>
>>>> I see the problem, will investigate.
>>>>
>>>> Victor
>>>> On 19 Nov 2010, at 09:36, joachim heintz wrote:
>>>>
>>>>> 
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Beautiful is writing same markup. Internet Explorer 9 supports
>>>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
>>>> Spend less time writing and  rewriting code and more time creating
>>>> great
>>>> experiences on the web. Be a part of the beta today
>>>> http://p.sf.net/sfu/msIE9-sfdev2dev
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Beautiful is writing same markup. Internet Explorer 9 supports
>>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
>>> Spend less time writing and  rewriting code and more time creating
>>> great
>>> experiences on the web. Be a part of the beta today
>>> http://p.sf.net/sfu/msIE9-sfdev2dev
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> Beautiful is writing same markup. Internet Explorer 9 supports
>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
>> Spend less time writing and  rewriting code and more time creating  
>> great
>> experiences on the web. Be a part of the beta today
>> http://p.sf.net/sfu/msIE9-sfdev2dev
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
> Spend less time writing and  rewriting code and more time creating  
> great
> experiences on the web. Be a part of the beta today
> http://p.sf.net/sfu/msIE9-sfdev2dev_______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


Date2010-11-19 21:16
FromVictor Lazzarini
SubjectRe: [Cs-dev] tabw not writing correctly to non-pow-of-2 tables
yes, I think so. The problem is the phasor, but not with normalised  
indexing. I can't exactly pinpoint what is going wrong there. It's  
possible that
the phasor is not giving integral indexes and that is causing trouble  
in truncation.
I'll keep looking.

Victor

On 19 Nov 2010, at 20:40, joachim heintz wrote:

> but if you replace the line
> apos line 0,(ilen/sr),1
> with the line
> apos	 phasor	 1/(ftlen(p4)/sr)
> then you hear the distorted signal again. so it must have something  
> to do with the phasor as index, doesn't it?
>
> 	joachim
>
> 
>
>
>
> Am 19.11.2010 um 20:12 schrieb Victor Lazzarini:
>
>> No, I don't think that is the problem. I have tested with  
>> normalised indexes and it appears to be OK. There is something
>> funny though, with the way your table-to-file works. See the  
>> attached CSD, the output is OK and so is the reading,
>> but the file that is written from the table has some zero samples  
>> in it (as before). However, I'm quite sure the table
>> is OK (as the output is OK). I'm using normalised indexing.
>>
>> Victor
>> 
>>
>>
>>
>> On 19 Nov 2010, at 18:27, joachim heintz wrote:
>>
>>> thanks for having such a quick look, victor. these are good news,  
>>> and
>>> i can confirm that it works if i use raw index values. so this is a
>>> way to sail round this problem.
>>> should we write a warning in the manual, that imode=1 seems to bring
>>> problems? for table instead of tab, the phasor works perfectly.
>>>
>>> 	joachim
>>>
>>>
>>> Am 19.11.2010 um 17:39 schrieb Victor Lazzarini:
>>>
>>>> This seems to be related to the index variable to tabw, rather  
>>>> than a
>>>> bug with it (I checked the code and it
>>>> does not appear to have any problems. For instance if you set  
>>>> ksmps=1
>>>> and use this instrument
>>>>
>>>> instr 1 ;writes values to buffers
>>>> prints	 "Writing to buffer %d!\n", p4
>>>> apos init 0
>>>> ilen	 =	 ftlen(p4)
>>>> ain	 oscils	 1, 400, 0
>>>> apos = apos + 1
>>>> kpos downsamp apos
>>>> if kpos >= ilen then ;don't start from the beginning
>>>> turnoff
>>>> endif
>>>> tabw	 ain, apos, p4
>>>> endin
>>>>
>>>> or even (with any ksmps):
>>>>
>>>> instr 1 ;writes values to buffers
>>>> prints	 "Writing to buffer %d!\n", p4
>>>> ilen	 =	 ftlen(p4)
>>>> ain	 oscils	 1, 400, 0
>>>> apos line 0, ilen/sr, ilen
>>>> kpos downsamp apos
>>>> if kpos >= ilen then ;don't start from the beginning
>>>> turnoff
>>>> endif
>>>> tabw	 ain, apos, p4
>>>> endin
>>>>
>>>> then there is no problem. I have not found out exactly why the  
>>>> phasor
>>>> is not doing the job properly,
>>>> but I think it might be with the way it calculates the sampling
>>>> increment, some rounding problem.
>>>>
>>>> Victor
>>>>
>>>> On 19 Nov 2010, at 13:51, Victor Lazzarini wrote:
>>>>
>>>>> I see the problem, will investigate.
>>>>>
>>>>> Victor
>>>>> On 19 Nov 2010, at 09:36, joachim heintz wrote:
>>>>>
>>>>>> 
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Beautiful is writing same markup. Internet Explorer 9 supports
>>>>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
>>>>> Spend less time writing and  rewriting code and more time creating
>>>>> great
>>>>> experiences on the web. Be a part of the beta today
>>>>> http://p.sf.net/sfu/msIE9-sfdev2dev
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Beautiful is writing same markup. Internet Explorer 9 supports
>>>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
>>>> Spend less time writing and  rewriting code and more time creating
>>>> great
>>>> experiences on the web. Be a part of the beta today
>>>> http://p.sf.net/sfu/msIE9-sfdev2dev
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Beautiful is writing same markup. Internet Explorer 9 supports
>>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
>>> Spend less time writing and  rewriting code and more time creating  
>>> great
>>> experiences on the web. Be a part of the beta today
>>> http://p.sf.net/sfu/msIE9-sfdev2dev
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>> ------------------------------------------------------------------------------
>> Beautiful is writing same markup. Internet Explorer 9 supports
>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
>> Spend less time writing and  rewriting code and more time creating  
>> great
>> experiences on the web. Be a part of the beta today
>> http://p.sf.net/sfu/msIE9-sfdev2dev_______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
> Spend less time writing and  rewriting code and more time creating  
> great
> experiences on the web. Be a part of the beta today
> http://p.sf.net/sfu/msIE9-sfdev2dev_______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2010-11-19 22:04
FromVictor Lazzarini
SubjectRe: [Cs-dev] tabw not writing correctly to non-pow-of-2 tables
I think I know what the matter is. Because of truncating, it's not  
guaranteed that the
phasor will always provide consecutive indexes for the table writing,  
so it might jump one pos now
and then, and overwrite as well.  It somehow works with pow-of-two and  
there might be numerical reasons
for this.

I think a simple rounding of the index should take care of this problem:

apos	 phasor	 1/(ilen/sr)
apos = round(apos*ilen)
tabw	 ain, apos, p4

it seems to do the trick.

Victor
On 19 Nov 2010, at 21:16, Victor Lazzarini wrote:

> yes, I think so. The problem is the phasor, but not with normalised
> indexing. I can't exactly pinpoint what is going wrong there. It's
> possible that
> the phasor is not giving integral indexes and that is causing trouble
> in truncation.
> I'll keep looking.
>
> Victor
>
> On 19 Nov 2010, at 20:40, joachim heintz wrote:
>
>> but if you replace the line
>> apos line 0,(ilen/sr),1
>> with the line
>> apos	 phasor	 1/(ftlen(p4)/sr)
>> then you hear the distorted signal again. so it must have something
>> to do with the phasor as index, doesn't it?
>>
>> 	joachim
>>
>> 
>>
>>
>>
>> Am 19.11.2010 um 20:12 schrieb Victor Lazzarini:
>>
>>> No, I don't think that is the problem. I have tested with
>>> normalised indexes and it appears to be OK. There is something
>>> funny though, with the way your table-to-file works. See the
>>> attached CSD, the output is OK and so is the reading,
>>> but the file that is written from the table has some zero samples
>>> in it (as before). However, I'm quite sure the table
>>> is OK (as the output is OK). I'm using normalised indexing.
>>>
>>> Victor
>>> 
>>>
>>>
>>>
>>> On 19 Nov 2010, at 18:27, joachim heintz wrote:
>>>
>>>> thanks for having such a quick look, victor. these are good news,
>>>> and
>>>> i can confirm that it works if i use raw index values. so this is a
>>>> way to sail round this problem.
>>>> should we write a warning in the manual, that imode=1 seems to  
>>>> bring
>>>> problems? for table instead of tab, the phasor works perfectly.
>>>>
>>>> 	joachim
>>>>
>>>>
>>>> Am 19.11.2010 um 17:39 schrieb Victor Lazzarini:
>>>>
>>>>> This seems to be related to the index variable to tabw, rather
>>>>> than a
>>>>> bug with it (I checked the code and it
>>>>> does not appear to have any problems. For instance if you set
>>>>> ksmps=1
>>>>> and use this instrument
>>>>>
>>>>> instr 1 ;writes values to buffers
>>>>> prints	 "Writing to buffer %d!\n", p4
>>>>> apos init 0
>>>>> ilen	 =	 ftlen(p4)
>>>>> ain	 oscils	 1, 400, 0
>>>>> apos = apos + 1
>>>>> kpos downsamp apos
>>>>> if kpos >= ilen then ;don't start from the beginning
>>>>> turnoff
>>>>> endif
>>>>> tabw	 ain, apos, p4
>>>>> endin
>>>>>
>>>>> or even (with any ksmps):
>>>>>
>>>>> instr 1 ;writes values to buffers
>>>>> prints	 "Writing to buffer %d!\n", p4
>>>>> ilen	 =	 ftlen(p4)
>>>>> ain	 oscils	 1, 400, 0
>>>>> apos line 0, ilen/sr, ilen
>>>>> kpos downsamp apos
>>>>> if kpos >= ilen then ;don't start from the beginning
>>>>> turnoff
>>>>> endif
>>>>> tabw	 ain, apos, p4
>>>>> endin
>>>>>
>>>>> then there is no problem. I have not found out exactly why the
>>>>> phasor
>>>>> is not doing the job properly,
>>>>> but I think it might be with the way it calculates the sampling
>>>>> increment, some rounding problem.
>>>>>
>>>>> Victor
>>>>>
>>>>> On 19 Nov 2010, at 13:51, Victor Lazzarini wrote:
>>>>>
>>>>>> I see the problem, will investigate.
>>>>>>
>>>>>> Victor
>>>>>> On 19 Nov 2010, at 09:36, joachim heintz wrote:
>>>>>>
>>>>>>> 
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Beautiful is writing same markup. Internet Explorer 9 supports
>>>>>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 &  
>>>>>> L3.
>>>>>> Spend less time writing and  rewriting code and more time  
>>>>>> creating
>>>>>> great
>>>>>> experiences on the web. Be a part of the beta today
>>>>>> http://p.sf.net/sfu/msIE9-sfdev2dev
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Beautiful is writing same markup. Internet Explorer 9 supports
>>>>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
>>>>> Spend less time writing and  rewriting code and more time creating
>>>>> great
>>>>> experiences on the web. Be a part of the beta today
>>>>> http://p.sf.net/sfu/msIE9-sfdev2dev
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Beautiful is writing same markup. Internet Explorer 9 supports
>>>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
>>>> Spend less time writing and  rewriting code and more time creating
>>>> great
>>>> experiences on the web. Be a part of the beta today
>>>> http://p.sf.net/sfu/msIE9-sfdev2dev
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>> ------------------------------------------------------------------------------
>>> Beautiful is writing same markup. Internet Explorer 9 supports
>>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
>>> Spend less time writing and  rewriting code and more time creating
>>> great
>>> experiences on the web. Be a part of the beta today
>>> http://p.sf.net/sfu/msIE9-sfdev2dev_______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>> ------------------------------------------------------------------------------
>> Beautiful is writing same markup. Internet Explorer 9 supports
>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
>> Spend less time writing and  rewriting code and more time creating
>> great
>> experiences on the web. Be a part of the beta today
>> http://p.sf.net/sfu/msIE9-sfdev2dev_______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
> Spend less time writing and  rewriting code and more time creating  
> great
> experiences on the web. Be a part of the beta today
> http://p.sf.net/sfu/msIE9-sfdev2dev
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2010-11-20 13:48
FromRory Walsh
SubjectRe: [Cs-dev] tabw not writing correctly to non-pow-of-2 tables
perhaps a note should be put into the manual about this.

On 19 November 2010 22:04, Victor Lazzarini  wrote:
> I think I know what the matter is. Because of truncating, it's not
> guaranteed that the
> phasor will always provide consecutive indexes for the table writing,
> so it might jump one pos now
> and then, and overwrite as well.  It somehow works with pow-of-two and
> there might be numerical reasons
> for this.
>
> I think a simple rounding of the index should take care of this problem:
>
> apos     phasor  1/(ilen/sr)
> apos = round(apos*ilen)
> tabw     ain, apos, p4
>
> it seems to do the trick.
>
> Victor
> On 19 Nov 2010, at 21:16, Victor Lazzarini wrote:
>
>> yes, I think so. The problem is the phasor, but not with normalised
>> indexing. I can't exactly pinpoint what is going wrong there. It's
>> possible that
>> the phasor is not giving integral indexes and that is causing trouble
>> in truncation.
>> I'll keep looking.
>>
>> Victor
>>
>> On 19 Nov 2010, at 20:40, joachim heintz wrote:
>>
>>> but if you replace the line
>>> apos line 0,(ilen/sr),1
>>> with the line
>>> apos  phasor  1/(ftlen(p4)/sr)
>>> then you hear the distorted signal again. so it must have something
>>> to do with the phasor as index, doesn't it?
>>>
>>>      joachim
>>>
>>> 
>>>
>>>
>>>
>>> Am 19.11.2010 um 20:12 schrieb Victor Lazzarini:
>>>
>>>> No, I don't think that is the problem. I have tested with
>>>> normalised indexes and it appears to be OK. There is something
>>>> funny though, with the way your table-to-file works. See the
>>>> attached CSD, the output is OK and so is the reading,
>>>> but the file that is written from the table has some zero samples
>>>> in it (as before). However, I'm quite sure the table
>>>> is OK (as the output is OK). I'm using normalised indexing.
>>>>
>>>> Victor
>>>> 
>>>>
>>>>
>>>>
>>>> On 19 Nov 2010, at 18:27, joachim heintz wrote:
>>>>
>>>>> thanks for having such a quick look, victor. these are good news,
>>>>> and
>>>>> i can confirm that it works if i use raw index values. so this is a
>>>>> way to sail round this problem.
>>>>> should we write a warning in the manual, that imode=1 seems to
>>>>> bring
>>>>> problems? for table instead of tab, the phasor works perfectly.
>>>>>
>>>>>    joachim
>>>>>
>>>>>
>>>>> Am 19.11.2010 um 17:39 schrieb Victor Lazzarini:
>>>>>
>>>>>> This seems to be related to the index variable to tabw, rather
>>>>>> than a
>>>>>> bug with it (I checked the code and it
>>>>>> does not appear to have any problems. For instance if you set
>>>>>> ksmps=1
>>>>>> and use this instrument
>>>>>>
>>>>>> instr 1 ;writes values to buffers
>>>>>> prints     "Writing to buffer %d!\n", p4
>>>>>> apos init 0
>>>>>> ilen       =       ftlen(p4)
>>>>>> ain        oscils  1, 400, 0
>>>>>> apos = apos + 1
>>>>>> kpos downsamp apos
>>>>>> if kpos >= ilen then ;don't start from the beginning
>>>>>> turnoff
>>>>>> endif
>>>>>> tabw       ain, apos, p4
>>>>>> endin
>>>>>>
>>>>>> or even (with any ksmps):
>>>>>>
>>>>>> instr 1 ;writes values to buffers
>>>>>> prints     "Writing to buffer %d!\n", p4
>>>>>> ilen       =       ftlen(p4)
>>>>>> ain        oscils  1, 400, 0
>>>>>> apos line 0, ilen/sr, ilen
>>>>>> kpos downsamp apos
>>>>>> if kpos >= ilen then ;don't start from the beginning
>>>>>> turnoff
>>>>>> endif
>>>>>> tabw       ain, apos, p4
>>>>>> endin
>>>>>>
>>>>>> then there is no problem. I have not found out exactly why the
>>>>>> phasor
>>>>>> is not doing the job properly,
>>>>>> but I think it might be with the way it calculates the sampling
>>>>>> increment, some rounding problem.
>>>>>>
>>>>>> Victor
>>>>>>
>>>>>> On 19 Nov 2010, at 13:51, Victor Lazzarini wrote:
>>>>>>
>>>>>>> I see the problem, will investigate.
>>>>>>>
>>>>>>> Victor
>>>>>>> On 19 Nov 2010, at 09:36, joachim heintz wrote:
>>>>>>>
>>>>>>>> 
>>>>>>>
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> Beautiful is writing same markup. Internet Explorer 9 supports
>>>>>>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 &
>>>>>>> L3.
>>>>>>> Spend less time writing and  rewriting code and more time
>>>>>>> creating
>>>>>>> great
>>>>>>> experiences on the web. Be a part of the beta today
>>>>>>> http://p.sf.net/sfu/msIE9-sfdev2dev
>>>>>>> _______________________________________________
>>>>>>> Csound-devel mailing list
>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Beautiful is writing same markup. Internet Explorer 9 supports
>>>>>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
>>>>>> Spend less time writing and  rewriting code and more time creating
>>>>>> great
>>>>>> experiences on the web. Be a part of the beta today
>>>>>> http://p.sf.net/sfu/msIE9-sfdev2dev
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Beautiful is writing same markup. Internet Explorer 9 supports
>>>>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
>>>>> Spend less time writing and  rewriting code and more time creating
>>>>> great
>>>>> experiences on the web. Be a part of the beta today
>>>>> http://p.sf.net/sfu/msIE9-sfdev2dev
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Beautiful is writing same markup. Internet Explorer 9 supports
>>>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
>>>> Spend less time writing and  rewriting code and more time creating
>>>> great
>>>> experiences on the web. Be a part of the beta today
>>>> http://p.sf.net/sfu/msIE9-sfdev2dev_______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>> ------------------------------------------------------------------------------
>>> Beautiful is writing same markup. Internet Explorer 9 supports
>>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
>>> Spend less time writing and  rewriting code and more time creating
>>> great
>>> experiences on the web. Be a part of the beta today
>>> http://p.sf.net/sfu/msIE9-sfdev2dev_______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>>
>> ------------------------------------------------------------------------------
>> Beautiful is writing same markup. Internet Explorer 9 supports
>> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
>> Spend less time writing and  rewriting code and more time creating
>> great
>> experiences on the web. Be a part of the beta today
>> http://p.sf.net/sfu/msIE9-sfdev2dev
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
> Spend less time writing and  rewriting code and more time creating great
> experiences on the web. Be a part of the beta today
> http://p.sf.net/sfu/msIE9-sfdev2dev
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net