[HELP! urgent :(] Compare 3 values and export unique message
Hi. Currently I'm making some timbre changing sound through the color ratio of video.
Now I have 3 inlet values that keep changing like [ i ] [ i ] [ i ]. (These are ratio of R, G, B)
And I want to pick up the maximum value and also want to export the name of the color.
so if [3000] [5000] [4000] are there, I want to export [5000] and also the message says 'Green'.
I tried with maximum object but couldn't find the way to export message says one of the color.
I think it seems quite simple in my brain but cannot make a proper patch :(
Please Help !
I solved to export the message!
{
"boxes" : [ {
"box" : {
"maxclass" : "button",
"outlettype" : [ "bang" ],
"patching_rect" : [ 349.5, 627.0, 24.0, 24.0 ],
"numinlets" : 1,
"style" : "",
"presentation_rect" : [ 350.0, 626.0, 0.0, 0.0 ],
"numoutlets" : 1,
"id" : "obj-102"
}
}
, {
"box" : {
"maxclass" : "button",
"outlettype" : [ "bang" ],
"patching_rect" : [ 254.25, 627.0, 24.0, 24.0 ],
"numinlets" : 1,
"style" : "",
"presentation_rect" : [ 264.0, 626.0, 0.0, 0.0 ],
"numoutlets" : 1,
"id" : "obj-101"
}
}
, {
"box" : {
"maxclass" : "button",
"outlettype" : [ "bang" ],
"patching_rect" : [ 170.0, 627.0, 24.0, 24.0 ],
"numinlets" : 1,
"style" : "",
"numoutlets" : 1,
"id" : "obj-100"
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "if $i1 == $i2 then blue",
"outlettype" : [ "" ],
"patching_rect" : [ 462.0, 369.0, 125.0, 22.0 ],
"numinlets" : 2,
"style" : "",
"presentation_rect" : [ 462.0, 371.0, 0.0, 0.0 ],
"numoutlets" : 1,
"id" : "obj-96"
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "blue",
"outlettype" : [ "" ],
"patching_rect" : [ 270.25, 444.0, 50.0, 22.0 ],
"numinlets" : 2,
"style" : "",
"numoutlets" : 1,
"id" : "obj-95"
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "if $i1 == $i2 then green",
"outlettype" : [ "" ],
"patching_rect" : [ 318.0, 369.0, 133.0, 22.0 ],
"numinlets" : 2,
"style" : "",
"numoutlets" : 1,
"id" : "obj-93"
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "if $i1 == $i2 then red",
"outlettype" : [ "" ],
"patching_rect" : [ 173.75, 369.0, 120.0, 22.0 ],
"numinlets" : 2,
"style" : "",
"numoutlets" : 1,
"id" : "obj-92"
}
}
, {
"box" : {
"maxclass" : "flonum",
"outlettype" : [ "", "bang" ],
"patching_rect" : [ 242.5, 321.0, 50.0, 22.0 ],
"numinlets" : 1,
"style" : "",
"parameter_enable" : 0,
"numoutlets" : 2,
"format" : 6,
"id" : "obj-81"
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "maximum",
"outlettype" : [ "int", "int" ],
"patching_rect" : [ 242.5, 291.0, 63.0, 22.0 ],
"numinlets" : 2,
"style" : "",
"numoutlets" : 2,
"id" : "obj-79"
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "pack 0 0 0",
"outlettype" : [ "" ],
"patching_rect" : [ 242.5, 260.0, 150.0, 22.0 ],
"numinlets" : 3,
"style" : "",
"numoutlets" : 1,
"id" : "obj-78"
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "3",
"outlettype" : [ "" ],
"patching_rect" : [ 346.75, 573.0, 29.5, 22.0 ],
"numinlets" : 2,
"style" : "",
"presentation_rect" : [ 349.5, 452.0, 0.0, 0.0 ],
"numoutlets" : 1,
"id" : "obj-77"
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "2",
"outlettype" : [ "" ],
"patching_rect" : [ 254.25, 573.0, 29.5, 22.0 ],
"numinlets" : 2,
"style" : "",
"presentation_rect" : [ 250.0, 453.0, 0.0, 0.0 ],
"numoutlets" : 1,
"id" : "obj-76"
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "1",
"outlettype" : [ "" ],
"patching_rect" : [ 173.75, 573.0, 29.5, 22.0 ],
"numinlets" : 2,
"style" : "",
"numoutlets" : 1,
"id" : "obj-75"
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "sel red",
"outlettype" : [ "bang", "" ],
"patching_rect" : [ 173.75, 528.0, 47.0, 22.0 ],
"numinlets" : 2,
"style" : "",
"numoutlets" : 2,
"id" : "obj-73"
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "sel blue",
"outlettype" : [ "bang", "" ],
"patching_rect" : [ 346.75, 528.0, 52.0, 22.0 ],
"numinlets" : 2,
"style" : "",
"numoutlets" : 2,
"id" : "obj-72"
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "sel green",
"outlettype" : [ "bang", "" ],
"patching_rect" : [ 254.25, 528.0, 60.0, 22.0 ],
"numinlets" : 2,
"style" : "",
"numoutlets" : 2,
"id" : "obj-66"
}
}
, {
"box" : {
"maxclass" : "number",
"outlettype" : [ "", "bang" ],
"patching_rect" : [ 398.0, 217.0, 67.0, 22.0 ],
"numinlets" : 1,
"style" : "",
"parameter_enable" : 0,
"presentation_rect" : [ 372.0, 226.0, 0.0, 0.0 ],
"numoutlets" : 2,
"id" : "obj-43"
}
}
, {
"box" : {
"maxclass" : "number",
"outlettype" : [ "", "bang" ],
"patching_rect" : [ 308.0, 217.0, 50.0, 22.0 ],
"numinlets" : 1,
"style" : "",
"parameter_enable" : 0,
"presentation_rect" : [ 304.0, 232.0, 0.0, 0.0 ],
"numoutlets" : 2,
"id" : "obj-42"
}
}
, {
"box" : {
"maxclass" : "number",
"outlettype" : [ "", "bang" ],
"patching_rect" : [ 198.0, 217.0, 50.0, 22.0 ],
"numinlets" : 1,
"style" : "",
"parameter_enable" : 0,
"numoutlets" : 2,
"id" : "obj-41"
}
}
, {
"box" : {
"maxclass" : "toggle",
"outlettype" : [ "int" ],
"patching_rect" : [ 318.0, 74.0, 24.0, 24.0 ],
"numinlets" : 1,
"style" : "",
"parameter_enable" : 0,
"numoutlets" : 1,
"id" : "obj-39"
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "metro 1000",
"outlettype" : [ "bang" ],
"patching_rect" : [ 308.0, 137.0, 71.0, 22.0 ],
"numinlets" : 2,
"style" : "",
"numoutlets" : 1,
"id" : "obj-37"
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "random 2000",
"outlettype" : [ "int" ],
"patching_rect" : [ 398.0, 184.0, 81.0, 22.0 ],
"numinlets" : 2,
"style" : "",
"numoutlets" : 1,
"id" : "obj-36"
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "random 2000",
"outlettype" : [ "int" ],
"patching_rect" : [ 308.0, 184.0, 81.0, 22.0 ],
"numinlets" : 2,
"style" : "",
"numoutlets" : 1,
"id" : "obj-35"
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "random 2000",
"outlettype" : [ "int" ],
"patching_rect" : [ 198.0, 180.0, 81.0, 22.0 ],
"numinlets" : 2,
"style" : "",
"numoutlets" : 1,
"id" : "obj-34"
}
}
],
"lines" : [ {
"patchline" : {
"source" : [ "obj-77", 0 ],
"destination" : [ "obj-102", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-76", 0 ],
"destination" : [ "obj-101", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-75", 0 ],
"destination" : [ "obj-100", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-95", 0 ],
"destination" : [ "obj-72", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-95", 0 ],
"destination" : [ "obj-66", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-95", 0 ],
"destination" : [ "obj-73", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-37", 0 ],
"destination" : [ "obj-95", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-43", 0 ],
"destination" : [ "obj-96", 1 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-81", 0 ],
"destination" : [ "obj-96", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-42", 0 ],
"destination" : [ "obj-93", 1 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-81", 0 ],
"destination" : [ "obj-93", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-93", 0 ],
"destination" : [ "obj-95", 1 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-96", 0 ],
"destination" : [ "obj-95", 1 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-92", 0 ],
"destination" : [ "obj-95", 1 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-41", 0 ],
"destination" : [ "obj-92", 1 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-81", 0 ],
"destination" : [ "obj-92", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-39", 0 ],
"destination" : [ "obj-37", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-37", 0 ],
"destination" : [ "obj-34", 0 ],
"hidden" : 0,
"midpoints" : [ 317.5, 169.0, 207.5, 169.0 ],
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-37", 0 ],
"destination" : [ "obj-35", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-37", 0 ],
"destination" : [ "obj-36", 0 ],
"hidden" : 0,
"midpoints" : [ 317.5, 171.0, 407.5, 171.0 ],
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-79", 0 ],
"destination" : [ "obj-81", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-78", 0 ],
"destination" : [ "obj-79", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-43", 0 ],
"destination" : [ "obj-78", 2 ],
"hidden" : 0,
"midpoints" : [ 407.5, 249.0, 383.0, 249.0 ],
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-42", 0 ],
"destination" : [ "obj-78", 1 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-41", 0 ],
"destination" : [ "obj-78", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-72", 0 ],
"destination" : [ "obj-77", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-66", 0 ],
"destination" : [ "obj-76", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-73", 0 ],
"destination" : [ "obj-75", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-36", 0 ],
"destination" : [ "obj-43", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-35", 0 ],
"destination" : [ "obj-42", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-34", 0 ],
"destination" : [ "obj-41", 0 ],
"hidden" : 0,
"disabled" : 0
}
}
],
"appversion" : {
"major" : 7,
"minor" : 2,
"revision" : 3,
"architecture" : "x64",
"modernui" : 1
}
,
"styles" : [ {
"name" : "Luca",
"default" : {
"bgfillcolor" : {
"type" : "gradient",
"color" : [ 0.290196, 0.309804, 0.301961, 1.0 ],
"color1" : [ 0.862745, 0.870588, 0.878431, 1.0 ],
"color2" : [ 0.65098, 0.666667, 0.662745, 1.0 ],
"angle" : 270.0,
"proportion" : 0.39,
"autogradient" : 0
}
,
"selectioncolor" : [ 0.720698, 0.16723, 0.080014, 1.0 ],
"color" : [ 0.475135, 0.293895, 0.251069, 1.0 ],
"textcolor_inverse" : [ 0.239216, 0.254902, 0.278431, 1.0 ],
"fontname" : [ "Open Sans Semibold" ],
"bgcolor" : [ 0.904179, 0.895477, 0.842975, 0.56 ],
"accentcolor" : [ 0.32549, 0.345098, 0.372549, 1.0 ],
"elementcolor" : [ 0.786675, 0.801885, 0.845022, 1.0 ]
}
,
"parentstyle" : "",
"multi" : 0
}
]
}
Hi Juhna,
while your solution if fine, there is one error that Isee. The [numberbox] for the red color (the first one) sends its value first to the pack object, triggering it to output and in turn the maximum etc, and THEN it sends the red value to the first [if $i1 == $i2 the red].
That means that the comparison is made with the previous red value, so unless its the same by luck, it would not output the correct color.
To avoid that kind of "priority" problems, use the [trigger] object to ensure the order of the connections!
A bit more elegant way would be to use the second [maximum] outlet that outputs the index of the biggest number of the list. Because you know the order of the values corresponds to red-green-blue, you know that the index "0" is when red is the maximum, "1" for green and "2" for blue. Something like that:
Hope this helps,
Nikolas.
PS. I would suggest using the "copy compressed" to post a patch! Select the part of the patch you want to send, and then "edit" -> "copy compressed"!
@NIKOLAS K
Thank you very much NIKOLAS ! Of course I was WRONG :((( lol
Your patch is awesome and really really thank you for your additional advices !