• ### plotting points on a curve using array...

HI,

this seems super obvious, but I can't figure it out.

I am trying to plot a curve on an array with certain points.

when x = 0, y = 38.89
when x = 6, y = 41.2
when x = 11, y = 43.65

I'm calling this array pitches1

in a message box i'm putting this

;pitches1 0 38.89 6 41.2 11 43.65

i also tried this

;pitches1 0 38.89, 6 41.2, 11 43.65

when using [tabread pitches1] and i input a 0 I get 38.89, a 1 outputs 6, a outputs 41.2, a 3 outputs 11, 4 outputs 43.65. Not the desired outcome.

what i want is 0 outputs 38.89, 6 outputs 41.2 and 11 outputs 43.65. and if I input a number like 3 it will be on the curve between 38.89 and 41.2. Does this make sense? So I want to plot a curve along several given points, but I don't want to input every value of x, only certain ones like 0, 6 and 11, and I want Pd to figure out the in between values.

Is this possible? And how would I format a message box to achieve this?

thank you!

• Posts 14 | Views 3500
• @nicnut Hi, when you send a list to a table, the floats are sent to consecutive indexes starting from the index specified by the first float element of the list. You can check out [tabwrite] which accepts lists for value and index.

For populating the indexes in between I have patched this that seems to do that.

array.plot.pd

Hope it helps.

• @nicnut Pd will not calculate your curve automatically. There is a indefinite number of ways to interpolate your values, so you have to specify your function yourself.

i found a function that matches your values here: http://www.xuru.org/rt/PR.asp#CopyPaste and put it in a patch: array-test.pd.

• This post is deleted!
• Hi,

Thank you both for your help.

@ingox this isn't really a function, it's values from a sensor so that won't really work because it's not consistent.

@weightless, thanks for this patch. This does exactly what I was trying to acheive.

A couple questions. I am on vanilla, and I don't have [list-seek]. I searched for it in deken and can't seem to find it. It's not that big a deal though, because I know in the end my list will be 127 values and I can resize it in the properties of pitches1.

Also, I can't seem to find the [once] object. where can i find that object? also what is that part of the patch doing? maybe I can work around it.

But thank you! This is a great help and I'm sure I can modify this or make it work some how.

• @nicnut list-seek is in list-abs, once in iemlib.
a vanilla once: once.zip

• @nicnut Hi, I'm not sure which library is [once] from, but yes it's pretty much what @ingox suggested so you can make a subpatch with that inside. [list-seek] is from the library list-abs, you can find it in Deken, very useful set of abstractions for working with lists.

The part where there is [once] basically skips the calculations for the first value, since there is nothing to calculate but just write the first value at index 0. This is why I used once, because after that you need to calculate the numbers in between the last 2 values. Does that make sense? I realise the patch is pretty messy but I couldn't think of a more elegant way to do it.

EDIT: also the list and list-split that come after [once] only output after the second float they receive, so that's why I put them that way. The first float (needs to be the value for the 0 index) goes to the once object, the others to the list-split which concatenates the last two floats.

• Hi @ingox and @weightless,

Ok this is excellent. Thanks for the vanilla [once], now the patch is working perfectly.

Also, I do have [list-seek], but I have to format it like this; [list-abs/list-seek]

Seems like a very useful object.

Thanks again and I think this issue is solved.

• Hi guys,

The patch @weightless uploaded worked, but as soon as I started adding items to the array plot the values weren't being calculated correctly.

I'm gonna keep working on this, but if anyone has any ideas please let me know. It looks like when you get to 15 the calculations break down, and aren't being input correctly, or are being calculated correctly.

Let me know if anyone sees the problem.

thanks, Nick

arrayplot5.pd

• @nicnut Yes, my bad. There was an error in the calculation of the difference between the two most recent indexes and so the calculated number of in-between indexes was wrong after a while.

arrayplot5_fixed.pd

The last, longer list still doesn't work because the indexes are not in ascending order. I'm not sure whether my approach could be made to work if the indexes in the list are scrambled, and I'm a bit too tired now to try and figure that out. Maybe a possible solution would be to sort the indexes before sending the list, making sure that the first is always 0, and the others are in ascending order.

• @nicnut This does the sorting so for now you could pass your lists through this just to make sure, in case you are using lists that are generated automatically.

sort.list.pd

• @weightless Damn, you are a master with these lists. I sat for a few hours trying to wrap my head around your arrayplot patch and I couldn't figure it out. The math expressions made my head hurt.

thank you for posting these. I think this one will work, and the sorting patch helps too.

I'm sort of surprised there's not an easy way to do this at it's such a great way to use an array. In Max I use the "function" object. Anyway this is very helpful and thanks for you patches.

• @nicnut Glad to help out. Let us know if there are still problems down the line.

When you posted this I was also convinced there would be an easy (or built-in) way to do this, and I'd be very curious to know if there is, also to calculate the in-between values with different curves.

• @weightless There used to be [curve~] but it (/cyclone) was unfortunately part of the now unsupported and redundant(?) "extended".
Limited to 42 triples, but that is actually quite a lot.
It can be accessed in Vanilla though just by pointing Pd at the library.
Serious work could be done in extended, that is now difficult (osc and bp~) or impossible (pmpd, Gem except windows) in 64bit Vanilla.....
...... which could be why Apple Mac's were prone to overheating...... (only joking? a bit?.... maybe not?).
David.

Posts 14 | Views 3500
Internal error.

Oops! Looks like something went wrong!