Forums > Jitter

UDP and Jitter weirdness

March 22, 2010 | 4:04 am

Hi All
While trying to trigger different frames of a quicktime movie over a network, I came across a strange quirk, that appears to happen for every jit.matrix object. Essentialy, it refuses to output a matrix more than once per "trigger event", no matter how many times it was actually banged. This happens only when the command comes through udpsend- when testing locally and transmitting it through "send" it works fine. I assume this has something to do with the scheduler- would love to know how to get around this.

Attached is a simple example patch, using localhost for the udp send/receive pair.
many thanks!
Nadav

{
"boxes" : [ {
"box" : {
"maxclass" : "gswitch2",
"numinlets" : 2,
"id" : "obj-18",
"int" : 1,
"numoutlets" : 2,
"outlettype" : [ "", "" ],
"patching_rect" : [ 25.0, 218.0, 39.0, 32.0 ]
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "r planB",
"numinlets" : 0,
"id" : "obj-17",
"fontname" : "Arial",
"numoutlets" : 1,
"outlettype" : [ "" ],
"fontsize" : 12.0,
"patching_rect" : [ 307.0, 54.0, 49.0, 20.0 ]
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "s planB",
"numinlets" : 1,
"id" : "obj-14",
"fontname" : "Arial",
"numoutlets" : 0,
"fontsize" : 12.0,
"patching_rect" : [ 45.0, 257.0, 51.0, 20.0 ]
}

}
, {
"box" : {
"maxclass" : "comment",
"text" : "enter a number in the yellow box and see how though the number and bang are triggered twice, the matrix is only output once. Why? how can I get around that?",
"linecount" : 6,
"numinlets" : 1,
"id" : "obj-13",
"fontname" : "Arial",
"numoutlets" : 0,
"fontsize" : 12.0,
"patching_rect" : [ 377.0, 50.0, 168.0, 89.0 ]
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "route test",
"numinlets" : 1,
"id" : "obj-12",
"fontname" : "Arial",
"numoutlets" : 2,
"outlettype" : [ "", "" ],
"fontsize" : 12.0,
"patching_rect" : [ 205.0, 103.0, 61.0, 20.0 ]
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "udpreceive 8400",
"numinlets" : 1,
"id" : "obj-11",
"fontname" : "Arial",
"numoutlets" : 1,
"outlettype" : [ "" ],
"fontsize" : 12.0,
"patching_rect" : [ 205.0, 54.0, 99.0, 20.0 ]
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "t i i",
"numinlets" : 1,
"id" : "obj-16",
"fontname" : "Arial",
"numoutlets" : 2,
"outlettype" : [ "int", "int" ],
"fontsize" : 12.0,
"patching_rect" : [ 46.0, 88.0, 32.5, 20.0 ]
}

}
, {
"box" : {
"maxclass" : "number",
"numinlets" : 1,
"id" : "obj-15",
"fontname" : "Arial",
"numoutlets" : 2,
"bgcolor" : [ 0.945098, 0.913725, 0.407843, 1.0 ],
"outlettype" : [ "int", "bang" ],
"fontsize" : 12.0,
"patching_rect" : [ 46.0, 52.0, 50.0, 20.0 ]
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "_ test",
"numinlets" : 1,
"id" : "obj-9",
"fontname" : "Arial",
"numoutlets" : 1,
"outlettype" : [ "" ],
"fontsize" : 12.0,
"patching_rect" : [ 45.0, 166.0, 40.0, 20.0 ]
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "udpsend 127.0.0.1 8400",
"numinlets" : 1,
"id" : "obj-8",
"fontname" : "Arial",
"numoutlets" : 0,
"fontsize" : 12.0,
"patching_rect" : [ 23.0, 296.0, 140.0, 20.0 ]
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "print b",
"numinlets" : 1,
"id" : "obj-10",
"fontname" : "Arial",
"numoutlets" : 0,
"fontsize" : 12.0,
"patching_rect" : [ 219.0, 204.0, 44.0, 20.0 ]
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "print i",
"numinlets" : 1,
"id" : "obj-7",
"fontname" : "Arial",
"numoutlets" : 0,
"fontsize" : 12.0,
"patching_rect" : [ 283.0, 206.0, 40.0, 20.0 ]
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "print j",
"numinlets" : 1,
"id" : "obj-6",
"fontname" : "Arial",
"numoutlets" : 0,
"fontsize" : 12.0,
"patching_rect" : [ 254.0, 259.0, 40.0, 20.0 ]
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "t b i",
"numinlets" : 1,
"id" : "obj-5",
"fontname" : "Arial",
"numoutlets" : 2,
"outlettype" : [ "bang", "int" ],
"fontsize" : 12.0,
"patching_rect" : [ 205.0, 143.0, 32.5, 20.0 ]
}

}
, {
"box" : {
"maxclass" : "jit.pwindow",
"numinlets" : 1,
"id" : "obj-4",
"numoutlets" : 2,
"outlettype" : [ "", "" ],
"patching_rect" : [ 205.0, 290.0, 80.0, 60.0 ]
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "jit.noise 4 char 320 240",
"numinlets" : 1,
"id" : "obj-3",
"fontname" : "Arial",
"numoutlets" : 2,
"outlettype" : [ "jit_matrix", "" ],
"fontsize" : 12.0,
"patching_rect" : [ 205.0, 229.0, 135.0, 20.0 ]
}

}
, {
"box" : {
"maxclass" : "number",
"numinlets" : 1,
"id" : "obj-2",
"fontname" : "Arial",
"numoutlets" : 2,
"outlettype" : [ "int", "bang" ],
"fontsize" : 12.0,
"patching_rect" : [ 283.0, 179.0, 50.0, 20.0 ]
}

}
],
"lines" : [ {
"patchline" : {
"source" : [ "obj-11", 0 ],
"destination" : [ "obj-12", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-18", 0 ],
"destination" : [ "obj-8", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-18", 1 ],
"destination" : [ "obj-14", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-9", 0 ],
"destination" : [ "obj-18", 1 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-17", 0 ],
"destination" : [ "obj-12", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-3", 0 ],
"destination" : [ "obj-4", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-5", 1 ],
"destination" : [ "obj-2", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-2", 0 ],
"destination" : [ "obj-7", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-3", 0 ],
"destination" : [ "obj-6", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-5", 0 ],
"destination" : [ "obj-10", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-5", 0 ],
"destination" : [ "obj-3", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-16", 0 ],
"destination" : [ "obj-9", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-16", 1 ],
"destination" : [ "obj-9", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-15", 0 ],
"destination" : [ "obj-16", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-12", 0 ],
"destination" : [ "obj-5", 0 ],
"hidden" : 0,
"midpoints" : [ ]
}

}
]
}


March 22, 2010 | 2:47 pm

a workaround would be to place a deferlow just below your udpreceive.

-Ben


March 22, 2010 | 6:35 pm

Thanks- this indeed works, both with defer and deferlow.
A question about how it works though, as I’m not sure I fully understand how priority queuing works:

Since I’m using the udp communication to send frame commands to quicktime players spread across several machines, who have to all be totally synchronized (I’m driving the udp commands from an audio signal sampled via snapshot~ every 33 ms, that has to stay synced to the video), won’t deferring the messages to low priority make the synchronization less accurate?


March 23, 2010 | 5:59 pm

All Jitter processing takes place in the low priority main application thread for QT and OpenGL, so there’s no additional penalty for using defer. udp objects output in the high priority scheduler thread.


March 23, 2010 | 6:00 pm

p.s. deferlow is better to use, as defer has the potential to reverse message order (placing each element on the front of the queue rather than the end). Also for filtering a single stream, you may find qlim useful, but you should split your udp streams before using qlim.

Hope that helps.


March 24, 2010 | 10:35 pm

thanks for clarifying that Joshua! am using deferlow now and it works fine.


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