[chuck-users] SndBuf functions - valueAt ??

Malik Martin laserbeak43 at gmail.com
Mon Dec 4 13:09:27 EST 2006


hi spencer
i'd really love to see come clearer docs on sndbuf myself:)
i havent touched chuck since that last little issue i had with it.
i do miss chuck. but i want to learn to sample with it. not really much 
of a synth fanatic. i sample  my synths then throw them into my sampler :)

Spencer Salazar wrote:

>Hi Laurie,
>Its not documented but SndBuf.valueAt() actually takes an integer  
>argument, which is the buffer position of the sample you are trying  
>to take the value of.  So a.valueAt( a.pos ) will give you the sample  
>at the current buffer position.  Also, it returns a float.  Im not  
>sure why it is documented like it is on the website; we'll be sure to  
>make the docs more clear on that soon.
>
>spencer
>
>On Dec 3, 2006, at 11:48 PM, Laurie Hollander wrote:
>
>  
>
>>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
>>_______________________________________________
>>chuck-users mailing list
>>chuck-users at lists.cs.princeton.edu
>>https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>>    
>>
>
>_______________________________________________
>chuck-users mailing list
>chuck-users at lists.cs.princeton.edu
>https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
>  
>



More information about the chuck-users mailing list