## [lcd] object doesn't do what i want!

Dec 24, 2006 at 3:32pm

# [lcd] object doesn't do what i want!

Hi all.

I’ve been working on some stuff with gesture recognition with the [lcd] object. One problem I’ve encountered is that lcd doesn’t output every value drawn unless the line is drawn very slowly.

I can get the length of a line drawn along a single axis (subtract the start value from the end value…) but I can’t measure the length of a line drawn in actual pixels covered.

In particular, I’m working on a ‘z’ gesture. I’ve sorted out horiz. line recognition, but the diagonal is proving more tricky.
I was planning on having max test the length of the drawn diagonal line against the shortest possible length of the line given by pythagoras’ theorum, and giving a maximum deviation after which the line can be deemed not diagonal.

There are two things I’d love to know –
1) Is there a way to work out the length of a line on a graph by comparing the two sets of coordinates?
2) Is there a similar object to [lcd], perhaps a 3rd party, that outputs every value? Can’t find anything on maxobjects.com though.

Thanks, and merry christmas!

robin

#29359
Dec 25, 2006 at 1:27am

> There are two things I’d love to know –
> 1) Is there a way to work out the length of a line on a graph by comparing the two sets of coordinates?

For a line from coordinates (x1,y1) to (x2, y2), you want:

the square root of ((x1-x2)squared + (y1-y2)squared)

> 2) Is there a similar object to [lcd], perhaps a 3rd party, that outputs every value? Can’t find anything on maxobjects.com though.
>
>

Does jsui do what you want?

mz

#91590
Dec 25, 2006 at 2:15pm

Hi,

There is an example in FTM library that does gesture recognition using hmm.
If you have ftm installed, you can find the example in extras menu,
mnm-examples->hmm->mnm.hmmL2R-ez.help

In that example, you can use lcd to draw patterns for training and
recognition.

best,
nesa

#91591
Dec 25, 2006 at 2:40pm

Firstly, i can’t believe i’m actually posting on Christmas day. Secondly, thanks – hadn’t thought of jsui. The jsui example that responds most similar to lcd doesn’t put out all values though… If I draw a line with a range from 100 to 0, i get the following:

print: 97
print: 95
print: 94
print: 93
print: 87
print: 77
print: 62
print: 40
print: 20
print: 0
print: 0
print: 0
print: 0
print: 0

There may well be some way to edit the javascript, but I know nothing about java. Maybe when I’m not too busy drinking as much as I can I’ll have a look

merry christmas

#91592
Dec 26, 2006 at 3:41am

>One problem I’ve encountered is that lcd doesn’t output every >value drawn unless the line is drawn very slowly.

yoyu mean mousing output? its some 20 or 50 milliseconds
and not more.

> I was planning on having max test the length of the
> drawn diagonal line against the shortest possible length
> of the line given by pythagoras’ theorum, and giving a
> maximum deviation after which the line can be deemed not
> diagonal.

[110.pythagoras] at maxobjects.com

> 2) Is there a similar object to [lcd], perhaps a 3rd
> party, that outputs every value?

this already fits into the category “dont exspect MAX
to replace photoshop” when i am not wrong.

there is [jit.lcd] … those two are the only ones
of that type.

-110

#91593
Dec 26, 2006 at 11:25am

Thanks, but I’m a little confused now. I said I intended to measure the length of the actual line drawn and compare it to the length of the straightest possible line between the start and end points, using pythagoras.

You (Roman) said it can’t be done, but also pointed me to an external – which doesn’t exist anyway.

did i miss something?!

thanks anyway, the lcd info is useful to know.

robin

#91594
Dec 26, 2006 at 10:59pm

Quote: robin wrote on Tue, 26 December 2006 04:25
—————————————————-
> Thanks, but I’m a little confused now. I said I intended to measure the length of the actual line drawn and compare it to the length of the straightest possible line between the start and end points, using pythagoras.
>
> You (Roman) said it can’t be done, but also pointed me to an external – which doesn’t exist anyway.
>
> did i miss something?!
>
> thanks anyway, the lcd info is useful to know.
>
> robin
>
—————————————————-

to know the lenght of a drawn line the beginning and the
end point should be enough no? though i am not sure how
we could get the exact end point via mousing.

but feel free to post your problem patch, maybe i can
learn something myself fixing it.

not to self: dont point people to files which are not
online.

#91595
Dec 27, 2006 at 1:12am

the patch i’m working on/planning involves the user drawing lines with the mouse in [lcd], and as such, a ‘straight’ line may not actually be so. I was hoping to count the numbers of pixels covered by the line – say i moved from coordinates 0,0 to 0,100, but via 10,100, the line’s length would be greater than 100.
i need to be able to work out the value in terms of pixels, so i was hoping to just be able to count each output value. as you pointed out, [lcd] outputs on a time-based interval, so it ain’t really much use.

forgive me for not posting it, its a little embarrassing at this stage

thanks for the patch – nice festive colour scheme

robin

#91596
Dec 29, 2006 at 8:00pm

What about using mousestate to read the coordinate values where you are drawing, then collect and store them into a coll or something? Looks like mousestate can output every bang, so 1 ms. is lot better than 20 ms (if you want finer resolution).

Using LCD you can read when it’s clicked, this starts the metro/mousestate and begins collecting the coordinate data, then releasing will stop the metro. You’d have a list of your coordinates, though they would be time-based. Guess you could use a *change* object in the stream to filter out times that you don’t move within the polling period.

Hm, this would be a nice way to record gestural motions on the screen to use for lots of stuff like musical parameters too. Of course, an mtr and a 2D slider would do it too. You might consider mtr as a possible tool for recording your information too, the textfile has all the info you need (though maybe a bit awkward to parse through).

–CJ

#91597
Dec 29, 2006 at 8:53pm

hey. thanks for the idea. i think though, that unless i can measure the exact amount of pixels drawn in a line, then i can’t use pythag to compare it to a straight line between those two points. with both [mousestate] and [lcd], i still end up with diagonal lines that appear to be shorter than the hypotenuse, which is obviously impossible. i may have to rethink the approach for this

thanks

#91598
Dec 29, 2006 at 9:21pm

…oh, and you talked about how it would be a nice way to record gestures. i made this thing a while ago. it records gesture and plays it back, preserving the timing

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 263 86 195 196617 5. press p (turns itself off after playing);
#P comment 263 72 87 196617 4. press r again;
#P comment 263 58 87 196617 3. draw in the lcd;
#P comment 263 44 139 196617 2. press r to start recording.;
#P newex 45 71 92 196617 select 112 114 99;
#P newex 45 46 38 196617 key;
#P message 566 147 61 196617 pensize 2 2;
#P newex 526 118 48 196617 loadbang;
#P message 526 147 35 196617 idle 1;
#P message 307 147 33 196617 clear;
#P user lcd 352 184 320 320 1 1 1 0 0;
#P message 352 147 65 196617 lineto \$1 \$2;
#P message 431 147 73 196617 moveto \$1 \$2;
#P button 181 103 15 0;
#P comment 198 103 30 196617 reset;
#P message 99 233 14 196617 0;
#P comment 134 103 36 196617 record;
#P number 72 131 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 45 103 15 0;
#P toggle 117 103 15 0;
#P comment 62 103 25 196617 play;
#P button 71 376 15 0;
#P message 71 413 33 196617 clear;
#P newex 71 509 27 196617 + 1;
#P newex 71 540 44 196617 gate 2;
#P newex 71 479 44 196617 zl nth 3;
#P number 297 376 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#N coll ;
#P newobj 71 446 53 196617 coll;
#P newex 153 413 156 196617 pack 0 0 0 0;
#P flonum 249 376 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 201 376 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 201 343 58 196617 unpack 0 0;
#N vpatcher 10 59 217 252;
#P window setfont “Sans Serif” 9.;
#P comment 10 13 181 196617 this was the only way i could be bothered to think of to allow me to turn off the metro when the counter had gone through the amount of coll entries. the max carry flag seemed to reset the counter to 0 regardless of what i did;
#P comment 10 104 181 196617 the counter which is only counting when the mouse movement is being recorded sets the max count , and the select. the select bangs on the max count to turn the counter off. wabadoosh!;
#P pop;
#P newobj 94 293 37 196617 p note;
#P newex 45 293 37 196617 select;
#P message 159 165 14 196617 0;
#P number 117 233 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#N counter;
#X flags 0 0;
#P newobj 45 261 82 196617 counter;
#P newex 45 233 37 196617 metro;
#N counter;
#X flags 0 0;
#P newobj 117 199 66 196617 counter;
#P newex 117 165 37 196617 metro;
#P comment 263 30 100 196617 1. press c to reset;
#P connect 35 0 36 0;
#P connect 36 0 22 0;
#P fasten 7 0 22 0 50 315 40 315 40 97 50 97;
#P connect 22 0 3 0;
#P connect 3 0 4 0;
#P connect 4 0 7 0;
#P fasten 27 0 19 0 186 366 76 366;
#P connect 19 0 18 0;
#P fasten 4 0 13 0 50 285 28 285 28 437 76 437;
#P connect 12 0 13 0;
#P connect 18 0 13 0;
#P connect 13 0 15 0;
#P connect 15 0 17 0;
#P connect 17 0 16 0;
#P connect 23 0 3 1;
#P connect 5 0 7 1;
#P connect 25 0 4 3;
#P connect 15 1 16 1;
#P fasten 36 1 21 0 77 95 122 95;
#P connect 21 0 1 0;
#P connect 1 0 2 0;
#P connect 2 0 5 0;
#P connect 5 0 4 4;
#P connect 23 0 1 1;
#P fasten 2 0 12 0 122 224 158 224;
#P connect 27 0 6 0;
#P connect 6 0 2 3;
#P fasten 36 2 27 0 104 95 186 95;
#P fasten 30 1 9 0 460 513 337 513 337 336 206 336;
#P fasten 30 0 9 0 357 513 337 513 337 336 206 336;
#P connect 9 0 10 0;
#P connect 10 0 12 1;
#P connect 9 1 11 0;
#P connect 11 0 12 2;
#P fasten 30 2 14 0 563 513 337 513 337 336 302 336;
#P fasten 1 0 14 0 122 189 302 189;
#P connect 14 0 12 3;
#P fasten 22 0 31 0 50 127 312 127;
#P fasten 16 1 29 0 110 565 345 565 345 143 357 143;
#P fasten 32 0 30 0 531 172 357 172;
#P fasten 29 0 30 0 357 172 357 172;
#P fasten 28 0 30 0 436 172 357 172;
#P fasten 34 0 30 0 571 172 357 172;
#P connect 31 0 30 0;
#P fasten 16 0 28 0 76 565 345 565 345 143 436 143;
#P connect 33 0 32 0;
#P connect 33 0 34 0;
#P window clipboard copycount 41;

#91599
Dec 29, 2006 at 9:42pm

Robin,

Each time I discover something new for lcd, I think this is one of
the most full-featured object of Max.
A user lib (a la Reaktor) should exist for storing a such great
patcher!!!

Well-done ;-)
Philippe

#91600
Dec 29, 2006 at 10:30pm

Hey, that recordable patch is great. Nicely done, there’s definitely some potential for using that in other patches. Good use of counter, coll, and the LCD.

I’m thinking that the playback of it could be nicely coordinated with something underneath, like a frequency/timbre 2D plot, or a “level-of-effect” area that would send the coordinates to sound generators or wavefile playback signals. This way there would be a visual indication of where the levels are at during playback.

How might you make this real-time-eraseable, that is, have a trail of some length behind the current point, but the rest disappears after a moment or two? ;-)

This way the LCD would stay “clean”….

–CJ

#91601
Dec 29, 2006 at 10:51pm

So, i’m just gonna give you this patch.
It’s true that if you don’t draw your curve very slowly, it seems like you can’t get all the values for each pixel.

Well, with this patch, you can do it…

Have a look at it and let me know if it helps :-)
Seb.

***patch***

max v2;
#N vpatcher 15 50 894 671;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 211 89 50 196617 loadbang;
#P message 162 204 50 196617 color 35;
#P window setfont “Lucida Grande” 9.;
#P newex 499 81 28 67108873 i;
#P newex 651 169 57 67108873 pack 0 0;
#P newex 657 123 27 67108873 + 3;
#P newex 309 169 57 67108873 pack 0 0;
#P window setfont “Sans Serif” 9.;
#P message 466 212 80 196617 getpixel \$1 \$2;
#P window setfont “Lucida Grande” 9.;
#P newex 342 123 27 67108873 – 3;
#P newex 466 123 27 67108873 + 1;
#P newex 354 169 57 67108873 pack 0 0;
#P newex 387 123 27 67108873 – 2;
#P newex 592 169 57 67108873 pack 0 0;
#P newex 612 123 27 67108873 + 2;
#P newex 466 155 57 67108873 pack 0 0;
#P newex 533 169 57 67108873 pack 0 0;
#P newex 399 169 57 67108873 pack 0 0;
#P newex 432 123 27 67108873 – 1;
#P newex 566 123 27 67108873 + 1;
#P window setfont “Sans Serif” 9.;
#P message 73 272 50 196617 clear;
#P window setfont “Lucida Grande” 9.;
#P number 60 142 35 9 0 0 0 1024 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 2;
#P comment 27 113 134 196617 On cherche pour X = 1 un Y donnant un pixel de couleur;
#P window setfont “Lucida Grande” 9.;
#P window linecount 1;
#P newex 693 529 57 67108873 pack 0 0;
#P message 693 551 119 67108873 setpixel \$2 \$1 255 0 0;
#P message 647 528 31 67108873 dump;
#P newex 616 418 51 67108873 route 0;
#P newex 676 463 27 67108873 t i i;
#P message 648 491 27 67108873 clear;
#N coll ;
#P newobj 693 507 111 67108873 coll;
#P newex 693 485 53 67108873 pack 0 0;
#P newex 616 441 131 67108873 unpack 0 0 0;
#P window setfont “Sans Serif” 9.;
#P message 60 160 80 196617 getpixel 1 \$1;
#P window setfont “Lucida Grande” 9.;
#P newex 616 395 61 67108873 route 255;
#P newex 616 373 64 67108873 route pixel;
#P number 45 68 35 9 0 0 0 1024 0 0 0 221 221 221 222 222 222 0 0 0;
#P button 15 67 15 0;
#P newex 15 86 40 67108873 uzi 110;
#P window setfont “Sans Serif” 9.;
#P window linecount 2;
#P comment 45 39 87 196617 la taille vertical du LCD – 1 pixel;
#P user lcd 184 257 444 111 1 1 0 0 0;
#P comment 133 39 100 196617 the height of lcd – 1 pixel;
#P window linecount 3;
#P comment 164 114 100 196617 we’re searching , for X=1 , a Y giving a colored pixel;
#P window linecount 6;
#P comment 193 392 229 196617 1- draw your curve ; 2- press bang at uzi ; 3- open coll and check there’s something in it ; 4- clear lcd ; 5- press dump (coll) ; Your curve should be redrawn :-);
#P connect 6 0 5 0;
#P connect 7 0 5 1;
#P connect 5 2 10 0;
#P connect 21 0 10 0;
#P connect 40 0 39 0;
#P connect 39 0 3 0;
#P connect 34 0 3 0;
#P connect 10 0 3 0;
#P fasten 18 0 3 0 698 571 172 571 172 242 189 242;
#P connect 22 0 3 0;
#P connect 32 0 35 0;
#P connect 38 0 33 0;
#P connect 32 0 31 0;
#P connect 33 0 35 1;
#P connect 38 0 30 0;
#P connect 32 0 25 0;
#P connect 30 0 31 1;
#P connect 38 0 24 0;
#P connect 24 0 25 1;
#P connect 15 0 32 0;
#P connect 32 0 27 0;
#P connect 35 0 34 0;
#P connect 31 0 34 0;
#P connect 25 0 34 0;
#P connect 27 0 34 0;
#P connect 26 0 34 0;
#P connect 29 0 34 0;
#P connect 37 0 34 0;
#P connect 11 2 38 0;
#P connect 38 0 27 1;
#P connect 32 0 26 0;
#P connect 38 0 23 0;
#P connect 23 0 26 1;
#P connect 32 0 29 0;
#P connect 38 0 28 0;
#P connect 3 3 8 0;
#P connect 8 0 9 0;
#P connect 9 0 16 0;
#P connect 16 0 11 0;
#P connect 28 0 29 1;
#P connect 32 0 37 0;
#P connect 38 0 36 0;
#P connect 11 1 15 0;
#P connect 15 1 12 0;
#P connect 12 0 13 0;
#P connect 14 0 13 0;
#P connect 17 0 13 0;
#P connect 13 0 19 0;
#P connect 19 0 18 0;
#P connect 36 0 37 1;
#P connect 11 2 12 1;
#P connect 13 1 19 1;
#P pop;

#91602
Dec 29, 2006 at 11:13pm

Seb, maybe i’m being dense, but i can’t seem to get anything in the coll. if it works, i might fly to france and kiss you.

thanks to seejayjames and Philippe for their kind words about the lcd record patch.

#91603
Dec 30, 2006 at 12:41am

> i can’t seem to get anything in the coll.
> if it works, i might fly to france and kiss you.

- “No kiss, non non!”
- “But why?”
- “The patcher posted by seb doesn’t work.”

Bogus ;-)
Philippe

#91604
Dec 30, 2006 at 9:04am

Roman Thilenius wrote:
> not to self: dont point people to files which are not
> online.

They are not ready… (the + 0.5 creates a result 0.5 too big… ;-)

Stefan

Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com

#91605
Dec 30, 2006 at 11:15pm

what’s wrong with my patch ?
It works perfectly fine here ! please let me know

#91606
Dec 30, 2006 at 11:18pm

Try to re-enter 110 in the number box before you press the bang !!
I tried and it works just fine !!

#91607
Dec 30, 2006 at 11:33pm

Nothing gets fed into the coll.

Andreas.

tworowski.sebastien skrev:
> what’s wrong with my patch ?
> It works perfectly fine here ! please let me know
> –
> serious : http://www.synart.org
>
> a lot less serious :
> – http://www.bloghotel.org/oulchenowski
> – http://www.bloghotel.org/tworowski
>
> .
>
>

#91608
Dec 30, 2006 at 11:37pm

Nope. Still doesn’t work.

A.

tworowski.sebastien skrev:
> Try to re-enter 110 in the number box before you press the bang !!
> I tried and it works just fine !!
>
> –
> serious : http://www.synart.org
>
> a lot less serious :
> – http://www.bloghotel.org/oulchenowski
> – http://www.bloghotel.org/tworowski
>
> .
>
>

#91609
Dec 30, 2006 at 11:41pm

Ditto.

MaxMSP 4.6.2 over OSX.4.8

#91610
Dec 30, 2006 at 11:53pm

ditto

ditto specs

#91611
Dec 31, 2006 at 12:20am

Make sure you press [loadbang] after pasting this patcher from text.
The number doesn’t bang unless the patch is loaded.

Works fine after that.

b

robin foster wrote:
> ditto
>
> ditto specs
>

barry threw :: sound | (if you would see the stars clearly,
http://www.barrythrew.com | look hard at the surrounding darkness)
bthrew(at)gmail(dot)com | -Ooka Makoto
857-544-3967 |

#91612
Dec 31, 2006 at 10:10am

Make sure your first pixel is part of the curve as we’re starting the search from the first pixel.
If there’s nothing, it won’t work.

Honestly, i copied the code i sent and made it work just perfectly !

1- open the patch
2- draw your curve (starting with the fisrt pixel)
3- enter 110 in the number box
4- press bang (you should have all the coords in coll)
5- clear lcd
6- press dump

htw

#91613
Dec 31, 2006 at 12:01pm

weird, banging the uzi crashes max…

tworowski.sebastien skrev:
> Make sure your first pixel is part of the curve as we’re starting the search from the first pixel.
> If there’s nothing, it won’t work.
>
> Honestly, i copied the code i sent and made it work just perfectly !
>
> 1- open the patch
> 2- draw your curve (starting with the fisrt pixel)
> 3- enter 110 in the number box
> 4- press bang (you should have all the coords in coll)
> 5- clear lcd
> 6- press dump
>
> htw
> –
> serious : http://www.synart.org
>
> a lot less serious :
> – http://www.bloghotel.org/oulchenowski
> – http://www.bloghotel.org/tworowski
>
> .
>
>

#91614
Dec 31, 2006 at 12:14pm

Quote: Wetterberg wrote on Sun, 31 December 2006 13:01
—————————————————-
> weird, banging the uzi crashes max…

Me too.
Put a print on the left outlet of [route 0]…
Then put it on the right outlet…

#91615
Dec 31, 2006 at 12:19pm

Well, it worked for me after I drew the line from the very beginning of the lcd. Only the x coordinates are stored though??

#91616

You must be logged in to reply to this topic.