packing multiple different data - should I use join with @triggers -1 ?

F_Dos's icon

I'm receiving data consisting of 6 floating-point numbers at a 125 Hz rate via UDP into Max.

Along with these, I’m also packing some other values that change less frequently (though they are initialized when the patch loads).

To ensure the data is as accurate as possible — should I use a [join] object with all inputs hot, or make only the inlets receiving the 125 Hz stream hot?

Another question related to this:
How can I measure the time elapsed between receiving the data over UDP in Max, packing it together with other numbers inside Max, and then sending it out again via UDP? Is there a way I could measure that?

Thanks for any clarification.

Wil's icon

I don't use [join] or [pak]. I have been prepending each data then send/receive then route. It stops one bit of data from re-triggering other bits of data

I don't want re-trigger other data

Not sure about elapsed time

Someone else knows that

Source Audio's icon

You should answer that questin yourself.

do you need to pack or store

1 2 3 4 5 6 aaa

and

1 2 3 4 5 6 bbb

even if 1 2 3 4 5 6 came in only once and only aaa changed to bbb ?

____________________________________

your question about timing...

what should trigger sending of UDP data ?

measured time between received messages

or change in data which you call "other numbers" ?

F_Dos's icon

what should trigger sending of UDP data ?

measured time between received messages

or change in data which you call "other numbers" ?

the received messages

in your example it means it took the data from the UDP 24.9 ms to pass from the udpreceive to farther proccessing?

do you need to pack or store

I need both to store it inside max using coll at regular intervals of 8ms and I also need to pack it before sending it out. the data received from UDP is at regular rate of 125Hz while the "other numbers" usually comes in larger intervals from within max.

Source Audio's icon

if you want to insert a line into coll no matter what came in using 8ms interval,

then use pak or join with triggers -1.

same as to send UDP packets.

when you receive a packet, grab current list and send it away.

but be aware that pak and join keep whatever they received so far.

There is no way to "empty" them.

only to set to some values.

F_Dos's icon

I got confused a little.

let assume two senario in which one: Is receiving only 6 data numbers from two different udp as this:

is this the correct way to join all data together and send it out as well store it into coll?

Max Patch
Copy patch and select New From Clipboard in Max.

second senario:

receiving 6 data numbers from two different udp as well sending some other message in different interval such as this:

Max Patch
Copy patch and select New From Clipboard in Max.

Could you please explain the timer system? what is this output value? the time it takes the data to arrive in Max?

F_Dos's icon

I have been prepending each data then send/receive then route.

@WILL - but if you were needed to store them in the same line? then you must pak them together isn't it?

Source Audio's icon

you are confusing me because every time I give you working answer

you change the question

and new answer is NO !

you should not send to UDP like that.

Wil's icon

your first example can be done more simply prepend into coll

no nee to join anything

I only do like this on occasion when I don't want all to trigger because other bangs cause problems

it should be more efficient if all streams are not always changing

depending on where you com from and where you go

maybe want join

Screen Recording 2025-11-05 at 1.10.01 AM.mp4


looks like you have 2 obviously different situations

1 store in coll

2 send somewhere

It depends on situations

you can send then put directly into coll at the redcieving end


F_Dos's icon

you should not send to UDP like that.

OK I will follow this method.

Regarding my question of:

How can I measure the time elapsed between receiving the data over UDP in Max, packing it together with other numbers inside Max, and then sending it out again via UDP? Is there a way I could measure that?

Is the timer object measure that? could you explain it please? what is this value outputted of the timer? is it the time elapsed since data arrived in Max to when it was sent out?

edit: I also see you pak the timer value alongside the data joined together. why is that? I also see that this timer output is the one the bang the grab object that will pass the data to the udpsend object. Could you please explain that?

Source Audio's icon

"Another question related to this:
How can I measure the time elapsed between receiving the data over UDP in Max, packing it together with other numbers inside Max, and then sending it out again via UDP? Is there a way I could measure that?"

that was exactly your question.

What I posted is exact answer to that.

Needs no further explanations.

F_Dos's icon

What I posted is exact answer to that.


Ok Thanks. is that number is due to computer power or Max limitation? is this value can reduced somehow?

if this values is 25ms and data is passed at 8ms rate it means what? just the latency between samples?

Source Audio's icon

25 ms was send interval of my test messages.

you asked to measure time elapsed between receiving the data over UDP

that is what it does.

You wanted it to be accurate, ok:

we first capture input list, then pack it with measured time.

you wanted to trigger & send joined data when UDP receives something, ok:

we grab current list from zl.reg containing internal data, received data and measured interval.

Can not be more accurate.

If you actually wanted something else, sorry but I can't read your mind,

only what you wrote.

F_Dos's icon

The upper left part is just to imitate data arrived from UDP at 125Hz.

Why there is nothing outputted from timer?

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

onebang 1

you also need to remove typeroute~

I forgot that it is a list and not single int of float

Source Audio's icon

I think it would be better if you explain exactly what you really try to do.

not only parts of it but all.

your last patch has unneeded stuff inside,

@trigger -1 is not needed, also not grab .

F_Dos's icon

onebang 1

I changed it in the patch I shared. Still not working.

I think it would be better if you explain exactly what you really try to do.

The big picture is that I need to collect data from two sensors, each sending UDP packets independently.
Each sensor sends three values: two floating-point numbers and one integer.

Inside Max (Max/MSP), these incoming values need to be:

  1. Combined with additional values generated within Max.

  2. Stored in a coll object at 8 ms intervals.

  3. Packed together and sent out via UDP to another Python process (which I do not have access to).

I’d like to know:

  • What’s the best way to implement this data collection, combination, storage, and re-transmission in Max?

  • How can I measure the time it takes for the data to travel through Max — from the moment it arrives (via UDP) until it’s sent out again?

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

you can not measure time between receive and send.

one can't tell when something really got sent.

only when some object is told to do so.

main question is WHAT SHOULD TRIGGER SENDING OF UDP MESSAGES.

if it is so that you play metronome sound

and want to measure how precise 2 users react to it

(which I remember from many of your previous posts)

then what you are doing is wrong.

what should that list for python script exactly represent ?

if you know that, then you should know how to collect your informations

so that they make sense.

F_Dos's icon

if it is so that you play metronome sound

and want to measure how precise 2 users react to it

Yes, this.

what should that list for python script exactly represent ?

just the data of the two users and the metronome bpm and when it passed from one bpm to another

you can not measure time between receive and send.

one can't tell when something really got sent.

so we have no way to know the time it takes to max processed all data inside it? it is related maybe to vector size? :|

Source Audio's icon

I guess you mean latency of created click .

to measure how long it took user to hear the click and react to it.

yes, that depends on vector size but also Mac / Win drivers etc.

Windows built in hardware is simply a bullshit unless you use ASIO4ALL

or something similar.

there is latency measure patch somewhere in max examples,

I delete that stuff so can't tell you where exactly it is,

but you could simplify it by capturing audio click with mic as close to speakers

where users sit on PC and get time difference from UDP input.

That "listening" PC will also have input latency which has to be taken into account.

with 128/64 I/O and vector size you might expect 10 - 12 ms input latency.

.......................

back to UDP to python :

you should follow advice WILL gave you

and separate input of that 2 users.

otherwise you will have wrong or doubled lists.

F_Dos's icon

The example WILL gave puts each value in different line.

What if I needs all data (from both users) at the same line? meaning to see what value was at a given time (each 8ms intervals)

Source Audio's icon

you will have wrong or doubled lists

F_Dos's icon

correct me if I wrong but in that example (of using prepeand for each value) when the metro is bang the [zl.reg] object only the last changed value will be stored isn't it?

Source Audio's icon

has nothing to do with that

Use your brain

all that objects keep data till it gets changed

If one user reacts to metronome and the other falls asleep, you will keep sending last input values of sleeping user

Only way to get arround this is to set

something like - - - on each metronome bang

and treat it as "missed reaction" in case user did not send anything

F_Dos's icon

Data is passing constantly even if no change is made. Assuming I want to pass the data even if nothing is changed - why I can't use the method I shared in my last uploaded patch?

Source Audio's icon

if you don't care much about what really came in then send whatever you want

F_Dos's icon

I do care.. Is this method in storing data inside max is not correct?

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

you can remove zl.change

it does nothing at that position

at least use same output as to coll for UDP

which would at least reduce output flood

but in my eyes it makes no sense

and I don't want to discuss this any more