2 summary:: Finds the (lowest) point in the Buffer at which the input signal lies in-between the two values
3 categories:: UGens>Buffer
4 related:: Classes/Index, Classes/IndexL
7 Finds the (lowest) point in the link::Classes/Buffer:: at which the input signal lies in-between the two values, and returns the index. The fractional part of the index is suitable for linearly interpolating between the buffer slot values.
9 For example, if the Buffer contains [3, 21, 25, 26] and the input has the value 22, then the output will be 1.25, because the value 22 is in-between the values stored in indices 1 and 2 and in fact is one-quarter of the way along the interval between them.
11 IndexInBetween is the complement of link::Classes/IndexL::.
26 t = ([0, 1, 3, 4, 7, 11, 12] + 70).midicps;
27 b = Buffer(s, t.size, 1);
29 // alloc and set the values
30 s.listSendMsg( b.allocMsg( b.setnMsg(0, t) ).postln );
33 var index, in, out, f0, fdiff;
35 in = Pulse.ar(MouseX.kr(t.minItem, t.maxItem)) * 0.1;
36 f0 = Pitch.kr(in).at(0);
37 index = IndexInBetween.kr(bufnum, f0);
38 fdiff = index.frac * (Index.kr(bufnum, index + 1) - Index.kr(bufnum, index));
39 out = PitchShift.ar(in, 0.1, 1 - (fdiff / f0), 0.01, 0.01);
40 RLPF.ar(out, [2000, 5000], 0.3)
50 t = [ 200, 210, 400, 430, 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 );
57 var index, f0, f1, f3;
59 f0 = MouseX.kr(200, 900);
60 index = IndexInBetween.kr(bufnum, f0);
61 f1 = IndexL.kr(bufnum, index);
62 SinOsc.ar([f0, f1]) * 0.1
70 // One way to map across from an arbitrary piecewise curve, onto another:
71 // We use IndexInBetween to "unmap" your input into integer slots,
72 // and then use IndexL to do the reverse, to "map" onto your other distribution.
73 // This example maps a sort-of-exponential curve onto a sort-of-sinusoidal curve:
75 ~from = [1, 2, 4, 8, 16];
76 ~to = [0, 1, 0, -1, 0];
79 IndexL.kr(~to.as(LocalBuf), IndexInBetween.kr(~from.as(LocalBuf),MouseX.kr(~from.first, ~from.last).poll).poll).poll