Cabbage Logo
Back to Cabbage Site

Writing f-table values on screen

Dear all,
I am having problems figuring out whats wrong (i guess it is a peoblem with execututing the code).

a) i have the following table:
giSeq1f ftgen 10, 0, 2^3, -2, 7.00, 7.03, 7.02, 7.06, 7.05, 7.09, 7.08, 7.12
b) and a button is triggering the following Instr:
instr 2
prints “Button %i pressed !!!\n”, i(gkButBank)
ilength = ftlen(giSeq1f); length of f-table
kndx = 0
kval table kndx, giSeq1f, 0, 0, 1
prints “ilength: %f kval1: %f\n”, k(ilength), kval
kndx = 1
kval table kndx, giSeq1f, 0, 0, 1
prints “ilength: %f kval2: %f\n”, k(ilength), kval
kndx = 2
kval table kndx, giSeq1f, 0, 0, 1
prints “ilength: %f kval3: %f\n”, k(ilength), kval
endin
c) the output is (depending on the button pressed:
Button 1 pressed !!!
ilength: 8.000000 kval1: 0.000000
ilength: 8.000000 kval2: 0.000000
ilength: 8.000000 kval3: 0.000000
or
Button 2 pressed !!!
ilength: 8.000000 kval1: 7.020000
ilength: 8.000000 kval2: 7.020000
ilength: 8.000000 kval3: 7.020000
or
Button 3 pressed !!!
ilength: 8.000000 kval1: 7.020000
ilength: 8.000000 kval2: 7.020000
ilength: 8.000000 kval3: 7.020000

Does anyone know what’s going on? All I want is to change values depending on the button pressed.
However, i already experience problems when trying to read a table value. Odd, no?

Many thanks in advance
Domnik

Hi Domnik. I expect it might be a problem with your update rates. I see you a lot of casts in there, but it’s hard to tell from a few little snippets of code. Any chance you could post a minimal .csd that shows the problem?

Dear Rory,
Many thanks for your reply.
Please find below a rewritten part of the code.
I still do not understand why parts of it do not get executed.
However, parts get executed after pressig the buttons a second or third time (reading 555).
Best Dominik

-odac -d sr = 44100 ksmps = 64 nchnls = 2 0dbfs = 1 giSeq1f ftgen 100, 0, 2^3, -2, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8 ; -------------------------------------------------------------------- ; gui FLpanel "test", 450, 550, 100, 100, 16, 1 ; start of container iwidth = 400 iheight = 50 ix = 10 iy = 10 iopcode = 0 iinstr = 2 istarttime = 0 idur = 1 ; 5x2 buttonbank gkButBank,giHaButBank FLbutBank 1, 8, 1,\ iwidth, iheight, ix, iy, iopcode,\ iinstr, istarttime, idur FLpanelEnd; end of container FLrun; runs the widget thread, it is always required! ; -------------------------------------------------------------------- instr 2 ; try to rad a view cells... prints "Button %f pressed!\\n", i(gkButBank) iLength = ftlen(giSeq1f); length of f-table iCount = 0 until iCount == iLength do kval table iCount, giSeq1f prints "iCount: %f f-table no.: %f iLength: %f kval: %f\\n",\ iCount, giSeq1f, iLength, kval iCount += 1 od ; try writing to the table and then reading.... tablew 555.0, 7, giSeq1f ktemp table 7, giSeq1f prints "write/read: %f\\n", ktemp endin t 0 60 i2 0 10

I think the problem might be expecting a k-rate variable to change within an i-rate loop. Look at this excerpt:

until iCount == iLength do
kval table iCount, giSeq1f
prints "iCount: %f f-table no.: %f iLength: %f kval: %f\n",\
iCount, giSeq1f, iLength, kval
iCount += 1
od

The loop occurs at i-time, therefore kval will always be zero. Change kval to ival and I think it will do what you want.

Dear Ian,

Yep, that was the problem.
Changed it to an i-variable and it worked niceley.
Many thanks
Dominik