Forums > MaxMSP

Playing random files help

May 29, 2009 | 12:13 pm

I’ve looked through previous threads to no avail.

I’m trying to create a patch which should play all my audio files randomly, I have about 18 files in total and some are about 6 seconds and some are 2 mins.

I have written so far:
#P toggle 292 435 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 292 460 41 196617 loop $1;
#P comment 315 436 75 196617 • loop on/off;
#P user gain~ 1401 266 24 100 158 0 1.071519 7.94321 10.;
#P user gain~ 985 242 24 100 158 0 1.071519 7.94321 10.;
#P user gain~ 653 285 24 100 158 0 1.071519 7.94321 10.;
#P user gain~ 329 243 24 100 158 0 1.071519 7.94321 10.;
#P user gain~ 362 586 24 100 158 0 1.071519 7.94321 10.;
#P message 171 489 43 196617 replace;
#P toggle 1391 64 15 0;
#P toggle 1040 63 15 0;
#P toggle 689 68 15 0;
#P toggle 276 61 15 0;
#P toggle 238 455 15 0;
#P newex 242 529 81 196617 groove~ moosic;
#P newex 237 490 29 196617 sig~;
#P message 106 486 30 196617 read;
#P newex 116 544 78 196617 buffer~ moosic;
#P newex 1384 146 79 196617 groove~ samp4;
#P newex 1389 96 29 196617 sig~;
#P message 1218 267 50 196617 read file2;
#P newex 1201 292 76 196617 buffer~ samp4;
#P newex 1208 235 85 196617 prepend set read;
#P flonum 1145 131 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 1199 193 76 196617 sprintf file%ld;
#P newex 1196 146 58 196617 random 10;
#P newex 1192 93 64 196617 metro 4000;
#P toggle 1207 59 15 0;
#P newex 1037 140 79 196617 groove~ samp3;
#P newex 1042 90 29 196617 sig~;
#P message 871 261 50 196617 read file7;
#P newex 854 286 76 196617 buffer~ samp3;
#P newex 861 229 85 196617 prepend set read;
#P flonum 798 125 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 852 187 76 196617 sprintf file%ld;
#P newex 849 140 58 196617 random 10;
#P newex 845 87 70 196617 metro 20000;
#P newex 684 155 79 196617 groove~ samp2;
#P newex 689 102 29 196617 sig~;
#P message 518 273 50 196617 read file6;
#P newex 501 298 76 196617 buffer~ samp2;
#P newex 508 241 85 196617 prepend set read;
#P flonum 445 137 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 499 199 76 196617 sprintf file%ld;
#P newex 496 152 58 196617 random 10;
#P newex 492 99 64 196617 metro 5000;
#P toggle 507 65 15 0;
#P user ezdac~ 794 681 838 714 0;
#P newex 798 597 41 196617 *~ 0.2;
#P newex 275 154 86 196617 groove~ sounds1;
#P newex 280 104 29 196617 sig~;
#P message 109 275 76 196617 read file0.wav;
#P newex 92 300 83 196617 buffer~ sounds1;
#P newex 99 243 85 196617 prepend set read;
#P flonum 36 139 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 90 201 98 196617 sprintf file%ld.wav;
#P newex 87 154 52 196617 random 5;
#P newex 83 101 64 196617 metro 2000;
#P toggle 98 67 15 0;
#P connect 1 0 4 0;
#P connect 0 0 1 0;
#P connect 1 0 2 0;
#P connect 2 0 3 0;
#P connect 7 0 6 0;
#P connect 3 0 5 0;
#P connect 5 0 7 0;
#P connect 50 0 41 0;
#P connect 42 0 41 0;
#P connect 45 0 43 0;
#P connect 43 0 44 0;
#P connect 57 0 44 0;
#P connect 8 0 9 0;
#P connect 46 0 8 0;
#P connect 58 0 57 0;
#P connect 9 0 52 0;
#P connect 44 0 51 0;
#P connect 13 0 16 0;
#P connect 12 0 13 0;
#P connect 13 0 14 0;
#P connect 14 0 15 0;
#P connect 19 0 18 0;
#P connect 15 0 17 0;
#P connect 17 0 19 0;
#P connect 21 0 53 0;
#P connect 20 0 21 0;
#P connect 47 0 20 0;
#P connect 10 0 11 0;
#P connect 22 0 25 0;
#P connect 55 0 10 0;
#P connect 54 0 10 0;
#P connect 53 0 10 0;
#P connect 52 0 10 0;
#P connect 51 0 10 0;
#P connect 10 0 11 1;
#P connect 22 0 23 0;
#P connect 23 0 24 0;
#P connect 28 0 27 0;
#P connect 24 0 26 0;
#P connect 26 0 28 0;
#P connect 30 0 54 0;
#P connect 29 0 30 0;
#P connect 48 0 29 0;
#P connect 32 0 35 0;
#P connect 31 0 32 0;
#P connect 32 0 33 0;
#P connect 33 0 34 0;
#P connect 38 0 37 0;
#P connect 34 0 36 0;
#P connect 36 0 38 0;
#P connect 39 0 40 0;
#P connect 49 0 39 0;
#P connect 40 0 55 0;
#P window clipboard copycount 59;

and I’m wondering where I’ve gone wrong as the buffer without the random will play my samples, but I cannot get the files to play through random. I’ve played around with sfplay~ but it didn’t really work unless I did it wrong. I am using the 4.6 version.If anyone has any answers I would be very grateful! Thanks


May 29, 2009 | 2:58 pm

The problem could be that the message boxes connected up after the prepends don’t pass their values through to the buffers to load the files, you would have to click them to load.

So run the prepend (without ‘set’) straight through into the buffer, and consider using the ‘replace’ message into buffer instead of the ‘read’ message (this will resize the buffer to the size of the new file).

Also, if you use message’s right inlet you need no ‘set’ message, which is very convenient!


May 29, 2009 | 3:22 pm

Thanks for your response, however, I took away the set from the prepend and max came up with the error that it didn’t understand replace. Also it stopped the files from changing randomly.


May 29, 2009 | 3:26 pm

Can you post the new patch?


May 29, 2009 | 3:30 pm

Only the first buffer has the set removed

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 61 486 30 196617 open;
#P toggle 292 435 15 0;
#P message 292 460 41 196617 loop $1;
#P comment 315 436 75 196617 • loop on/off;
#P user gain~ 1401 266 24 100 158 0 1.071519 7.94321 10.;
#P user gain~ 985 242 24 100 158 0 1.071519 7.94321 10.;
#P user gain~ 653 285 24 100 158 0 1.071519 7.94321 10.;
#P user gain~ 329 241 24 100 158 0 1.071519 7.94321 10.;
#P user gain~ 362 586 24 100 158 0 1.071519 7.94321 10.;
#P message 171 489 43 196617 replace;
#P toggle 1391 64 15 0;
#P toggle 1040 63 15 0;
#P toggle 689 68 15 0;
#P toggle 276 61 15 0;
#P toggle 238 455 15 0;
#P newex 242 529 81 196617 groove~ moosic;
#P newex 237 490 29 196617 sig~;
#P message 111 485 30 196617 read;
#P newex 116 544 78 196617 buffer~ moosic;
#P newex 1384 146 79 196617 groove~ samp4;
#P newex 1389 96 29 196617 sig~;
#P message 1218 267 69 196617 read samp7;
#P newex 1201 292 76 196617 buffer~ samp4;
#P newex 1208 235 98 196617 prepend set replace;
#P flonum 1145 131 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 1199 193 84 196617 sprintf samp%ld;
#P newex 1196 146 58 196617 random 10;
#P newex 1192 93 64 196617 metro 4000;
#P toggle 1207 59 15 0;
#P newex 1037 140 79 196617 groove~ samp3;
#P newex 1042 90 29 196617 sig~;
#P message 871 261 69 196617 read sound1;
#P newex 854 286 76 196617 buffer~ samp3;
#P newex 861 229 98 196617 prepend set replace;
#P flonum 798 125 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 852 187 86 196617 sprintf sound%ld;
#P newex 849 140 52 196617 random 4;
#P newex 845 87 70 196617 metro 20000;
#P toggle 860 53 15 0;
#P newex 684 155 79 196617 groove~ samp2;
#P newex 689 102 29 196617 sig~;
#P message 518 273 63 196617 read track0;
#P newex 501 298 76 196617 buffer~ samp2;
#P newex 508 239 98 196617 prepend set replace;
#P flonum 445 137 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 499 199 85 196617 sprintf track%ld;
#P newex 496 152 52 196617 random 4;
#P newex 492 99 64 196617 metro 5000;
#P toggle 507 65 15 0;
#P user ezdac~ 794 681 838 714 0;
#P newex 798 597 41 196617 *~ 0.2;
#P newex 275 154 86 196617 groove~ sounds1;
#P newex 280 104 29 196617 sig~;
#P message 95 268 95 196617 replace file4.wav;
#P newex 92 300 83 196617 buffer~ sounds1;
#P newex 90 232 81 196617 prepend replace;
#P flonum 44 133 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 90 201 98 196617 sprintf file%ld.wav;
#P newex 87 154 52 196617 random 5;
#P newex 83 101 64 196617 metro 3000;
#P toggle 98 67 15 0;
#P connect 35 0 37 0;
#P connect 37 0 39 0;
#P connect 25 0 27 0;
#P connect 27 0 29 0;
#P connect 15 0 17 0;
#P connect 17 0 19 0;
#P connect 3 0 5 0;
#P connect 5 0 7 0;
#P connect 41 0 56 0;
#P connect 50 0 40 0;
#P connect 40 0 41 0;
#P connect 39 0 38 0;
#P connect 34 0 35 0;
#P connect 33 0 36 0;
#P connect 33 0 34 0;
#P connect 32 0 33 0;
#P connect 49 0 30 0;
#P connect 30 0 31 0;
#P connect 31 0 55 0;
#P connect 29 0 28 0;
#P connect 24 0 25 0;
#P connect 23 0 26 0;
#P connect 23 0 24 0;
#P connect 22 0 23 0;
#P connect 10 0 11 0;
#P connect 10 0 11 1;
#P connect 56 0 10 0;
#P connect 55 0 10 0;
#P connect 54 0 10 0;
#P connect 53 0 10 0;
#P connect 52 0 10 0;
#P connect 48 0 20 0;
#P connect 20 0 21 0;
#P connect 21 0 54 0;
#P connect 19 0 18 0;
#P connect 14 0 15 0;
#P connect 13 0 16 0;
#P connect 13 0 14 0;
#P connect 12 0 13 0;
#P connect 45 0 52 0;
#P connect 9 0 53 0;
#P connect 59 0 58 0;
#P connect 47 0 8 0;
#P connect 8 0 9 0;
#P connect 44 0 45 0;
#P connect 58 0 45 0;
#P connect 46 0 44 0;
#P connect 60 0 42 0;
#P connect 43 0 42 0;
#P connect 51 0 42 0;
#P connect 7 0 6 0;
#P connect 2 0 3 0;
#P connect 1 0 4 0;
#P connect 1 0 2 0;
#P connect 0 0 1 0;
#P window clipboard copycount 61;


May 29, 2009 | 3:37 pm

You need to remove the message box between the prepend and the buffer~… setting a message box doesn’t cause output as well. If you connect the prepend box directly to the buffer it should work.



amy
April 8, 2010 | 3:46 am

test


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