a problem with basic scripting

Oct 22, 2008 at 10:19pm

a problem with basic scripting

This has been killing me for the last 4 hours , but i can’t seem to find what the problem is .
I am making an patch in order to be able to open a folder , retrieve the sound files , generate a number of buffers according to the number of sound files, name them in order to access them later , and assign the sound files to the buffers .
The paths for the soundfiles are saved in a coll named mysoundfiles

Although almost everything seems to work fine , when i am trying get the sound files into the buffers , i get an error message that a variable doesn’t exist with that name .
In the manual patcher everything seems to work fine.

Here is the subpatch,
save as : “generatebuffersxx”

max v2;
#N vpatcher 248 164 1211 1073;
#P origin 35 0;
#N comlet ToThisPatcher;
#P outlet 33 238 15 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#N vpatcher 1 25 1045 872;
#P origin -70 0;
#P window setfont “Sans Serif” 9.;
#P newex 33 640 33 9109513 print z;
#P window linecount 1;
#P newex 26 540 149 9109513 sprintf script send %s replace %s;
#N coll mysounds;
#P newobj 106 489 69 9109513 coll mysounds;
#P window setfont “Sans Serif” 18.;
#P comment 153 60 238 9109522 Create the buffers and info~;
#B color 14;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 924 223 206 9240586 sprintf script delete kolosinfo%i;
#P newex 389 389 110 9240586 sprintf mysound%i;
#P window setfont “Sans Serif” 12.;
#P comment 139 361 100 9109516 Place the info~;
#B color 6;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 236 387 122 9240586 sprintf kolosinfo%i;
#P newex 134 419 164 9240586 pack 0 500 objname referto;
#P newex 124 329 104 9240586 expr ($i1*75)+40;
#P window setfont “Sans Serif” 9.;
#P message 134 443 206 9109513 script new $3 newex $1 $2 70 9109513 info~ $4;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 619 391 110 9240586 sprintf mysound%i;
#N comlet Destroy Buffers (bang);
#P inlet 725 70 15 0;
#P window setfont “Sans Serif” 12.;
#P comment 399 358 111 9109516 Place the Buffers;
#B color 6;
#P comment 648 171 77 9109516 Clear Buffers;
#B color 6;
#P button 707 228 15 0;
#P button 295 307 15 0;
#P button 509 359 15 0;
#P window setfont “Sans Serif” 9.;
#P message 918 162 14 9109513 0;
#B color 5;
#P newex 901 123 27 9109513 t b b;
#P newex 478 168 40 9109513 uzi;
#P newex 478 90 40 9109513 t b i;
#P button 725 147 15 0;
#P window setfont “Fixedwidth Serif” 10.;
#N counter 0 0 4;
#X flags 0 0;
#P newobj 725 198 86 9240586 counter 0 0 4;
#P newex 725 226 182 9240586 sprintf script delete kolos%i;
#P newex 725 170 40 9240586 uzi 5;
#P newex 500 388 98 9240586 sprintf kolos%i;
#N counter 0 0 4;
#X flags 0 0;
#P newobj 520 330 86 9240586 counter 0 0 4;
#P newex 379 423 164 9240586 pack 0 400 objname bufname;
#P newex 304 331 104 9240586 expr ($i1*75)+40;
#N counter 0 0 4;
#X flags 0 0;
#P newobj 304 282 83 9240586 counter 0 0 4;
#P window setfont “Sans Serif” 9.;
#P message 379 447 216 9109513 script new $3 newex $1 $2 70 9109513 buffer~ $4;
#P window setfont “Sans Serif” 12.;
#P window linecount 2;
#P comment 932 147 74 9109516 Reset Counters;
#B color 6;
#N comlet Number of Buffers (int);
#P inlet 478 70 15 0;
#N comlet Create Buffers (script);
#P outlet 379 621 15 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 517 91 59 9109513 trigger script;
#B color 14;
#P window setfont “Sans Serif” 18.;
#P window linecount 0;
#P comment 810 53 238 9109522 Destroy the buffers and info~;
#B color 14;
#P fasten 10 0 35 0 505 414 31 414;
#P lcolor 15;
#P connect 35 0 36 0;
#P fasten 9 0 34 0 525 354 111 354;
#P lcolor 15;
#P fasten 6 0 27 0 309 304 129 304;
#P fasten 27 0 28 0 129 362 139 362;
#P connect 28 0 26 0;
#P fasten 34 0 35 1 111 519 170 519;
#P fasten 9 0 29 0 525 376 241 376;
#P connect 29 0 28 2;
#P fasten 31 0 28 3 394 417 292 417;
#P connect 6 0 20 0;
#P fasten 16 0 6 0 483 264 309 264;
#P connect 6 0 7 0;
#P fasten 18 0 6 2 923 277 345 277;
#P lcolor 13;
#P fasten 15 1 6 4 513 130 381 130;
#P lcolor 15;
#P fasten 7 0 8 0 309 361 384 361;
#P connect 8 0 5 0;
#P connect 5 0 2 0;
#P fasten 26 0 2 0 139 476 384 476;
#P fasten 12 0 2 0 730 571 384 571;
#P lcolor 6;
#P fasten 32 0 2 0 929 572 384 572;
#P lcolor 6;
#P fasten 35 0 2 0 31 578 384 578;
#P lcolor 6;
#P fasten 9 0 31 0 525 357 394 357;
#P connect 3 0 15 0;
#P connect 15 0 16 0;
#P fasten 10 0 8 2 505 414 486 414;
#P fasten 9 0 10 0 525 384 505 384;
#P connect 15 1 16 1;
#P connect 9 0 19 0;
#P fasten 16 0 9 0 483 289 525 289;
#P fasten 25 0 8 3 624 419 537 419;
#P fasten 18 0 9 2 923 309 563 309;
#P lcolor 13;
#P fasten 15 1 9 4 513 131 601 131;
#P lcolor 15;
#P fasten 9 0 25 0 525 384 624 384;
#P fasten 13 0 21 0 730 221 712 221;
#P connect 24 0 14 0;
#P fasten 17 1 14 0 923 145 730 145;
#P connect 14 0 11 0;
#P connect 11 0 13 0;
#P connect 13 0 12 0;
#P fasten 15 1 11 1 513 117 760 117;
#P lcolor 15;
#P fasten 18 0 13 2 923 193 768 193;
#P lcolor 13;
#P fasten 15 1 13 4 513 117 806 117;
#P lcolor 15;
#P fasten 15 1 17 0 513 117 906 117;
#P lcolor 15;
#P connect 17 0 18 0;
#P fasten 13 0 32 0 730 221 929 221;
#P pop;
#P newobj 33 187 132 9109513 p Generate and name buffers;
#P button 205 99 15 0;
#N comlet Destroy Buffers (bang);
#P inlet 155 89 15 0;
#N comlet NumberOfBuffers (int);
#P inlet 33 89 15 0;
#P window setfont “Sans Serif” 12.;
#P number 33 132 43 12 0 0 0 139 0 0 0 153 153 255 222 222 222 0 0 0;
#P comment 38 116 111 9109516 Number of buffers;
#B color 6;
#P window setfont “Sans Serif” 18.;
#P comment 15 22 426 9109522 Generate and name an arbitrary number of buffers;
#B color 14;
#P window setfont “Sans Serif” 14.;
#P window linecount 5;
#P comment 141 254 100 9109518 standard name to acess the buffers from another object mysound(i);
#B color 14;
#P window linecount 3;
#P comment 303 46 138 9109518 Variable names : for buffer~ kolos(i) for info~ kolosinfo(I);
#B color 14;
#P connect 5 0 4 0;
#P connect 4 0 8 0;
#P connect 8 0 9 0;
#P connect 7 0 8 1;
#P connect 6 0 8 1;
#P pop;

and the main patch :

max v2;
#N vpatcher 73 50 881 878;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 97 89 74 9109513 Open Folder;
#B color 14;
#P button 158 110 15 0;
#N thispatcher;
#Q end;
#P newobj 83 222 54 9109513 thispatcher;
#N vpatcher 15 55 615 455;
#P outlet 94 184 15 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 0;
#P newex 55 179 26 9109513 print;
#P window linecount 1;
#P newex 50 117 149 9109513 sprintf script send %s replace %s;
#P number 50 50 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 50 80 70 9109513 sprintf kolos%i;
#P message 195 73 175 9109513 E:/samplesGia_Grain/Attack_E_oct.wav;
#P comment 369 73 173 9109513 replace with an appropriate sound path;
#B color 14;
#P connect 3 0 2 0;
#P connect 2 0 4 0;
#P connect 4 0 5 0;
#P connect 4 0 6 0;
#P connect 1 0 4 1;
#P pop;
#P newobj 211 166 120 9109513 p this form works manualy;
#P newex 83 171 85 9109513 generatebuffersxx;
#P button 83 89 15 0;
#P newex 83 128 66 9109513 openfoldercoll;
#P comment 213 152 100 9109513 open to operate;
#B color 14;
#P window linecount 2;
#P comment 205 303 100 9109513 If opened the object name seems corect;
#B color 14;
#P window linecount 1;
#P comment 172 110 74 9109513 Destroy Buffers;
#B color 14;
#P connect 4 0 3 0;
#P connect 3 0 5 0;
#P connect 6 0 7 0;
#P connect 5 0 7 0;
#P connect 8 0 5 1;
#P pop;

Thanks for any help :)

Greg

#40475
Oct 22, 2008 at 10:38pm

Is [openfoldercoll] an abstraction you have made or an external? If it is an external could you say where to find it so understanding your patch would be easier.

lh

#143278
Oct 22, 2008 at 10:48pm

Wow , i totally forgot about that , sorry ..

Its an abstraction

here is the code :

max v2;
#N vpatcher 4 52 939 797;
#N comlet Number of audio files;
#P outlet 206 363 15 0;
#P button 289 453 15 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 116 602 100 9109513 pack 1 ga;
#N coll mysounds;
#P newobj 116 641 69 9109513 coll mysounds;
#P message 94 361 14 9109513 0;
#N counter 0 0 1;
#X flags 0 0;
#P newobj 20 388 78 9109513 counter 0 0 1;
#P user umenu 116 417 100 9109543 1 64 433 1;
#P newex 20 334 85 9109513 t b i b;
#P newex 20 362 40 9109513 uzi;
#P newex 320 549 57 9109513 prepend set;
#N comlet Open Folder;
#P inlet 116 48 15 0;
#P newex 315 181 45 9109513 loadbang;
#P window linecount 6;
#P message 320 581 115 9109513 replace C:/Documents and Settings/Greg/Desktop/samplesGia Grain/sustained_E_oct.wav;
#B color 14;
#P window linecount 1;
#P newex 279 548 26 9109513 print;
#P newex 279 519 76 9109513 sprintf %s%s;
#B color 5;
#P message 279 476 92 9109513 E:/tokako2_ideas/;
#B color 14;
#P newex 178 133 57 9109513 prepend set;
#P flonum 206 300 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 315 211 62 9109513 types WAVE;
#P newex 116 133 61 9109513 absolutepath;
#P newex 116 98 71 9109513 opendialog fold;
#P newex 116 275 100 9109513 folder;
#P fasten 4 0 14 0 211 330 25 330;
#P connect 14 0 13 0;
#P connect 13 0 16 0;
#P connect 14 1 13 1;
#P fasten 17 0 16 2 99 385 59 385;
#P fasten 14 1 16 4 62 380 93 380;
#P connect 14 2 17 0;
#P connect 11 0 1 0;
#P connect 1 0 2 0;
#P fasten 3 0 0 0 320 245 121 245;
#P connect 2 0 0 0;
#P fasten 16 0 15 0 25 413 121 413;
#P connect 0 0 15 0;
#P connect 15 0 19 0;
#P connect 19 0 18 0;
#P fasten 1 0 5 0 121 123 183 123;
#P connect 0 1 4 0;
#P connect 4 0 21 0;
#P fasten 12 0 19 1 325 572 211 572;
#P connect 20 0 6 0;
#P fasten 5 0 6 0 183 176 284 176;
#P connect 6 0 7 0;
#P fasten 7 0 8 0 284 540 284 543 284 543;
#P fasten 15 0 20 0 121 439 294 439;
#P connect 10 0 3 0;
#P fasten 7 0 12 0 284 543 325 543;
#P connect 12 0 9 0;
#P fasten 15 1 7 1 211 496 350 496;
#P pop;

Thanks

Greg

#143279
Oct 22, 2008 at 10:55pm

And a last thing , openfoldercoll doesn’t work when there are spaces in the path , i forgot to fix this .

cheers

G

#143280
Oct 23, 2008 at 2:06am

There’s a few things I’ve noticed. First of all in your [openfoldercoll] subpatch you need to insert a [tosymbol] between your absolute path and the [pack] object otherwise if there is a space in the path it will not store correctly in the [coll].

Other than that your main problem seems to be the order that you trigger events. For example the [sprintf] that sends the “replace” message is receiving the send destination before the file path from [coll]. It should be the other way around because the left inlet triggers the output not the right. You will definitely want to study the benefits of the [trigger] object a bit more. I would advise you to make a written flow chart of what you want to happen and in what order and then set about trying to rebuild your patch using that as a guide.

I thought your problem was quite interesting so I have designed my own method from the bottom up. It works pretty well so far. If you want to have a look at it then let me know. I use max 5 so if you’re still only on 4.6 I could perhaps post a screenshot for you to work from.

lh

#143281
Oct 24, 2008 at 2:44pm

Sorry for the delay man and thanks for you valuable insight,
but i was working yesterday till late.
I tried your suggestions , but i must still be doing something wrong with the triggering of events.
I will post it when it (hopefully) works :)
I would be interested to see your approach , since i am not sure even when i fix this that it might be the best way to achieve what i need.

Basically this is supposed to work with an granular patch , where i will be controlling which sound buffer will access each grain
stream .
For that i need also the duration , as well as start and end points for segments of the audio files that will be granulated .

I was wondering thus if this is the best way to do so , because i am not sure about how i can access these start and end points .
In the beginning i thought that i could mark this points into an audio editor (instead of using waveform~ , which would be tricky when the number of audio files is high), but i am not sure whether these points can be imported in a buffer .

cheers

Greg

#143282
Oct 24, 2008 at 3:30pm

Ah I just emailed you to see if you’d managed to fix your patch. Here are my methods which seem to work just fine.

Will you be connecting directly to these buffers or refering to them elsewhere in the patch? I’d suggest refering to them from elsewhere as this means less scripting and you can also look at my [poly~] approach. Will you need the lengths of all files all the time (stored in a [coll] perhaps?) or just find the length of a particular file when you use it?

Anyway, below is the scripting approach which names the [buffer~]s after the file you loaded into it. Below that is another patch which uses [poly~] to load the sounds without worrying about scripting and below that is the extremely simple [poly~] abstraction which should be named “autobuf”. Let me know if you have any problems using them or understanding what’s going on inside.

lh

Scripting:

– Pasted Max Patch, click to expand. –

Non-scripting:

– Pasted Max Patch, click to expand. –

Poly:

– Pasted Max Patch, click to expand. –
#143283
Oct 25, 2008 at 1:36am

Yes i received your email thanks ,

Unfortunately i can’t open the solution you posted since i am in
max 4.6

I managed to fix the biggest part of the patch , you were right there was a mix up with the order of the events .
The problem was though not only in the generatebuffers abstraction but also in the “openfolder” abstraction .

It seems that the folder object sends its output from left to right , i spent at least an hour trying to see what was going on.
Because basically i was sending the replace message before filling the coll .

However i still haven’t fixed the issue when there is a space in the path(not a big issue since i have the habit of using underscores in the folders , still..) .

As for the granulation patch , i still need to make a choice on how to work with multiple buffers.
The version i have now is accessing only one buffer .
So what i do is open a sound file , select a region with waveform~ , calculate it’s duration , divide this with the grain size thus getting the number of grains per region .
Then when granulating i can choose if i want to repeat each grain a number of times, play with their order, etc .

I am not sure though if this would be a good strategy with multiple buffers.
Perhaps i should “prepare” the files first in an audio editor, and forget the waveform~ object .

So to answer your question ,since i plan to basically mix up grains (scholastically) from various sound files , i need the buffer names and durations to be stored in a coll immediately .

From this coll i can make a new one with buffer names and grains per sound file which is actually the one i’ll be using for the granulation.
The granulation patch uses the play~ object to read through the grains , thus i am referring to them by name , not connecting to them .

I’ll post you the folder patch so far , if you are interested i can also post the granulation patch although probably basic .

I was wondering though , if there is a way to retain loop points created in an audio editor .
This could be a nice compromise between the two strategies .

thanks a lot

Greg

#143284
Oct 25, 2008 at 1:47am

name as “openfoldercoll”

max v2;
#N vpatcher 83 52 939 797;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 133 329 14 9109513 0;
#N counter 0 0 1;
#X flags 0 0;
#P newobj 61 373 78 9109513 counter 0 0 1;
#P newex 25 297 119 9109513 t i b i b;
#P newex 61 336 46 9109513 uzi;
#P message 133 588 28 9109513 clear;
#N comlet Number of audio files;
#P outlet 25 546 15 0;
#P button 337 438 15 0;
#P newex 164 587 100 9109513 pack 1 ga;
#N coll dasoundfilez;
#P newobj 164 626 77 9109513 coll dasoundfilez;
#P user umenu 164 402 100 9109543 1 64 418 1;
#P newex 368 534 57 9109513 prepend set;
#N comlet Open Folder;
#P inlet 164 33 15 0;
#P newex 363 166 45 9109513 loadbang;
#P window linecount 6;
#P message 368 566 115 9109513 replace C:/Documents and Settings/Greg/Desktop/samplesGia Grain/sustained_E_oct.wav;
#B color 14;
#P window linecount 1;
#P newex 327 504 76 9109513 sprintf %s%s;
#B color 5;
#P message 327 461 92 9109513 E:/tokako2_ideas/;
#B color 14;
#P newex 226 118 57 9109513 prepend set;
#P flonum 254 285 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 363 196 62 9109513 types WAVE;
#P newex 164 118 61 9109513 absolutepath;
#P newex 164 83 71 9109513 opendialog fold;
#P newex 164 260 100 9109513 folder;
#P fasten 4 0 19 0 259 303 159 303 159 286 30 286;
#P connect 19 0 16 0;
#P connect 19 1 18 0;
#P connect 18 0 20 0;
#P fasten 21 0 20 2 138 358 100 358;
#P connect 19 2 18 1;
#P fasten 19 2 20 4 102 326 134 326;
#P connect 19 3 21 0;
#P connect 21 0 17 0;
#P connect 10 0 1 0;
#P connect 1 0 2 0;
#P connect 2 0 0 0;
#P fasten 3 0 0 0 368 230 169 230;
#P connect 0 0 12 0;
#P fasten 20 0 12 0 66 397 169 397;
#P connect 12 0 14 0;
#P connect 14 0 13 0;
#P fasten 17 0 13 0 138 614 169 614;
#P fasten 1 0 5 0 169 108 231 108;
#P connect 0 1 4 0;
#P fasten 11 0 14 1 373 557 259 557;
#P fasten 5 0 6 0 231 161 332 161;
#P connect 15 0 6 0;
#P connect 6 0 7 0;
#P fasten 12 0 15 0 169 424 342 424;
#P connect 9 0 3 0;
#P fasten 7 0 11 0 332 528 373 528;
#P connect 11 0 8 0;
#P fasten 12 1 7 1 259 481 398 481;
#P pop;

name as “generatebuffers”

max v2;
#N vpatcher 139 28 1102 937;
#P origin 35 0;
#N comlet ToThisPatcher;
#P outlet 346 411 15 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#N vpatcher 17 29 973 876;
#P origin -51 0;
#P window setfont “Sans Serif” 9.;
#P newex 166 269 40 9109513 uzi;
#P newex 196 314 81 9109513 t i i;
#P newex 267 360 27 9109513 – 1;
#P window linecount 1;
#P newex 128 529 46 9109513 print zeta;
#P newex 128 493 57 9109513 prepend set;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 128 386 98 9240586 sprintf kolos%i;
#P window setfont “Sans Serif” 9.;
#P newex 128 436 149 9109513 sprintf script send %s replace %s;
#N coll dasoundfilez;
#P newobj 267 386 77 9109513 coll dasoundfilez;
#P newex 451 183 40 9109513 uzi 4;
#P newex 459 101 128 9109513 t b i b;
#P newex 577 148 40 9109513 uzi 4;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 720 241 182 9240586 sprintf script delete kolos%i;
#P window setfont “Sans Serif” 18.;
#P comment 134 60 238 9109522 Create the buffers and info~;
#B color 14;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 600 386 110 9240586 sprintf mysound%i;
#P window setfont “Sans Serif” 12.;
#P comment 274 220 111 9109516 Place the Buffers;
#B color 6;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 481 386 98 9240586 sprintf kolos%i;
#P newex 360 423 164 9240586 pack 0 400 objname bufname;
#P newex 360 386 104 9240586 expr ($i1*75)+40;
#P window setfont “Sans Serif” 9.;
#P message 360 470 216 9109513 script new $3 newex $1 $2 70 9109513 buffer~ $4;
#N comlet Number of Buffers (int);
#P inlet 459 70 15 0;
#N comlet Create Buffers (script);
#P outlet 360 646 15 0;
#P comment 506 55 59 9109513 trigger script;
#B color 14;
#P window setfont “Sans Serif” 18.;
#P window linecount 0;
#P comment 791 53 238 9109522 Destroy the buffers and info~;
#B color 14;
#P fasten 21 0 17 0 201 353 133 353;
#P connect 17 0 16 0;
#P connect 16 0 18 0;
#P connect 18 0 19 0;
#P fasten 14 1 22 0 471 237 171 237;
#P fasten 13 1 22 1 523 159 201 159;
#P connect 22 2 21 0;
#P connect 21 1 20 0;
#P connect 20 0 15 0;
#P fasten 15 0 16 1 272 415 272 415;
#P fasten 14 2 5 0 486 247 365 247;
#P connect 5 0 6 0;
#P connect 6 0 4 0;
#P fasten 11 0 2 0 725 514 365 514;
#P lcolor 6;
#P connect 4 0 2 0;
#P lcolor 6;
#P fasten 16 0 2 0 133 477 327 477 327 557 365 557;
#P fasten 13 0 14 0 464 133 456 133;
#P connect 3 0 13 0;
#P fasten 7 0 6 2 486 414 467 414;
#P fasten 13 1 14 1 523 161 486 161;
#P connect 14 2 7 0;
#P fasten 9 0 6 3 605 419 518 419;
#P connect 13 2 12 0;
#P fasten 14 2 9 0 486 247 605 247;
#P fasten 13 1 12 1 523 132 612 132;
#P fasten 12 2 11 0 612 179 725 179;
#P pop;
#P newobj 346 373 132 9109513 p Generate and name buffers;
#N comlet NumberOfBuffers (int);
#P inlet 346 275 15 0;
#P window setfont “Sans Serif” 12.;
#P number 346 318 43 12 0 0 0 139 0 0 0 153 153 255 222 222 222 0 0 0;
#P comment 351 302 111 9109516 Number of buffers;
#B color 6;
#P window setfont “Sans Serif” 18.;
#P comment 15 22 426 9109522 Generate and name an arbitrary number of buffers;
#B color 14;
#P window setfont “Sans Serif” 14.;
#P window linecount 5;
#P comment 435 19 100 9109518 standard name to acess the buffers from another object mysound(i);
#B color 14;
#P window linecount 3;
#P comment 303 46 138 9109518 Variable names : for buffer~ kolos(i) for info~ kolosinfo(I);
#B color 14;
#P connect 5 0 4 0;
#P connect 4 0 6 0;
#P connect 6 0 7 0;
#P pop;

and the main patch :

max v2;
#N vpatcher -21 31 920 841;
#P window setfont “Sans Serif” 9.;
#P comment 340 134 74 9109513 Open Folder;
#B color 14;
#N thispatcher;
#Q end;
#P newobj 326 253 54 9109513 thispatcher;
#P newex 326 212 75 9109513 generatebuffers;
#P button 326 134 15 0;
#P newex 326 173 66 9109513 openfoldercoll;
#P connect 1 0 0 0;
#P fasten 0 0 2 0 331 203 331 203;
#P connect 2 0 3 0;
#P pop;

I have taken out the generate info~ part at this point ,
at least until i solve the issues with the spaces , since it seemed to work fine .

#143285
Oct 26, 2008 at 11:53pm

To understand paths with spaces you need to make sure that the collection and the “replace” message receive the file path as one symbol which can be done using [sprintf "%s"] or some such variation thereof, it’s including the “quotes” that makes all the difference. I had to do this to get it working as my hard drive is called “Macintosh HD”.

lh

#143286
Oct 29, 2008 at 1:15am

OK i found some time to work on it more , and this time it works .
It is though quite ugly:)
The problem with the spaces still remains though, i tried your sprintf suggestion but it doesn’t seem to work when there are several spaces , also i used the tosymbol and fromsymbol objects still without success .
Nevertheless now i can open a folder load the wave files into buffers and create a coll with the buffer names and the corresponding durations , to access elsewere .
There is still some polishing needed but i think for the moment it will do .

Still it would be nice to see your approach , i don’t know if you cold post some screen shots , in any case you have been very helpful and I’d like to thank for that .

Below is the patch :

save as “openfoldercoll”

max v2;
#N vpatcher 83 52 939 797;
#N comlet Number of Soundfiles;
#P outlet 533 633 15 0;
#P window setfont “Sans Serif” 9.;
#P message 133 329 14 9109513 0;
#N counter 0 0 1;
#X flags 0 0;
#P newobj 61 373 78 9109513 counter 0 0 1;
#P newex 25 297 119 9109513 t i b i b;
#P newex 61 336 46 9109513 uzi;
#P message 133 588 28 9109513 clear;
#N comlet Number of audio files;
#P outlet 25 546 15 0;
#P button 337 438 15 0;
#P newex 164 587 100 9109513 pack 1 ga;
#N coll dasoundfilez;
#P newobj 164 626 77 9109513 coll dasoundfilez;
#P user umenu 164 402 100 9109543 1 64 418 1;
#P newex 368 534 57 9109513 prepend set;
#N comlet Open Folder;
#P inlet 164 33 15 0;
#P newex 363 166 45 9109513 loadbang;
#P window linecount 6;
#P message 368 566 115 9109513 replace C:/Documents and Settings/Greg/Desktop/samplesGia Grain/sustained_E_oct.wav;
#B color 14;
#P window linecount 1;
#P newex 327 504 76 9109513 sprintf %s%s;
#B color 5;
#P message 327 461 92 9109513 E:/tokako2_ideas/;
#B color 14;
#P newex 226 118 57 9109513 prepend set;
#P flonum 254 285 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 363 196 62 9109513 types WAVE;
#P newex 164 118 61 9109513 absolutepath;
#P newex 164 83 71 9109513 opendialog fold;
#P newex 164 260 100 9109513 folder;
#P fasten 4 0 19 0 259 303 159 303 159 286 30 286;
#P connect 19 0 16 0;
#P connect 19 1 18 0;
#P connect 18 0 20 0;
#P fasten 21 0 20 2 138 358 100 358;
#P connect 19 2 18 1;
#P fasten 19 2 20 4 102 326 134 326;
#P connect 19 3 21 0;
#P connect 21 0 17 0;
#P connect 10 0 1 0;
#P connect 1 0 2 0;
#P fasten 3 0 0 0 368 230 169 230;
#P connect 2 0 0 0;
#P fasten 20 0 12 0 66 397 169 397;
#P connect 0 0 12 0;
#P connect 12 0 14 0;
#P fasten 17 0 13 0 138 614 169 614;
#P connect 14 0 13 0;
#P fasten 1 0 5 0 169 108 231 108;
#P connect 0 1 4 0;
#P fasten 11 0 14 1 373 557 259 557;
#P connect 15 0 6 0;
#P fasten 5 0 6 0 231 161 332 161;
#P connect 6 0 7 0;
#P fasten 12 0 15 0 169 424 342 424;
#P connect 9 0 3 0;
#P fasten 7 0 11 0 332 528 373 528;
#P connect 11 0 8 0;
#P fasten 12 1 7 1 259 481 398 481;
#P fasten 4 0 22 0 259 333 538 333;
#P pop;

save as “generatebufandname”

max v2;
#N vpatcher -6 30 758 665;
#P origin 35 0;
#P window setfont “Sans Serif” 14.;
#P window linecount 3;
#P comment 551 97 138 9109518 Coll to acess buffer info name : namecol;
#B color 14;
#N comlet ToThisPatcher;
#P outlet 94 320 15 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#N vpatcher 12 34 1392 943;
#P origin -46 0;
#P window setfont “Sans Serif” 9.;
#N vpatcher 430 235 1145 879;
#P window setfont “Sans Serif” 9.;
#P window linecount 0;
#P message 286 54 290 9109513 Trigger information to be stored in namecol (buffer name , duration);
#B color 14;
#P window linecount 1;
#P message 50 286 109 9109513 script send mypack2 $1;
#P newex 229 50 40 9109513 uzi;
#P newex 259 239 40 9109513 t i i i;
#P window setfont “Fixedwidth Serif” 10.;
#P window linecount 2;
#P newex 314 285 71 9240586 sprintf infokolos%i;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 314 324 123 9109513 sprintf script send %s bang;
#P window setfont “Fixedwidth Serif” 10.;
#P window linecount 2;
#P newex 161 285 61 9240586 sprintf mysound%i;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 161 324 137 9109513 sprintf script send mypack %s;
#N comlet Number of Bangs;
#P inlet 259 30 15 0;
#N comlet Bang;
#P inlet 229 30 15 0;
#N comlet Trigger info (to this patcher);
#P outlet 50 453 15 0;
#P fasten 7 0 9 0 264 269 55 269;
#P fasten 5 0 0 0 319 375 55 375;
#P fasten 3 0 0 0 166 368 55 368;
#P connect 9 0 0 0;
#P fasten 7 1 4 0 279 271 166 271;
#P connect 4 0 3 0;
#P connect 1 0 8 0;
#P connect 2 0 8 1;
#P connect 8 2 7 0;
#P fasten 7 2 6 0 294 269 319 269;
#P connect 6 0 5 0;
#P pop;
#P newobj 592 601 64 9109513 p Trigger Info;
#B color 3;
#N vpatcher 406 275 1210 933;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 463 237 97 9109513 script delete namecol;
#B color 14;
#P message 366 237 88 9109513 script delete mycol;
#B color 14;
#P message 260 237 101 9109513 script delete mypack2;
#B color 14;
#P message 149 237 107 9109513 script delete mysymbol;
#B color 14;
#P newex 50 50 27 9109513 t b b;
#P message 50 236 96 9109513 script delete mypack;
#B color 14;
#N comlet Bang;
#P inlet 50 30 15 0;
#N comlet Destroy (to this patcher);
#P outlet 50 290 15 0;
#P window linecount 0;
#P comment 150 50 208 9109513 Destroy all the objects before creating new ones;
#B color 14;
#P connect 2 0 4 0;
#P connect 4 0 3 0;
#P connect 3 0 1 0;
#P fasten 5 0 1 0 154 262 55 262;
#P fasten 6 0 1 0 265 273 55 273;
#P fasten 8 0 1 0 468 276 55 276;
#P fasten 4 1 5 0 72 96 154 96;
#P fasten 4 1 6 0 72 96 265 96;
#P fasten 4 1 7 0 72 96 371 96;
#P fasten 4 1 8 0 72 96 468 96;
#P pop;
#P newobj 1059 151 81 9109513 p destroy objects;
#B color 12;
#P window linecount 1;
#P message 289 737 163 9109513 script connect mypack2 0 namecol 0;
#P window linecount 0;
#P newex 289 648 30 9109513 t b b;
#N vpatcher 190 90 1192 941;
#P window setfont “Sans Serif” 10.;
#P window linecount 1;
#P message 33 366 237 9109514 script newdefault namecol 240 630 coll namecol;
#P window setfont “Sans Serif” 9.;
#P window linecount 0;
#P message 167 440 173 9109513 script connect mysymbol 0 mypack2 1;
#P newex 300 371 64 9109513 pack 200 615;
#P message 300 399 234 9109513 script new mypack2 newex $1 $2 41 9109513 pack i s;
#P message 650 225 223 9109513 generate a pack object a symbol and connect them;
#B color 14;
#P outlet 558 609 15 0;
#P message 438 467 168 9109513 script connect mypack 0 mysymbol 0;
#P newex 600 313 64 9109513 pack 240 580;
#P newex 581 268 87 9109513 t b b b b b;
#P message 600 345 246 9109513 script new mysymbol newex $1 $2 47 9109513 tosymbol;
#P message 845 454 23 9109513 240;
#P newex 845 475 57 9109513 pack 0 550;
#P message 845 503 229 9109513 script new mypack newex $1 $2 41 9109513 pack s i;
#P inlet 581 217 15 0;
#P fasten 0 0 13 0 586 244 38 244;
#P fasten 5 1 12 0 605 294 172 294;
#P fasten 5 1 11 0 605 294 305 294;
#P connect 11 0 10 0;
#P fasten 5 2 7 0 624 295 443 295;
#P fasten 13 0 8 0 38 579 563 579;
#P fasten 12 0 8 0 172 551 563 551;
#P fasten 1 0 8 0 850 555 563 555;
#P fasten 4 0 8 0 605 564 563 564;
#P fasten 7 0 8 0 443 528 563 528;
#P fasten 10 0 8 0 305 526 563 526;
#P connect 0 0 5 0;
#P fasten 5 3 6 0 643 294 605 294;
#P connect 6 0 4 0;
#P fasten 5 4 3 0 662 292 850 292;
#P connect 3 0 2 0;
#P connect 2 0 1 0;
#P pop;
#P newobj 309 674 59 9109513 p storetocoll;
#P window setfont “Fixedwidth Serif” 10.;
#P window linecount 2;
#P newex 97 576 71 9240586 sprintf infokolos%i;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 97 618 166 9109513 sprintf script connect %s 6 mypack 1;
#P message 225 471 206 9109513 script new $3 newex $1 $2 70 9109513 info~ $4;
#P window setfont “Fixedwidth Serif” 10.;
#P window linecount 2;
#P newex 399 320 61 9240586 sprintf mysound%i;
#P newex 327 320 71 9240586 sprintf infokolos%i;
#P window linecount 1;
#P newex 225 369 164 9240586 pack 0 500 objname bufname;
#P window linecount 2;
#P newex 225 320 72 9240586 expr ($i1*75)+40;
#P window linecount 4;
#P newex 980 241 73 9240586 sprintf script delete infokolos%i;
#P window setfont “Sans Serif” 9.;
#P window linecount 0;
#P newex 38 270 40 9109513 uzi;
#P newex 68 315 81 9109513 t i i;
#P newex 139 361 27 9109513 – 1;
#P window linecount 1;
#P newex 0 638 46 9109513 print zeta;
#P newex 0 602 57 9109513 prepend set;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 0 387 98 9240586 sprintf kolos%i;
#P window setfont “Sans Serif” 9.;
#P newex 0 437 149 9109513 sprintf script send %s replace %s;
#N coll dasoundfilez;
#P newobj 139 387 77 9109513 coll dasoundfilez;
#P newex 523 183 40 9109513 uzi 4;
#P newex 531 101 128 9109513 t b i b;
#P newex 649 148 40 9109513 uzi 4;
#P window setfont “Fixedwidth Serif” 10.;
#P window linecount 4;
#P newex 792 241 56 9240586 sprintf script delete kolos%i;
#P window setfont “Sans Serif” 18.;
#P window linecount 1;
#P comment 129 60 238 9109522 Create the buffers and info~;
#B color 14;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 672 386 110 9240586 sprintf mysound%i;
#P window setfont “Sans Serif” 12.;
#P comment 146 221 111 9109516 Place the Buffers;
#B color 6;
#P window setfont “Fixedwidth Serif” 10.;
#P newex 553 386 98 9240586 sprintf kolos%i;
#P newex 432 423 164 9240586 pack 0 400 objname bufname;
#P newex 432 386 104 9240586 expr ($i1*75)+40;
#P window setfont “Sans Serif” 9.;
#P message 432 470 216 9109513 script new $3 newex $1 $2 70 9109513 buffer~ $4;
#N comlet Number of Buffers (int);
#P inlet 531 61 15 0;
#N comlet Create Buffers (script);
#P outlet 432 646 15 0;
#P comment 578 55 59 9109513 trigger script;
#B color 14;
#P window setfont “Sans Serif” 18.;
#P window linecount 0;
#P comment 863 53 238 9109522 Destroy the buffers and info~;
#B color 14;
#P fasten 21 0 17 0 73 354 5 354;
#P connect 17 0 16 0;
#P connect 16 0 18 0;
#P connect 18 0 19 0;
#P fasten 14 1 22 0 543 202 43 202;
#P fasten 13 1 22 1 595 159 73 159;
#P connect 22 2 21 0;
#P fasten 14 2 30 0 558 358 102 358;
#P lcolor 7;
#P connect 30 0 29 0;
#P connect 21 1 20 0;
#P connect 20 0 15 0;
#P fasten 15 0 16 1 144 416 144 416;
#P fasten 14 2 24 0 558 285 230 285;
#P lcolor 7;
#P connect 24 0 25 0;
#P connect 25 0 28 0;
#P fasten 12 1 32 0 669 556 294 556;
#P connect 32 0 33 0;
#P connect 32 1 31 0;
#P fasten 14 2 26 0 558 272 332 272;
#P lcolor 7;
#P connect 26 0 25 2;
#P fasten 27 0 25 3 404 361 383 361;
#P fasten 14 2 27 0 558 264 404 264;
#P lcolor 7;
#P fasten 14 2 5 0 558 247 437 247;
#P lcolor 7;
#P connect 5 0 6 0;
#P connect 6 0 4 0;
#P fasten 35 0 2 0 597 630 437 630;
#P lcolor 4;
#P fasten 33 0 2 0 294 767 467 767 467 641 437 641;
#P fasten 31 0 2 0 314 714 415 714 415 622 437 622;
#P fasten 29 0 2 0 102 644 437 644;
#P lcolor 15;
#P fasten 16 0 2 0 5 557 322 557 322 557 437 557;
#P lcolor 6;
#P fasten 28 0 2 0 230 588 437 588;
#P lcolor 6;
#P fasten 23 0 2 0 985 514 437 514;
#P lcolor 6;
#P connect 4 0 2 0;
#P lcolor 6;
#P fasten 11 0 2 0 797 514 437 514;
#P lcolor 6;
#P fasten 34 0 2 0 1064 598 437 598;
#P lcolor 13;
#P fasten 13 0 14 0 536 133 528 133;
#P connect 3 0 13 0;
#P fasten 7 0 6 2 558 414 539 414;
#P fasten 13 1 14 1 595 161 558 161;
#P connect 14 2 7 0;
#P lcolor 7;
#P fasten 9 0 6 3 677 419 590 419;
#P connect 22 1 35 0;
#P fasten 13 1 35 1 595 253 651 253;
#P connect 13 2 12 0;
#P fasten 14 2 9 0 558 247 677 247;
#P lcolor 7;
#P fasten 13 1 12 1 595 132 684 132;
#P fasten 12 2 11 0 684 179 797 179;
#P fasten 12 2 23 0 684 179 985 179;
#P fasten 3 0 34 0 536 88 1064 88;
#P pop;
#P newobj 94 282 132 9109513 p Generate and name buffers;
#N comlet NumberOfBuffers (int);
#P inlet 94 184 15 0;
#P window setfont “Sans Serif” 12.;
#P number 94 227 43 12 0 0 0 139 0 0 0 153 153 255 222 222 222 0 0 0;
#P comment 99 211 111 9109516 Number of buffers;
#B color 6;
#P window setfont “Sans Serif” 18.;
#P comment 15 22 426 9109522 Generate and name an arbitrary number of buffers;
#B color 14;
#P window setfont “Sans Serif” 14.;
#P window linecount 5;
#P comment 452 28 100 9109518 standard name to acess the buffers from another object mysound(i);
#B color 14;
#P window linecount 3;
#P comment 551 28 138 9109518 Variable names : for buffer~ kolos(i) for info~ kolosinfo(I);
#B color 14;
#P connect 5 0 4 0;
#P connect 4 0 6 0;
#P connect 6 0 7 0;
#P pop;

and the main :

max v2;
#N vpatcher -2 29 812 937;
#P window setfont “Sans Serif” 14.;
#P number 382 214 68 14 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 340 134 74 9109513 Open Folder;
#B color 14;
#N thispatcher;
#Q end;
#P newobj 326 367 54 9109513 thispatcher;
#P newex 326 269 96 9109513 generatebufandname;
#P button 326 134 15 0;
#P newex 326 173 66 9109513 openfoldercoll;
#P comment 387 200 97 9109513 Number of soundfiles;
#B color 9;
#P connect 2 0 1 0;
#P fasten 1 0 3 0 331 203 331 203;
#P connect 3 0 4 0;
#P connect 1 1 6 0;
#P pop;

#143287
Oct 29, 2008 at 2:29am

Here’s the two approaches I mentioned before, one using scripting to [thispatcher] like your patch and one using [poly~]. I added on the [coll] bit you mentioned so it should store the full filepath and time as well. I think all the objects are standard in 4.6 so you shouldn’t have much trouble piecing the patches back together from the screenshots. If you get stuck feel free to message me.

lh

http://tinyurl.com/5drlqy

#143288

You must be logged in to reply to this topic.