[chuck-users] SndBuf functions - valueAt ??

Laurie Hollander catbird451 at gmail.com
Sun Dec 3 23:48:32 EST 2006


I see the following functions in the Chuck manual, for SndBuf:
.read - (string, WRITE only) - loads file for reading
.chunks - (int, READ/WRITE) - size of chunk (# of frames) to read
on-demand; 0 implies
entire file, default; must be set before reading to take effect.
.write - (string, WRITE only) - loads a file for writing (or not)
.pos - (int, READ/WRITE) - set position (0 <p <.samples)
.valueAt - (int, READ only) - returns the value at sample index
.loop - (int, READ/WRITE) - toggle looping
.interp - (int, READ/WRITE) - set interpolation (0=drop, 1=linear, 2=sinc)
.rate - (float, READ/WRITE) - playback rate (relative to the file's
natural speed)
.play - (float, READ/WRITE) - play (same as rate)
.freq - (float, READ/WRITE) - playback rate (file loops/second)
.phase - (float, READ/WRITE) - set phase position (0-1)
.channel - (int, READ/WRITE) - select channel (0 <x <.channels)
.phaseOffset - (float, READ/WRITE) - set a phase offset
.samples - (int, READ only) - fetch number of samples
.length - (float, READ only) - fetch length in seconds
.channels - (int, READ only) - fetch number of channels

I am now trying to use the .valueAt function, but am getting errors.
The program is something like....
SndBuf a ;
...etc I read a soundfile into sndbuf a and play it - that much works....

int samp_pos ;
float samp_val ;
for (0 => int j ; j < 10000 ; j++) {
	j => a.pos ;
	j => samp_pos ;
	a.valueAt() => samp_val ;
//	<<<a.pos() >>> ;
//	<<< samp_pos, samp_val >>> ;
}

Here's the error message:
[trigplay2calc.ck]:line(151): arguments type(s) do not match:
[trigplay2calc.ck]:line(151): ... for function 'SndBuf.valueAt(...)' ...
[trigplay2calc.ck]:line(151): ...(please check the argument types)

When I change the type of samp_val to int, I get the same message.
When I leave out the parentheses, it complains that it's a function.

Does the .valueAt function work?

Thank you!

-Laurie


More information about the chuck-users mailing list