Csound Csound-dev Csound-tekno Search About

[Csnd] reason for adding one to f-table size

Date2010-01-11 21:43
FromEmerson Aagaard
Subject[Csnd] reason for adding one to f-table size
I was just curious (and I was sure someone could answer this question in no time on here) what the significance is of adding one to the size of an f-table?
I've looked through the manual and have been reading the Csound book for some time now, and I don't remember ever seeing clear explanation for this?

Thanks much,
Emerson

Date2010-01-11 22:04
FromAdam
Subject[Csnd] Re: reason for adding one to f-table size
AttachmentsNone  

Date2010-01-11 22:12
FromVictor Lazzarini
Subject[Csnd] Re: Re: reason for adding one to f-table size
I think it's better to explain like this:

Tables have always one extra point, known as the guard point. The size  
of the table is used as a code to tell Csound how to fill this guard- 
point. If the size is exactly power-of-two, then the guard point  
contains a copy of the first point on the table. if the size is power- 
of-two plus one, Csound will extend the contour of the function stored  
in the table for one extra point.

Victor


On 11 Jan 2010, at 22:04, Adam wrote:

>
> Basically its for the interpolating oscillators. Such as;
>
> http://www.csounds.com/manual/html/oscili.html
>
> There may be a clearer explanation elsewhere in the
> manual,
>
> This below is a section copied from here;
>
> http://www.csounds.com/manual/html/f.html
>
>>>
> For arrays whose length is a power of 2, space allocation always  
> provides for
> 2n points plus an additional guard point. The guard point value,  
> used during
> interpolated lookup, can be automatically set to reflect the table's  
> purpose:
> If size is an exact power of 2, the guard point will be a copy of  
> the first
> point; this is appropriate for interpolated wrap-around lookup as in  
> oscili,
> etc., and should even be used for non-interpolating oscil for safe
> consistency. If size is set to 2 n + 1, the guard point value  
> automatically
> extends the contour of table values; this is appropriate for single- 
> scan
> functions such in envplx, oscil1, oscil1i, etc.
>>>
>
> On Tuesday 12 January 2010 10:43 am, Emerson Aagaard wrote:
>> I was just curious (and I was sure someone could answer this  
>> question in no
>> time on here) what the significance is of adding one to the size of  
>> an
>> f-table?
>> I've looked through the manual and have been reading the Csound  
>> book for
>> some time now, and I don't remember ever seeing clear explanation  
>> for this?
>>
>> Thanks much,
>> Emerson
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
>> "unsubscribe
>> csound"
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
> "unsubscribe csound"



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

Date2010-01-11 22:35
Fromjoachim heintz
Subject[Csnd] Re: Re: Re: reason for adding one to f-table size
And is this extra point being read by opcodes like oscili?
Then there must be a slight discontinuity when the size is exactly pow- 
of-2, as there are two equal values following each other (the extra  
one and the first one), for instance at a pure sine wave, right?
So the statement f 1 0 1025 10 1 is simply better than f 1 0 1024 10 1?

	joachim



Am 11.01.2010 um 23:12 schrieb Victor Lazzarini:

> I think it's better to explain like this:
>
> Tables have always one extra point, known as the guard point. The  
> size of the table is used as a code to tell Csound how to fill this  
> guard-point. If the size is exactly power-of-two, then the guard  
> point contains a copy of the first point on the table. if the size  
> is power-of-two plus one, Csound will extend the contour of the  
> function stored in the table for one extra point.
>
> Victor
>
>
> On 11 Jan 2010, at 22:04, Adam wrote:
>
>>
>> Basically its for the interpolating oscillators. Such as;
>>
>> http://www.csounds.com/manual/html/oscili.html
>>
>> There may be a clearer explanation elsewhere in the
>> manual,
>>
>> This below is a section copied from here;
>>
>> http://www.csounds.com/manual/html/f.html
>>
>>>>
>> For arrays whose length is a power of 2, space allocation always  
>> provides for
>> 2n points plus an additional guard point. The guard point value,  
>> used during
>> interpolated lookup, can be automatically set to reflect the  
>> table's purpose:
>> If size is an exact power of 2, the guard point will be a copy of  
>> the first
>> point; this is appropriate for interpolated wrap-around lookup as  
>> in oscili,
>> etc., and should even be used for non-interpolating oscil for safe
>> consistency. If size is set to 2 n + 1, the guard point value  
>> automatically
>> extends the contour of table values; this is appropriate for single- 
>> scan
>> functions such in envplx, oscil1, oscil1i, etc.
>>>>
>>
>> On Tuesday 12 January 2010 10:43 am, Emerson Aagaard wrote:
>>> I was just curious (and I was sure someone could answer this  
>>> question in no
>>> time on here) what the significance is of adding one to the size  
>>> of an
>>> f-table?
>>> I've looked through the manual and have been reading the Csound  
>>> book for
>>> some time now, and I don't remember ever seeing clear explanation  
>>> for this?
>>>
>>> Thanks much,
>>> Emerson
>>>
>>> Send bugs reports to this list.
>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
>>> "unsubscribe
>>> csound"
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
>> "unsubscribe csound"
>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
> "unsubscribe csound"
>



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

Date2010-01-11 22:58
FromVictor Lazzarini
Subject[Csnd] Re: Re: Re: Re: reason for adding one to f-table size
It depends on what you will be using it for.As a rule of thumb,  for  
wrap around use 1024 etc, for single shot 1025 etc.

Victor
On 11 Jan 2010, at 22:35, joachim heintz wrote:

> And is this extra point being read by opcodes like oscili?
> Then there must be a slight discontinuity when the size is exactly  
> pow-of-2, as there are two equal values following each other (the  
> extra one and the first one), for instance at a pure sine wave, right?
> So the statement f 1 0 1025 10 1 is simply better than f 1 0 1024 10  
> 1?
>
> 	joachim
>
>
>
> Am 11.01.2010 um 23:12 schrieb Victor Lazzarini:
>
>> I think it's better to explain like this:
>>
>> Tables have always one extra point, known as the guard point. The  
>> size of the table is used as a code to tell Csound how to fill this  
>> guard-point. If the size is exactly power-of-two, then the guard  
>> point contains a copy of the first point on the table. if the size  
>> is power-of-two plus one, Csound will extend the contour of the  
>> function stored in the table for one extra point.
>>
>> Victor
>>
>>
>> On 11 Jan 2010, at 22:04, Adam wrote:
>>
>>>
>>> Basically its for the interpolating oscillators. Such as;
>>>
>>> http://www.csounds.com/manual/html/oscili.html
>>>
>>> There may be a clearer explanation elsewhere in the
>>> manual,
>>>
>>> This below is a section copied from here;
>>>
>>> http://www.csounds.com/manual/html/f.html
>>>
>>>>>
>>> For arrays whose length is a power of 2, space allocation always  
>>> provides for
>>> 2n points plus an additional guard point. The guard point value,  
>>> used during
>>> interpolated lookup, can be automatically set to reflect the  
>>> table's purpose:
>>> If size is an exact power of 2, the guard point will be a copy of  
>>> the first
>>> point; this is appropriate for interpolated wrap-around lookup as  
>>> in oscili,
>>> etc., and should even be used for non-interpolating oscil for safe
>>> consistency. If size is set to 2 n + 1, the guard point value  
>>> automatically
>>> extends the contour of table values; this is appropriate for  
>>> single-scan
>>> functions such in envplx, oscil1, oscil1i, etc.
>>>>>
>>>
>>> On Tuesday 12 January 2010 10:43 am, Emerson Aagaard wrote:
>>>> I was just curious (and I was sure someone could answer this  
>>>> question in no
>>>> time on here) what the significance is of adding one to the size  
>>>> of an
>>>> f-table?
>>>> I've looked through the manual and have been reading the Csound  
>>>> book for
>>>> some time now, and I don't remember ever seeing clear explanation  
>>>> for this?
>>>>
>>>> Thanks much,
>>>> Emerson
>>>>
>>>> Send bugs reports to this list.
>>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
>>>> "unsubscribe
>>>> csound"
>>>
>>>
>>> Send bugs reports to this list.
>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
>>> "unsubscribe csound"
>>
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
>> "unsubscribe csound"
>>
>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
> "unsubscribe csound"



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

Date2010-01-11 23:13
FromRichard Dobson
Subject[Csnd] Re: Re: Re: Re: reason for adding one to f-table size
No, it is done simply to streamline the linear interpolation code (saves 
a conditional test and possible wraparound index computation).

Note that in (say) a sinusoid cycle computed over 512 samples, table[0] 
is ~not~ the same as table[511].

Richard Dobson


joachim heintz wrote:
> And is this extra point being read by opcodes like oscili?
> Then there must be a slight discontinuity when the size is exactly 
> pow-of-2, as there are two equal values following each other (the extra 
> one and the first one), for instance at a pure sine wave, right?
> So the statement f 1 0 1025 10 1 is simply better than f 1 0 1024 10 1?
> 
>     joachim
> 
> 




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

Date2010-01-12 00:06
FrommoleculeColony
Subject[Csnd] Re: Re: Re: Re: re ason for adding one to f-table size
lol, C is such a user-friendly language.  starts counting at 0 and ends one
below where humans count...

there is this joke: the C language has a built-in optimizer called the C
programmer

lol

Date2010-01-12 07:34
Fromjoachim heintz
Subject[Csnd] Re: Re: Re: Re: Re: reason for adding one to f-table size
Yes, I know. It ~must~ not. But if in the statement
f 1 0 512 10 1
actually the size is 513 points, because table[0] is copied as  
table[512], there would be a repetition of this value (in this case 0)  
whenever an oscillator reaches table[512] and starts reading again at  
table[0], right?
Or what is my misunderstanding?

	joachim


Am 12.01.2010 um 00:13 schrieb Richard Dobson:

> No, it is done simply to streamline the linear interpolation code  
> (saves a conditional test and possible wraparound index computation).
>
> Note that in (say) a sinusoid cycle computed over 512 samples,  
> table[0] is ~not~ the same as table[511].
>
> Richard Dobson
>
>
> joachim heintz wrote:
>> And is this extra point being read by opcodes like oscili?
>> Then there must be a slight discontinuity when the size is exactly  
>> pow-of-2, as there are two equal values following each other (the  
>> extra one and the first one), for instance at a pure sine wave,  
>> right?
>> So the statement f 1 0 1025 10 1 is simply better than f 1 0 1024  
>> 10 1?
>>    joachim
>
>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
> "unsubscribe csound"
>



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

Date2010-01-12 07:50
FromVictor Lazzarini
Subject[Csnd] Re: Re: Re: Re: Re: Re: reason for adding one to f-table size
The oscillator does not reach 512. It will get to 511.9999... at max,  
which is 511 and if it is oscili, it will interpolate linearly  
betweeen 511 and 512 (which in this case should be the same as 0)

Victor



On 12 Jan 2010, at 07:34, joachim heintz wrote:

> Yes, I know. It ~must~ not. But if in the statement
> f 1 0 512 10 1
> actually the size is 513 points, because table[0] is copied as  
> table[512], there would be a repetition of this value (in this case  
> 0) whenever an oscillator reaches table[512] and starts reading  
> again at table[0], right?
> Or what is my misunderstanding?
>
> 	joachim
>
>
> Am 12.01.2010 um 00:13 schrieb Richard Dobson:
>
>> No, it is done simply to streamline the linear interpolation code  
>> (saves a conditional test and possible wraparound index computation).
>>
>> Note that in (say) a sinusoid cycle computed over 512 samples,  
>> table[0] is ~not~ the same as table[511].
>>
>> Richard Dobson
>>
>>
>> joachim heintz wrote:
>>> And is this extra point being read by opcodes like oscili?
>>> Then there must be a slight discontinuity when the size is exactly  
>>> pow-of-2, as there are two equal values following each other (the  
>>> extra one and the first one), for instance at a pure sine wave,  
>>> right?
>>> So the statement f 1 0 1025 10 1 is simply better than f 1 0 1024  
>>> 10 1?
>>>   joachim
>>
>>
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
>> "unsubscribe csound"
>>
>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
> "unsubscribe csound"



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

Date2010-01-12 07:59
Fromjoachim heintz
Subject[Csnd] Re: Re: Re: Re: Re: Re: Re: reason for adding one to f-table size
Thanks. And poscil(3)?


Am 12.01.2010 um 08:50 schrieb Victor Lazzarini:

> The oscillator does not reach 512. It will get to 511.9999... at  
> max, which is 511 and if it is oscili, it will interpolate linearly  
> betweeen 511 and 512 (which in this case should be the same as 0)
>
> Victor
>
>
>
> On 12 Jan 2010, at 07:34, joachim heintz wrote:
>
>> Yes, I know. It ~must~ not. But if in the statement
>> f 1 0 512 10 1
>> actually the size is 513 points, because table[0] is copied as  
>> table[512], there would be a repetition of this value (in this case  
>> 0) whenever an oscillator reaches table[512] and starts reading  
>> again at table[0], right?
>> Or what is my misunderstanding?
>>
>> 	joachim
>>
>>
>> Am 12.01.2010 um 00:13 schrieb Richard Dobson:
>>
>>> No, it is done simply to streamline the linear interpolation code  
>>> (saves a conditional test and possible wraparound index  
>>> computation).
>>>
>>> Note that in (say) a sinusoid cycle computed over 512 samples,  
>>> table[0] is ~not~ the same as table[511].
>>>
>>> Richard Dobson
>>>
>>>
>>> joachim heintz wrote:
>>>> And is this extra point being read by opcodes like oscili?
>>>> Then there must be a slight discontinuity when the size is  
>>>> exactly pow-of-2, as there are two equal values following each  
>>>> other (the extra one and the first one), for instance at a pure  
>>>> sine wave, right?
>>>> So the statement f 1 0 1025 10 1 is simply better than f 1 0 1024  
>>>> 10 1?
>>>>  joachim
>>>
>>>
>>>
>>>
>>> Send bugs reports to this list.
>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
>>> "unsubscribe csound"
>>>
>>
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
>> "unsubscribe csound"
>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
> "unsubscribe csound"
>



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

Date2010-01-12 08:03
FromVictor Lazzarini
Subject[Csnd] Re: Re: Re: Re: Re: Re: Re: Re: reason for adding one to f-table size
yes, all linear interpolating oscillators work similarly with regards  
to this.

Victor
On 12 Jan 2010, at 07:59, joachim heintz wrote:

> Thanks. And poscil(3)?
>
>
> Am 12.01.2010 um 08:50 schrieb Victor Lazzarini:
>
>> The oscillator does not reach 512. It will get to 511.9999... at  
>> max, which is 511 and if it is oscili, it will interpolate linearly  
>> betweeen 511 and 512 (which in this case should be the same as 0)
>>
>> Victor
>>
>>
>>
>> On 12 Jan 2010, at 07:34, joachim heintz wrote:
>>
>>> Yes, I know. It ~must~ not. But if in the statement
>>> f 1 0 512 10 1
>>> actually the size is 513 points, because table[0] is copied as  
>>> table[512], there would be a repetition of this value (in this  
>>> case 0) whenever an oscillator reaches table[512] and starts  
>>> reading again at table[0], right?
>>> Or what is my misunderstanding?
>>>
>>> 	joachim
>>>
>>>
>>> Am 12.01.2010 um 00:13 schrieb Richard Dobson:
>>>
>>>> No, it is done simply to streamline the linear interpolation code  
>>>> (saves a conditional test and possible wraparound index  
>>>> computation).
>>>>
>>>> Note that in (say) a sinusoid cycle computed over 512 samples,  
>>>> table[0] is ~not~ the same as table[511].
>>>>
>>>> Richard Dobson
>>>>
>>>>
>>>> joachim heintz wrote:
>>>>> And is this extra point being read by opcodes like oscili?
>>>>> Then there must be a slight discontinuity when the size is  
>>>>> exactly pow-of-2, as there are two equal values following each  
>>>>> other (the extra one and the first one), for instance at a pure  
>>>>> sine wave, right?
>>>>> So the statement f 1 0 1025 10 1 is simply better than f 1 0  
>>>>> 1024 10 1?
>>>>> joachim
>>>>
>>>>
>>>>
>>>>
>>>> Send bugs reports to this list.
>>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
>>>> "unsubscribe csound"
>>>>
>>>
>>>
>>>
>>> Send bugs reports to this list.
>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
>>> "unsubscribe csound"
>>
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
>> "unsubscribe csound"
>>
>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
> "unsubscribe csound"



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