[chuck-users] How to read large data files
gewang at CS.Princeton.EDU
Wed Jan 4 21:48:13 EST 2006
> I recently found ChucK, and have started to work with it in putting
> together some music. I am trying to use fractal data as a control for
> various parameters. I rewrote my fractal program in ChucK, but because
> of how the floats are of limited percision, I am getting different
> results than the same program written in C.
There is currently one floating point type 'float' in ChucK, which is
actually double precision internally.
> I had thought about two (three?) different approaches to solving the
> problem, the first would be to use my C program to generate the
> fractal data, and write it to a file. My program can write this data
> to an audio file, which would then be imported into ChucK. BUT, it
> would appear that it is not possible to access the underlying sample
> data from a 'sndbuf' object.
> I had looked to see if there was a generic function to read raw data
> from a disk file, but could not find anything.
General file I/O is a disaster zone right now (it's not yet implemented).
We are hoping to add this most essential functionality/API asap. Stay
> Also, would this be practical to read, as these datafile can have as
> many as 20,000 samples per file, these into an Array? How much overhead
> is there in using an array of floating point values on the order of
> 20,000 elements?
ChucK arrays have a small constant memory overhead per array (it's more
complicated if using multi-dimensional arrays). There is no per-element
> The last idea would be to write a UGEN object in C++, and then
> recompile ChucK to include this new object. Is there a limitation to
> how many outputs a UGEN can produce in a single iteration?
If I understand this correctly, the answer currently is no - each ugen
outputs one sample value mapped to a particular chuck time. The framework
caches this value and will not ask a ugen to recompute until the next time
I hope this helps - please post if you have additional questions.
More information about the chuck-users