Csound Csound-dev Csound-tekno Search About

[Csnd] Guard point and ftlen()

Date2009-09-08 21:17
FromJacob Joaquin
Subject[Csnd] Guard point and ftlen()
Is there a way to detect whether or not an f-table was declared with a size
of a power of two, a power of 2 + 1 or a negative number inside of an
instrument?  I discovered that ftlen ignores the guard point, whether or not
the guard point is implicitly or explicitly stated.  The following two
f-tables have sizes of 4 and 5, though ftlen() returns the value 4 for both:

f 1 0 4 -2 1 2 3 4
f 2 0 5 -2 1 2 3 4 5

I wrote a test csd that prints the size of the tables, along with the values
at each index.  Here is the output (F-table Index: Value):

__excerpt from output__
new alloc for instr 1:
Size of table 1: 4
0: 1.000000
1: 2.000000
2: 3.000000
3: 4.000000
4: 1.000000
new alloc for instr 1:
Size of table 2: 4
0: 1.000000
1: 2.000000
2: 3.000000
3: 4.000000
4: 5.000000
__end__

Other tests I ran show that negatively sized f-tables do not produce a guard
point.  Is this correct?

Here's the test csd I used:

__csd__


sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

instr 1
    ifn = p4
    ilast_index = p5
    isize = ftlen(ifn)
    ii = 0
    printf_i "Size of table %d: %d\n", 1, ifn, isize
    
    begin_loop:
    if (ii >= ilast_index) igoto end_loop
        ivalue tab_i ii, ifn
        printf_i "%d: %2f\n", 1, ii, ivalue 
        ii = ii + 1
        igoto begin_loop

    end_loop:
    turnoff
endin


f 1 0 4 -2 1 2 3 4
f 2 0 5 -2 1 2 3 4 5
i 1 0 1 1 5
i 1 0 1 2 5


__end__


Best,
Jake