how to pack values for a [line] msg?

Jul 18, 2010 at 9:46am

how to pack values for a [line] msg?

hey…

i want to use a line object to play through a sample file…
i know that line needs a msg with three values
(startpoint, endpoint duration)

lets say i want these values generated randomly…

how do i have to pack those values that the msg will be set up properly?

[pack $1 $2 $3] -> ($1, $2 $3) -> [line] ?

thanks

#51403
Jul 18, 2010 at 10:07am

i use this [sprintf %f, %f %f]

:awaits method that uses 60% less resources:

#184312
Jul 18, 2010 at 10:53am

do the below

#184313
Jul 18, 2010 at 10:56am
– Pasted Max Patch, click to expand. –
#184314
Jul 18, 2010 at 11:05am

‘NEVER do this’ haha

answer me this pid. i have a granular patch with absolutely tonnes of these things going off all the time, continuously, and it runs like clockwork. so where is this ‘ever growing amount of resources’ actually going? just checking activity monitor for max, all values are constant and don’t seem to be increasing at all.

now i’m not saying you’re wrong, as i don’t know the ins and outs of Max’s symbol tables and the like, but for every ‘no don’t do this’ post i usually find i’m doing exactly that, with no problems at all.

enlighten me :)

#184315
Jul 18, 2010 at 12:29pm

oh, maybe ignore me then – i have no great way to ‘enlighten’ when max says one thing and we have to try figure out the other. wait till someone cleverer posts…

#184316
Jul 18, 2010 at 1:14pm

The efficiency of sprintf depends on what you’re doing with it. Every unique symbol in max is stored in RAM, and never free-ed until you close max. So if you’re using it for general formatting of input values, you’re likely going to be adding a large number of unique symbols to RAM, which in theory could begin to waste your memory resources – I don’t know if this applies in the same way to floats and integers………….If you’re using it for message parsing to grab file names or something similar, it’s a more appropriate object to use because you won’t be generating symbols very often.

http://cycling74.com/forums/topic.php?id=16697

So for general purpose things like formatting for line/line~ it’s not the best object to use.

-edit: With sprintf, if you’re using it to format the same things over and over, then it doesn’t really matter that it’s storing into RAM, as you’ll be replacing the same symbols over and over, not adding to it. The reason it does this is to speed up processing of things if done a second time, so in MikeS’s patch, it might be totally appropriate, if it’s not causing problems then why change it :) That’s not to say that there aren’t multiple ways of doing just about everything in max/msp, none of them are “best” in every situation. -

Since coffencigs is wanting to control audio playback, line~ is far more appropriate to use than line. You want to be controlling audio-rate processes at audio rate most of the time, or you’ll end up with clicks and glitches.

The pack>message>line~ method is a perfectly good way of doing it; simple and it works. If you want to be really pedantic, you could say that it’s inefficient because the message object will have to visually refresh often, wasting resources. However this is not something to worry about unless you start running into cpu-limits. I think also, that if you put it in a sub-patch/made it not visible in some other way, then it being a GUI object wouldn’t matter, as it wouldn’t have to refresh.

My advice is to just use pack>message>line~ and not think about all these little worries until you think they might be causing a problem, which is unlikely to happen. If you don’t like message, you could do it like this:

– Pasted Max Patch, click to expand. –
#184317
Jul 18, 2010 at 7:33pm

you can not do it with pack, because you need “float, float float”

i usually put a [t l 0] between my lists and line

-110

#184318
Jul 18, 2010 at 7:38pm

Maybe I’m misreading your post Roman, but are you saying that pack doesn’t work with floats?

#184319
Jul 18, 2010 at 7:55pm

It works with pack and floats :) I’m not sure why you need a [t l 0] before line? That would truncate any input floats to int.

#184320
Jul 18, 2010 at 8:36pm

usually you want to set a line before starting it, right?

maybe i am mistaken, but when i hear something about “line format” i am
thinking of the MSP line~ object, where “float, float float” would the normal
way to trigger it.
and consecutive messages are not to be packed into a list ;)

#184321
Jul 18, 2010 at 9:26pm

I’ve overlooked the fact that [message] will screw with the comma. You need to do it like my example, which I think is pretty much what Roman was suggesting as well. Sorry for the confusion :)

#184322
Jul 19, 2010 at 1:31am

Cheers for clearing that up Raja – I thought it would work!…………..I mis-understood Roman’s reply and double-checked the ($1, $2 $3) way with it outputting to the right inlet of another message, which of course screwed with the comma – making me think it wouldn’t work with line/line~…………….I’m silly :)

#184325
Jul 20, 2010 at 4:31pm

How does this [t l 0] method work?

#184326
Jul 20, 2010 at 4:48pm

It works the same way as my example in my first post, except you’re always sending a value of 0 as a start value for line, while my example has a variable start value.

#184327
Jul 20, 2010 at 5:52pm

gotcha, i’ll see what difference it makes to my patch

#184328
Nov 12, 2010 at 6:37pm

another solution;

– Pasted Max Patch, click to expand. –
#184329
Nov 12, 2010 at 7:07pm

The comma in a message box is just shorthand for separating things. In the discussed case of line~, it is used to send an 0, followed by a list of value time pairs. This is no different from starting your list of pairs with 0 0.

#184330

You must be logged in to reply to this topic.