Hi guys,
I've recently discovered Pure Data as versatile platform I could use to build a robotic GUI. The idea is to collect data from a robot, send it to an OSC (open source control) server, get the data in pd~ and deal with it. One important aspect would be to plot data, in real-time, so the graph scrolls from right to left, and data is appended to the end of array (right) (well, I hope what I write is understandable...).
So far so good, I've been able to build all the OSC part, and even plot things in a array in pd~, but I can only find a way to plot data from left to right, and when array's end is reached, clear it and start from beginning again. In other words, I can't make it scroll...
Is there a common, usual way to do this ? Should I use "struct", "pointer" and other kind of advanced stuffs ? Is there any externals I could use or base on to build this ?
Thanks in advance for your help, Cheers, Seb
Hallo, Sebastien Lelong hat gesagt: // Sebastien Lelong wrote:
I've recently discovered Pure Data as versatile platform I could use to build a robotic GUI. The idea is to collect data from a robot, send it to an OSC (open source control) server, get the data in pd~ and deal with it. One important aspect would be to plot data, in real-time, so the graph scrolls from right to left, and data is appended to the end of array (right) (well, I hope what I write is understandable...).
So far so good, I've been able to build all the OSC part, and even plot things in a array in pd~, but I can only find a way to plot data from left to right, and when array's end is reached, clear it and start from beginning again. In other words, I can't make it scroll...
One simple way to make it scroll would be to use [list-lastx <TABLESIZE>] from the [list]-abs collection. Just prepend a 0 to the outgoing list and send it to a receiver named after the table like this:
[table DATA 16]
[r ROBOT] | [list-lastx 16] | [list prepend 0] | [s DATA]
Alternatively do it manuall. The basic algorithm is this:
If a new ROBOT-float comes in store it. Then start a loop over the table where you
This is a good excercise to get familiar with the [trigger] object and Pd's execution order.
Frank
Hi Frank,
Thanks for your help. I'm getting things that "kind of" scroll... building an horrible patch :) Some values are random, I guess I have a problem when access extremities of the array. I'm sure there's something simpler, probably using trigger, but I can't figure out how I could use a trigger here. Could you give one last hint ? I guess I need to learn how to "think" pure data...
Anyway, thanks again.
Cheers, Seb
Hallo,
Sebastien Lelong hat gesagt: // Sebastien Lelong wrote:
I've recently discovered Pure Data as versatile platform I could use to build a robotic GUI. The idea is to collect data from a robot, send it to
an
OSC (open source control) server, get the data in pd~ and deal with it.
One
important aspect would be to plot data, in real-time, so the graph
scrolls
from right to left, and data is appended to the end of array (right)
(well,
I hope what I write is understandable...).
So far so good, I've been able to build all the OSC part, and even plot things in a array in pd~, but I can only find a way to plot data from
left
to right, and when array's end is reached, clear it and start from
beginning
again. In other words, I can't make it scroll...
One simple way to make it scroll would be to use [list-lastx <TABLESIZE>] from the [list]-abs collection. Just prepend a 0 to the outgoing list and send it to a receiver named after the table like this:
[table DATA 16]
[r ROBOT] | [list-lastx 16] | [list prepend 0] | [s DATA]
Alternatively do it manuall. The basic algorithm is this:
If a new ROBOT-float comes in store it. Then start a loop over the table where you
- read out the current element with [tabread]
- store it in the right inlet of a [float]
- write the new value into the table with [tabwrite]
- increment your counter
- repeat using the float stored in 2) as the new value.
This is a good excercise to get familiar with the [trigger] object and Pd's execution order.
Ciao
Frank
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Hallo, Sebastien Lelong hat gesagt: // Sebastien Lelong wrote:
Thanks for your help. I'm getting things that "kind of" scroll... building an horrible patch :) Some values are random, I guess I have a problem when access extremities of the array. I'm sure there's something simpler, probably using trigger, but I can't figure out how I could use a trigger here. Could you give one last hint ? I guess I need to learn how to "think" pure data...
Indeed: Understanding triggering and execution order brings you much closer to "thinking in Pd". There are only two things to remember: The left inlet of (most) objects is hot, the right is cold and lets you use an object as a storage container.
OTOH the right outlet of (most) objects fires before the left one. This holds especially true for the [trigger] object whose main purpose is to control the order in that your patch cords get activated.
Both facts are nicely combined in the scrolling table solution in the attached patch. The top [trigger] object shows how sometimes in Pd you have to think far ahead: Its right outlet stores a number in a float object below that gets used much later.
The lower trigger object (abbreviated as [t ...]) shows another common idiom: It's followed by crossed patch cords. You will often see this when something is stored for a moment and the previously stored value is used instead.
Anyway the attachement shouldn't be to hard to folllow with its comments, but feel free to ask any questions. "Getting it" is important here. :)
Frank Barknecht Do You RjDj.me? _ ______footils.org__
Hi Frank, hi guys,
Many, many thanks for your explanation and your example ! I've finally understood how to use [trigger] objects and store value in a [float] (I have to admit I needed quite a lot of time, a paper and a pen: I must be very slow "thinking in Pd" :)). Indeed, a nice exercise.
I have one question though (not related to [trigger]). In your example, as in Martin's, you use $0-a16 to name the array. I understand $0 is used when building an abstraction and creating multiple instances of this abstraction. My question is how can I configure this array, from the parent (from the patch using the abstraction) ? For instance, I'd like to add "xticks", "ylabel", etc... I usually use a message, like: _________________ [array1 ylabel -1 0 1 (
but the same with $0-a16 obsviously doesn't work, since $0 is not known (I understand it's a counter incremented at each creation). Is this possible to do this ?
Cheers, Seb
Hallo,
Sebastien Lelong hat gesagt: // Sebastien Lelong wrote:
Thanks for your help. I'm getting things that "kind of" scroll...
building
an horrible patch :) Some values are random, I guess I have a problem
when
access extremities of the array. I'm sure there's something simpler, probably using trigger, but I can't figure out how I could use a trigger here. Could you give one last hint ? I guess I need to learn how to
"think"
pure data...
Indeed: Understanding triggering and execution order brings you much closer to "thinking in Pd". There are only two things to remember: The left inlet of (most) objects is hot, the right is cold and lets you use an object as a storage container.
OTOH the right outlet of (most) objects fires before the left one. This holds especially true for the [trigger] object whose main purpose is to control the order in that your patch cords get activated.
Both facts are nicely combined in the scrolling table solution in the attached patch. The top [trigger] object shows how sometimes in Pd you have to think far ahead: Its right outlet stores a number in a float object below that gets used much later.
The lower trigger object (abbreviated as [t ...]) shows another common idiom: It's followed by crossed patch cords. You will often see this when something is stored for a moment and the previously stored value is used instead.
Anyway the attachement shouldn't be to hard to folllow with its comments, but feel free to ask any questions. "Getting it" is important here. :)
Ciao
Frank Barknecht Do You RjDj.me? _ ______footils.org__
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Hallo, Sebastien Lelong hat gesagt: // Sebastien Lelong wrote:
I have one question though (not related to [trigger]). In your example, as in Martin's, you use $0-a16 to name the array. I understand $0 is used when building an abstraction and creating multiple instances of this abstraction. My question is how can I configure this array, from the parent (from the patch using the abstraction) ? For instance, I'd like to add "xticks", "ylabel", etc... I usually use a message, like: _________________ [array1 ylabel -1 0 1 (
but the same with $0-a16 obsviously doesn't work, since $0 is not known (I understand it's a counter incremented at each creation).
Correct!
Is this possible to do this ?
"[; array1 ylabel -1 0 1(" (note the semicolon!) is the same as this:
[ylabel -1 0 1 ( | [s array1]
because semicolon messages are just a shortcut for senders.
In object boxes like [s ...] you can use $0 variables, so inside of the scrolling abstraction your could use:
[ylabel -1 0 1 ( | [s $0-array]
Now to let something control the array from the outside, I'd recommend to just use an [inlet]:
[inlet] | [s $0-array]
Frank
Hi Sebastien,
Sebastien Lelong hat gesagt: // Sebastien Lelong wrote:
I have one question though (not related to [trigger]). In your example, as in Martin's, you use $0-a16 to name the array. I understand $0 is used when building an abstraction and creating multiple instances of this abstraction. My question is how can I configure this array, from the parent (from the patch using the abstraction) ? For instance, I'd like to add "xticks", "ylabel", etc... I usually use a message, like: _________________ [array1 ylabel -1 0 1 (
but the same with $0-a16 obsviously doesn't work, since $0 is not known (I understand it's a counter incremented at each creation).
if there aren't too many of those arrays in your patch, probably Frank's solution is far more simple and convenient.
another possibility would be using creation arguments as names. you would then use $1-arrayname in an abstraction instead of $0-arrayname which uses the first creation argument of the abstraction in your parent patch. (so $2 stands for the second creation argument and so on)
if you create an object [myabstraction something] in your parent patch you can access the array's properties by sending for example
[ylabel -1 0 1( | [s something-arrayname]
or like you wrote before using [; something-arrayname ylabel -1 0 1(]
also have a look at /doc/2.control.examples/14.dollarsigns.pd for more stuff with dollar signs as creation arguments. (i found it kind of confusing the first time, so perhaps better don't try too hard and have a look later again)
notice that dollar signs in messages like
[$1 $2 (
are not the same as dollar signs from creation arguments. That's one thing which can also seem strange when learning pd...
Just try the below to understand what dollar signs stand for in messages.
[one two three four( | [$2 $3 $1( | [print]
Dollar sings in messages like the above are not affected by creation arguments, by default they return 0 (and an error message, just click on the message [$2 $3 $1( directly to see that).
in the ppd_scroll abstraction you would have to change each $0-graph into $3-graph (because $1 and $2 are already in use) and then create instances of it like [ppd_scroll 10 1 myname] and send settings to myname-graph then.
cheers, Martin
Hi guys,
Thanks for all your suggestions and explanations ([trigger], [;semicolon message( acting a senders, dollars init variables vs. other dollar variables, the magic of $0, ...). Since I'll probably put a lot of scrolling graphs in my app, I think I'll go with the initialization argument solution and modify pdd_scroll as needed.
Cyrille, I did not have time to test mapping/timeroll yet. I guess this is in SVN extensions/abstractions/externals/.... I need to dig extensions in order to find ones I could use (widgets like gauges, knob, etc...).
Cheers, Seb
Hi Sebastien,
Sebastien Lelong hat gesagt: // Sebastien Lelong wrote:
I have one question though (not related to [trigger]). In your example, as in Martin's, you use $0-a16 to name the array. I understand $0 is used when building an abstraction and creating multiple instances of this abstraction. My question is how can I configure this array, from the parent (from the patch using the abstraction) ? For instance, I'd like to add "xticks", "ylabel", etc... I usually use a message, like: _________________ [array1 ylabel -1 0 1 (
but the same with $0-a16 obsviously doesn't work, since $0 is not known (I understand it's a counter incremented at each creation).
if there aren't too many of those arrays in your patch, probably Frank's solution is far more simple and convenient.
another possibility would be using creation arguments as names. you would then use $1-arrayname in an abstraction instead of $0-arrayname which uses the first creation argument of the abstraction in your parent patch. (so $2 stands for the second creation argument and so on)
if you create an object [myabstraction something] in your parent patch you can access the array's properties by sending for example
[ylabel -1 0 1( | [s something-arrayname]
or like you wrote before using [; something-arrayname ylabel -1 0 1(]
also have a look at /doc/2.control.examples/14.dollarsigns.pd for more stuff with dollar signs as creation arguments. (i found it kind of confusing the first time, so perhaps better don't try too hard and have a look later again)
notice that dollar signs in messages like
[$1 $2 (
are not the same as dollar signs from creation arguments. That's one thing which can also seem strange when learning pd...
Just try the below to understand what dollar signs stand for in messages.
[one two three four( | [$2 $3 $1( | [print]
Dollar sings in messages like the above are not affected by creation arguments, by default they return 0 (and an error message, just click on the message [$2 $3 $1( directly to see that).
in the ppd_scroll abstraction you would have to change each $0-graph into $3-graph (because $1 and $2 are already in use) and then create instances of it like [ppd_scroll 10 1 myname] and send settings to myname-graph then.
cheers, Martin
Hi, Is there a way to edit the entry on the bug tracker about [pow~] to include [log~] and [exp~]? It's the same problem about the creation arguments not being recognized.
Thanks, Jonathan
Just add a comment to the bug.
.hc
On Feb 25, 2009, at 5:00 AM, Jonathan Wilkes wrote:
Hi, Is there a way to edit the entry on the bug tracker about [pow~]
to include [log~] and [exp~]? It's the same problem about the
creation arguments not being recognized.Thanks, Jonathan
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
"It is convenient to imagine a power beyond us because that means we
don't have to examine our own lives.", from "The Idols of
Environmentalism", by Curtis White
hello,
have you tried to look at mapping/timeroll object. it's exactly what franck describ... cyrille
Sebastien Lelong a écrit :
Hi Frank,
Thanks for your help. I'm getting things that "kind of" scroll... building an horrible patch :) Some values are random, I guess I have a problem when access extremities of the array. I'm sure there's something simpler, probably using trigger, but I can't figure out how I could use a trigger here. Could you give one last hint ? I guess I need to learn how to "think" pure data...
Anyway, thanks again.
Cheers, Seb
Hallo, Sebastien Lelong hat gesagt: // Sebastien Lelong wrote: > I've recently discovered Pure Data as versatile platform I could use to > build a robotic GUI. The idea is to collect data from a robot, send it to an > OSC (open source control) server, get the data in pd~ and deal with it. One > important aspect would be to plot data, in real-time, so the graph scrolls > from right to left, and data is appended to the end of array (right) (well, > I hope what I write is understandable...). > > So far so good, I've been able to build all the OSC part, and even plot > things in a array in pd~, but I can only find a way to plot data from left > to right, and when array's end is reached, clear it and start from beginning > again. In other words, I can't make it scroll... One simple way to make it scroll would be to use [list-lastx <TABLESIZE>] from the [list]-abs collection. Just prepend a 0 to the outgoing list and send it to a receiver named after the table like this: [table DATA 16] [r ROBOT] | [list-lastx 16] | [list prepend 0] | [s DATA] Alternatively do it manuall. The basic algorithm is this: If a new ROBOT-float comes in store it. Then start a loop over the table where you 1) read out the current element with [tabread] 2) store it in the right inlet of a [float] 3) write the new value into the table with [tabwrite] 4) increment your counter 5) repeat using the float stored in 2) as the new value. This is a good excercise to get familiar with the [trigger] object and Pd's execution order. Ciao -- Frank _______________________________________________ Pd-list@iem.at <mailto:Pd-list@iem.at> mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
-- Sébastien Lelong http://www.sirloon.net http://sirbot.org
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Hallo, cyrille henry hat gesagt: // cyrille henry wrote:
have you tried to look at mapping/timeroll object.
I think, there is a minor bug in timeroll: Instead of [list apppend 0] it should probably be [list prepend 0]
(Btw. I think the dependency of "mapping" on "purepd" is a bit, uhm, uncomfortable.)
Frank
Frank Barknecht a écrit :
Hallo, cyrille henry hat gesagt: // cyrille henry wrote:
have you tried to look at mapping/timeroll object.
I think, there is a minor bug in timeroll: Instead of [list apppend 0] it should probably be [list prepend 0]
you're right. thanks.
(Btw. I think the dependency of "mapping" on "purepd" is a bit, uhm, uncomfortable.)
i strongly agree here. i need your help to have Hans authorisation to remove it!
Cyrille
Ciao
Hallo, cyrille henry hat gesagt: // cyrille henry wrote:
(Btw. I think the dependency of "mapping" on "purepd" is a bit, uhm, uncomfortable.)
i strongly agree here. i need your help to have Hans authorisation to remove it!
Hehe, I think you two better fight it out without me. :)
But anyway I think, it would be cool if mapping could be a bit more self-contained. Personally I would prefer it as a vanilla library as that would make it possible to to be used in vanilla enviroments like RjDj or even PDa (although without [list] that would be hard).
I guess, some externals cannot sensibly be removed, but at least float_argument is so trivial ... Maybe just copy it over to mapping and use it from there?
Frank
Frank Barknecht a écrit :
Hallo, cyrille henry hat gesagt: // cyrille henry wrote:
(Btw. I think the dependency of "mapping" on "purepd" is a bit, uhm, uncomfortable.)
i strongly agree here. i need your help to have Hans authorisation to remove it!
Hehe, I think you two better fight it out without me. :)
But anyway I think, it would be cool if mapping could be a bit more self-contained.
YES
Personally I would prefer it as a vanilla library as that would make it possible to to be used in vanilla enviroments like RjDj or even PDa (although without [list] that would be hard).
yep, list is mandatory for most mapping stuff.
I guess, some externals cannot sensibly be removed, but at least float_argument is so trivial ... Maybe just copy it over to mapping and use it from there?
yes, except float_argument, any_argument and purepd/once i don't see where to remove dependence. speedlim maybe also but it is used only in the examples...
other dependence are hard to remove, or limited to specific object, or only in the help file.
Cyrille
Ciao
Hi!
Sebastien Lelong wrote:
So far so good, I've been able to build all the OSC part, and even plot things in a array in pd~, but I can only find a way to plot data from left to right, and when array's end is reached, clear it and start from beginning again. In other words, I can't make it scroll...
I made something very similar but whithout scrolling originally. I added something to make it scroll, view the attached patch. there's a settable refreshrate (redraws the array every n values) so it doesn't consume too much CPU just for redrawing.
I'm not sure if that third part of the patch should be optimized like the first one - does copying and rewriting from a 'visible' array refresh the array on each write? Perhaps someone knows...
Martin