Merge pull request #506 from andrewcsmith/patch-2
[supercollider.git] / HelpSource / Classes / IndexL.schelp
blob1052054d23cc1262fbef20108b44a07cd88c4777
1 class:: IndexL
2 summary:: Index into a table with a signal, linear interpolated
3 categories:: UGens>Buffer
4 related:: Classes/Index, Classes/IndexInBetween
6 description::
7 The input signal value is used as an index into the table, with linear interpolation.
8 Out of range index values are clipped to the valid range.
10 classmethods::
11 method:: ar, kr
12 argument:: bufnum
13 index of the buffer.
14 argument:: in
15 the input signal.
17 examples::
18 code::
19 // indexing into a fixed table
22         SinOsc.ar(
23                 IndexL.kr(
24                         LocalBuf.newFrom([ 200, 300, 400, 500, 600, 800 ].scramble),
25                         LFSaw.kr(2.0).range(0, 7)
26                 ),
27                 0,
28                 0.5
29         )
30 }.play;
33 // with mouse control
36         SinOsc.ar(
37                 IndexL.kr(
38                         LocalBuf.newFrom([ 200, 300, 400, 500, 600, 800 ].scramble),
39                         MouseX.kr(0, 7)
40                 ),
41                 0,
42                 0.5
43         )
44 }.play;
48 // indexing into a changeable table
49 s = Server.local;
50 t = [ 200, 300, 400, 500, 600, 800 ];
51 b = Buffer(s, t.size, 1);
53 // alloc and set the values
54 s.listSendMsg( b.allocMsg( b.setnMsg(0, t) ).postln );
56 SynthDef(\help_index, { arg out = 0, i_bufnum = 0;
57         Out.ar(0,
58                 SinOsc.ar(
59                         IndexL.kr(
60                                 i_bufnum,
61                                 LFSaw.kr(2).range(0, 7)
62                         ),
63                         0,
64                         0.5
65                 )
66         )
67 }).play(s, [\i_bufnum, b]);
70 b.setn(*[ 200, 300, 400, 500, 600, 800 ].scramble.postln - 30);
74 SynthDef(\help_index, { arg out = 0, i_bufnum = 0;
75         Out.ar(0,
76                 SinOsc.ar(
77                         IndexL.kr(
78                                 i_bufnum,
79                                 MouseX.kr(0, BufFrames.ir(i_bufnum))
80                         ),
81                         0,
82                         0.5
83                 )
84         )
85 }).play(s, [\i_bufnum, b]);
88 b.free;