last two numbers
Hello!
I'm trying to find a way to generate random numbers and use them in pairs to modify the amplitude of a [cycle]. I use [sprintf %i, %i %i] where the first %i is the "from" value, the second is the "to" value and the final is the ms value. These go into a [line~]. For the line to be continuously generating without clipping I need the "to" value to replace the "from" value at each iteration. So basically I need a way to store the last two numbers of an infinite list, and to be able to change the index of the stored numbers. I can't find an intuitive way to do this without using delays which would probably overburden my processor.
I hope I managed to explain it clearly.
I was looking for solutions for this but I don't even know what to type in.
Do you have any suggestions?
Thank you!
Sounds like a shift register.
You can use [bucket] by having it shift from right to left.

Patch for download:
Not sure if I get what you need. I understand you want pairs of int numbers where the left number should be identical to the right number of the preceding pair.
You could simply use an [int| object – put a number into the right inlet to store it, put a bang into the left inlet to get it back. Generating one pair, store the right value for the next.
If you handle your pairs not as two single values but as a small list of two, using [prepend] might feel more natural. Use a message /set $1/ to store the old 'to' value for your next pair.
Or prepare the complete list of all numbers in advance. Make a list of single numbers, then use [zl lace] with the same list on both sides, then [zl slice 1] to throw away the very first element (or add a new first element). Or else, if you use a fixed number of pairs, double your elements using [zl indexmap].
If you need it, you can then cut the list into pairs, using [zl iter 2].
But probably I am misunderstanding everything…?
drop all that complication and use only pairs value - ramp time.
line~ needs no from - to in that context.
Oh, nice, did not know that.
But maybe he needs the values somewhere else in the patch ... ;-)
Thank you! Both solutions work really well!
The bucket object is really useful.
I have to admit I never used [ramp-] in my whole life… ; - )