Here's another approach using only list abs stuff (sorry for the messy -- I threw it together quickly). Could use as an abstraction with two inlets -- one on the right which receives a bang to initialize and one on the left that takes incoming numbers from the sensor, and one outlet (the outgoing numbers).
Matt
Hey Charlot,
Yes, that seems a good approach.
Will try in a few hours with a bit more time.
"You did not sew it solid enough it seems:)."
Definitely dropped a few stitches with this one:) I try to re-attach.
(btw - what is up with gmail and attachments atm?)
All good wishes,
Julian
On 27 March 2011 02:07, Charles Goyard cg@fsck.fr wrote:
J bz wrote:
I have a sensor which is spitting out numbers between 1-180.
Each number triggers an event that I only want to happen once but the
sensor
repeats numbers every so often.
You can use a table of 180 elements, each of which is initialized with zeros. When a sensor number occurs, check against the table. If it's 0, turn it to 1 and go on. If it's 1, do nothing and wait for a fresh number from the sensor. Or, if you don't want to wait, scan the table for the first zero. What appends when there's no zeros left is up to you.
(patch attached)
You did not sew it solid enough it seems:).
-- Charlot
Hey Matt,
Whoo-Hoo. That's splendid.
Can I ask you what the [t a] is doing that's looping with the [list prepend]? Just for my own understanding.
Bloody marvellous though.
All good wishes,
Julian
On 27 March 2011 16:19, Matt Barber brbrofsvl@gmail.com wrote:
Here's another approach using only list abs stuff (sorry for the messy -- I threw it together quickly). Could use as an abstraction with two inlets -- one on the right which receives a bang to initialize and one on the left that takes incoming numbers from the sensor, and one outlet (the outgoing numbers).
Matt
Sure,
PD doesn't give you a way to connect an outlet to an inlet of the same object, which is what's needed here to populate the first list with the numbers from 1-180 (it's one way to do it anyway). In this case, I'm using a counter to count up to 180, and on each bang from the [until] the new number goes into the [list prepend], which adds the number to the end of the last list -- but we need to store the last list as the thing to prepend, so it has to go back into the right inlet, and the only good way of doing that is [t a] (you could just use a [list] object, too, but [t a] seems more reliable and what people use most).
There are probably plenty of other ways of doing the same thing.
Matt
On Sun, Mar 27, 2011 at 6:12 PM, J bz jbeezez@gmail.com wrote:
Hey Matt,
Whoo-Hoo. That's splendid.
Can I ask you what the [t a] is doing that's looping with the [list prepend]? Just for my own understanding.
Bloody marvellous though.
All good wishes,
Julian
On 27 March 2011 16:19, Matt Barber brbrofsvl@gmail.com wrote:
Here's another approach using only list abs stuff (sorry for the messy -- I threw it together quickly). Could use as an abstraction with two inlets -- one on the right which receives a bang to initialize and one on the left that takes incoming numbers from the sensor, and one outlet (the outgoing numbers).
Matt
On Sun, 27 Mar 2011, Matt Barber wrote:
number to the end of the last list -- but we need to store the last list as the thing to prepend, so it has to go back into the right inlet, and the only good way of doing that is [t a] (you could just use a [list] object, too, but [t a] seems more reliable and what people use most).
I don't see what you mean about reliability. I only know that going through a [list append] is taking O(n) time, while going through a [t a] takes O(1) time.
Also, adding n elements to a list individually using [list]x[list] takes O(n^2) time, with [list]x[t a] it takes O(n^2) time too, and using a messagebox's add-method you can lower it to O(n). It's faster if you hide the messagebox in a subpatch.
From what I remember, the list-abs library does not use messageboxes, only
[list]x[t a], and thus several things are still O(n^2) even though they could be O(n), and even though I upgraded [list-drip] from O(n^2) to O(n) two years ago.
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC
On Tue, Mar 29, 2011 at 09:27:03AM -0400, Mathieu Bouchard wrote:
On Sun, 27 Mar 2011, Matt Barber wrote:
number to the end of the last list -- but we need to store the last list as the thing to prepend, so it has to go back into the right inlet, and the only good way of doing that is [t a] (you could just use a [list] object, too, but [t a] seems more reliable and what people use most).
I don't see what you mean about reliability. I only know that going
through a [list append] is taking O(n) time, while going through a [t a]
takes O(1) time.Also, adding n elements to a list individually using [list]x[list] takes
O(n^2) time, with [list]x[t a] it takes O(n^2) time too, and using a
messagebox's add-method you can lower it to O(n). It's faster if you hide the messagebox in a subpatch.From what I remember, the list-abs library does not use messageboxes, only [list]x[t a], and thus several things are still O(n^2) even though they could be O(n), and even though I upgraded [list-drip] from O(n^2) to O(n) two years ago.
Your list-drip.pd was included in [list]-abs at about that time. Message boxes are used in a handful of objects to speed things up, but probably some more places would be useful. I don't remember ATM if message box storage works fine with pointers as well, but there are objects where only floats would be allowed anyway.
Frank Barknecht Do You RjDj.me? _ ______footils.org__
On Tue, 29 Mar 2011, Frank Barknecht wrote:
Your list-drip.pd was included in [list]-abs at about that time. Message boxes are used in a handful of objects to speed things up, but probably some more places would be useful. I don't remember ATM if message box storage works fine with pointers as well, but there are objects where only floats would be allowed anyway.
consistency check failed: bad item in binbuf
while trying to output a gem pointer from a messagebox. not a real pd pointer though. note that it does not complain while putting the pointer in the binbuf using 'set' or 'add2', only when trying to output it.
i'll let you make the test using true pd pointers because I never remember how to use them, not to mention why t_gpointer and t_gstub have to exist at all.
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC