Forums > MaxMSP

ubumenu & sprintf question

October 11, 2009 | 7:38 pm

hello,
im getting my hands back on maxmsp after a long absence. im still running 4.6.3 on OSX 10.5.8. while trying to use an old patch i had written a long time ago for live performances, i noticed a bug but i cannot figure it out. any help mucho appreciated!
here is the problem:

1. I put samples inside folders, and the folders inside a main folder. For example ’808′ and ’909′ folders containing drum samples, inside a main ‘drum kits’ folder.
2. I want to drag and drop the main folder (‘drum kits’) on a dropfile area, so that the subfolders are listed in an ubumenu. This is very easy to do, since it’s in the help patch for the ubumenu object (the subpatch for the prefix settings).
3. Here is where the problem starts: now I want that whenever I select one of the subfolders in the first ubumenu, for example I select ’909′ with the mouse, then I want that the samples inside it get listed inside a second, different, ubumenu.

I used to do this operation using
– a simple ‘message’ object which stored the main folder path at the moment it was sent to the first ubumenu
– then the subfolder name (outputted by the first ubumenu) was added using the sprintf object which allowed me to combine the two messages (the main folder path + the subfolder name) so that it becomes a subfolder path.

It used to work fine, but today it doesn’t, and I don’t understand why. Comparing the outputs of the two ubumenus (the one for the mainfolder, and the one for the subfolders) using print objects give me exactly the same message in the Max window, but the second ubumenu doesn’t understand it when it comes out of the sprintf object? The only explanation I can imagine would be that sprintf gives a special format to the message, so that ubumenu cannot read it anymore??

Here is the test patch:

max v2;
#N vpatcher 0 44 1013 758;
#P origin -53 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 3;
#P comment 75 601 191 196617 audio files located inside any subfolder selected in the first ubumenu should be listed here , but nothing happens :(;
#P window linecount 1;
#P comment 30 343 191 196617 folders inside folder 1 listed here;
#P comment 57 257 191 196617 test patch to understand where’s the bug;
#P newex 283 409 74 196617 print firstUBU;
#P newex 207 565 69 196617 print 2ndUBU;
#P newex 89 426 63 196617 route prefix;
#P newex 198 451 28 196617 t b s;
#P message 89 480 252 196617 "Macintosh HD:/Users/arturo/Desktop/drum kits/";
#P newex 89 447 60 196617 prepend set;
#P newex 89 526 74 196617 prepend prefix;
#P newex 89 502 72 196617 sprintf %s%s;
#P window setfont Techno 9.;
#P user ubumenu 86 364 80 -622854135 0 1 1 0;
#X add 808;
#X add 909;
#X add bossanova;
#X add TR808HC.AIFF;
#X add TR808MC.AIFF;
#X prefix_set 2 1 "Macintosh HD:/Users/arturo/Desktop/drum kits/" 0;
#P user ubumenu 89 569 80 -622854135 0 1 1 0;
#X add;
#X prefix_set 2 1 Macintosh 0;
#P window setfont "Sans Serif" 9.;
#P number 646 301 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 646 320 48 196617 depth $1;
#P number 614 386 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 614 366 72 196617 route populate;
#P newex 569 319 74 196617 prepend prefix;
#P button 446 296 15 0;
#P newex 537 366 75 196617 print populated;
#P newex 418 215 60 196617 prepend set;
#P user dropfile 275 112 545 131 0 fold;
#P newex 569 298 54 196617 route text;
#P user textedit 599 268 869 287 32896 3 9 "Macintosh HD:/Users/arturo/Desktop/drum kits/";
#P message 492 320 73 196617 autopopulate 1;
#P user ubumenu 493 349 100 196617 0 1 1 0;
#X add 808;
#X add 909;
#X add bossanova;
#X add TR808HC.AIFF;
#X add TR808MC.AIFF;
#X prefix_set 0 1 "Macintosh HD:/Users/arturo/Desktop/drum kits/" 0;
#P newex 537 453 91 196617 print concat_mode;
#P message 492 410 125 196617 prefix per , prefix_mode 0;
#P user ubumenu 492 432 100 196617 0 1 1 0;
#X add manent;
#X add iscope;
#X add snickity;
#X add verted;
#X add muted;
#X prefix_set 0 0 per 0;
#P newex 537 531 95 196617 print prepend_mode;
#P message 492 488 141 196617 prefix french , prefix_mode 1;
#P user ubumenu 492 510 100 196617 0 1 1 0;
#X add bread;
#X add fries;
#X add kiss;
#X add mustard;
#X prefix_set 1 0 french 0;
#P comment 292 94 289 196617 drag and drop a folder on the textedit to populate the ubumenu!;
#P window linecount 2;
#P comment 653 166 100 196617 copy-pasted from the ubumenu help;
#P connect 16 0 22 0;
#P connect 16 0 28 0;
#P connect 28 0 25 0;
#P connect 27 0 26 0;
#P connect 25 0 26 0;
#P connect 26 0 23 0;
#P connect 23 0 24 0;
#P connect 24 0 21 0;
#P connect 27 1 23 1;
#P connect 22 1 27 0;
#P connect 24 0 29 0;
#P connect 16 0 30 0;
#P fasten 12 0 13 0 280 173 423 173;
#P fasten 13 0 15 0 423 264 451 264;
#P connect 6 0 5 0;
#P connect 3 0 2 0;
#P fasten 16 0 8 0 574 340 498 340;
#P connect 9 0 8 0;
#P fasten 19 0 8 0 651 340 498 340;
#P connect 8 1 14 0;
#P connect 5 1 7 0;
#P connect 2 1 4 0;
#P fasten 10 0 11 0 604 292 574 292;
#P connect 11 0 16 0;
#P fasten 13 0 10 0 423 252 604 252;
#P fasten 15 0 10 0 451 315 508 315 508 268 604 268;
#P fasten 8 2 17 0 588 363 619 363;
#P connect 17 0 18 0;
#P connect 20 0 19 0;
#P pop;


October 11, 2009 | 8:27 pm

hi,

your patch looks like it’s working here..
except if i have sub folders with spaces in their names.

this can be fixed by using "symout" argument with sprintf, so you’re sure that it always outputs a symbol (it will add quotes if needed).
[sprintf symout %s%s]

not sure if this is related to your problem though

ciao
_y


October 11, 2009 | 8:32 pm

hi,

thanks a lot for the reply. you say it’s working on your machine? here is what i do:

– open the patch
– drag and drop the main folder (with the subfolders inside)
–> the subfolders names get listed in the first ubumenu
– select one of the subfolder names in the first ubumenu with the computer mouse
–> nothing happens in the second ubumenu at the bottom (a list of the soundfiles inside the selected subfolder should appear inside it)

btw: no spaces in the names of the subfolders here
btw2: i used to add a slash in the sprintf, "sprintf %s%s/", it doesn’t change anything.


October 11, 2009 | 8:37 pm

what is really strange for me is that if i perform the operation twice

1) normally, as described above
2) then i drag and drop the subfolder i wanted to select in the ubumenu, and i compare the print message in Max window

–> the messages sent to the first ubumenu and the second one are exactly the same. how come it doesnt work??


October 11, 2009 | 8:58 pm

this is weird because it works fine here..
(osx, 10.5.7, max-5.0.7)

otherwise, you might want to simplify your patch and see if it’s still not working ?

I would use "concatenate" prefix-mode for the umenu that selects the subfolder (as in the example patch below), or use the "folder depth" option (but it can get nasty if you have a lot of files…)

– Pasted Max Patch, click to expand. –

ciao,
_y


October 12, 2009 | 8:58 am

thanks a lot, if the same patch works fine for you it means it’s a bug somewhere in 4.6.3, and that i can stop trying. thank you very very much for testing it.

i don’t have max5 so i think i cannot use the patch you posted, but i’ll try with the demo or just have a look at concatenate prefix mode. the problem is the amount of soundfiles, this is why i need to split in two separate ubumenus.

best, thanks again
basile


October 12, 2009 | 10:20 am

ah sorry for the format.

here is the patch again (working here on 4.6.3):
(by the way, your 1st patch also works fine on my 4.6.3)

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 144 236 85 196617 prepend prefix;
#P newex 223 313 35 196617 print;
#P user ubumenu 144 269 169 196617 0 1 1 0;
#X setrgb 38 38 38 255 255 255 255 255 255 128 128 128 140 140 140 110 110 110;
#X prefix_set 2 1 0;
#P comment 248 203 206 196617 prefix mode -> concatenate;
#P user ubumenu 65 202 169 196617 0 1 1 0;
#X setrgb 38 38 38 255 255 255 255 255 255 128 128 128 140 140 140 110 110 110;
#X prefix_set 0 1
0;
#P newex 65 164 85 196617 prepend prefix;
#P user dropfile 65 85 335 104 0;
#P noclick;
#P comment 82 67 361 196617 drag and drop a folder on the textedit to populate the ubumenu!;
#P connect 1 0 2 0;
#P connect 2 0 3 0;
#P connect 3 1 7 0;
#P connect 7 0 5 0;
#P connect 5 1 6 0;
#P window clipboard copycount 8;

ciao,
_y


October 13, 2009 | 4:34 pm

sorry i couldn’t work on music the last two days, i just tried your patch. it’s not only 1000 times more elegant and efficient, it also works fine on my computer. i wonder how i possibly missed this function of ubumenu

and if mine works fine on yours, it means i must have a problem with some externals (duplicates whatever), its also good news.

thanks a lot!! im very happy right now Smile


October 13, 2009 | 7:03 pm

i think found the gost: if the ubumenu has been set with a prefix_mode 2 command (for example), then it gets saved with the ubumenu object, although it cannot be seen in its inspector window.

there was a command like this somewhere in the main patch, and it got stored inside the ubumenus objects. what i still don’t understand is why the patch as text works on your computer and not on mine (i tried to open the text myself, it still doesn’t work).

anyway. the patch is too old, thats the problem. need to rewrite everything, tough life.


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