Hi,
I want to drive audio (eg pan & volume) by animations I did in a 3d animation program. I'm a beginner with csound, so here is my strategy (if you know a better one please tell me):
plot the animation in the 3d software to a textfile containing the values (with 25 fps). load the textfile in csound as gen02 table and plug it into the oscil. Here are my questions:
1. Can Csound read the values of a textfile? If yes, how? Is there a limit to the values ftgen can use? (I've read 1000 somewhere, which is weird... I mean if you read in eg samples from a wave file you have trillions of values).
2. 25 fps isn't much. so what is the best way to interpolate these values?
Thanks!



GEN23
Look at the docs for GEN23. Sounds like it should do what you want. Also maybe check out GEN28 -- it allows you to time-tag the values, which might be useful.
I don't think there's any upper limit like that on tables (though I guess there might be on ftgen, if the values are contained in the orchestra file).
I'd suspect linear interpolation would be good enough -- see the 'tablei' opcode. Then there's 'table3' for cubic interpolation which might be smoother. Just explore the manual.
thanks for the answer! I
thanks for the answer!
I find the manual to be a bit confusing for a beginner (and it lacks examples in certain areas).
I managed to write this code:
---------------
gitmp1 ftgen 1, 0, 32768, 10, 1
gitmp2 ftgen 0, 0, 16, -23, "test.txt"
instr 1
kamp = 10000
kIndx linseg 0,p3,16
kEnv tablei kIndx, gitmp2
a1 oscil kEnv*kamp, 440, gitmp1
out a1
endin
-----------------------------------
And it works, but the weird thing is I always have to write the length of the file manually even though the manual states that it's possible to write "0" and the ftgen will determine the size of the table itself. but when i write
gitmp2 ftgen 0, 0, 0, -23, "test.txt"
i can't hear anything.
what i also don't understand: If i define the table in the score section with
f2 0 0 -23 "test.txt"
and change tablei to:
kEnv tablei kIndx, 2
csound outputs an error.
what am I missing?
thanks!
Ps test.txt looks like this:
0.9174210626
0.8604291901
0.8034373295
0.7464454511
0.6894535965
0.6324617062
0.5754698635
0.5184779256
0.4614860829
0.4044941926
0.3475023023
0.2905104595
0.2335186168
0.776526774
0.8195348837
0.9033592131
Not your fault... (:-))
It looks like you've simply managed to find a bug or two (in Csound -- not your code...). I grabbed your orchestra file above, tried it, and got essentially the same as you.
Not quite, though. When I run in Csound5 (which I assume you are), I get an error ("deferred-size ftable ... illegal here") whenever I supply a '0' size, whether in ftgen or a score file. What's particularly silly is that it apparently determines the required size perfectly well in both cases! You can use the 'ftlen' operator to find the size of the table, e.g.:
iLen = ftlen(gitmp2)
print iLen
and it prints out '16', even it complains about an illegal table!
I originally tried in Csound4 (because that's what's on my day-to-day machine), with somewhat different results... ftgen actually crashed (with a divide error) without a size, and 'f1 0 0 -23 test.txt' worked perfectly well!!
I don't think anyone claims Csound is perfect... (:-/)
And the manual isn't difficult only for beginners!