Forums > MaxMSP

how to pack values for a [line] msg?

July 18, 2010 | 9:46 am

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


July 18, 2010 | 10:07 am

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

:awaits method that uses 60% less resources:



pid
July 18, 2010 | 10:53 am

do the below



pid
July 18, 2010 | 10:56 am
– Pasted Max Patch, click to expand. –

July 18, 2010 | 11:05 am

‘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 :)



pid
July 18, 2010 | 12:29 pm

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…


July 18, 2010 | 1:14 pm

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. –

July 18, 2010 | 7:33 pm

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


July 18, 2010 | 7:38 pm

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


July 18, 2010 | 7:55 pm

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.


July 18, 2010 | 8:36 pm

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 ;)


July 18, 2010 | 9:26 pm

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 :)


July 19, 2010 | 1:31 am

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 :)


July 20, 2010 | 4:31 pm

How does this [t l 0] method work?


July 20, 2010 | 4:48 pm

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.


July 20, 2010 | 5:52 pm

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


November 12, 2010 | 6:37 pm

another solution;

– Pasted Max Patch, click to expand. –

November 12, 2010 | 7:07 pm

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.


Viewing 18 posts - 1 through 18 (of 18 total)