Forums > MaxMSP

copying and compiling new buffers

April 30, 2006 | 4:47 pm

For anyone interested ….

Working on this today I realised that there were some (ahem) problems
with the patch I posted, so I’ve fixed those and finished off the
patcher so that I can assemble a number of individual aiff files into
a single buffer.
The samples are first assembled into a buffer which is set to be
larger than I’ll need (default 20 seconds, but it can of course be
changed).
The buffer that was used for loading the individual samples is then
sized to fit the total length of the new sample and the combined
sample copied to that buffer for saving (the [write] command isn’t in
the patch yet).
The next thing to do is to add a coll to keep the start/end points of
the various segments in the new file, and save that along with the
new sample. (I already have that; it’s just not in this patch yet).

Here it is ..

max v2;
#N vpatcher 16 44 1114 686;
#P origin -65 10;
#P window setfont "Sans Serif" 14.;
#P window linecount 2;
#P comment 16 447 278 196622 B. size original buffer to fit total new
sample size and copy back;
#P window setfont "Sans Serif" 10.;
#P window linecount 1;
#P newex 37 44 51 196618 loadbang;
#P newex 38 270 70 196618 sampstoms~;
#P newex 564 396 27 196618 +;
#P message 702 409 18 196618 0.;
#P toggle 727 382 15 0;
#P window setfont "Sans Serif" 9.;
#P newex 727 407 27 196617 sig~;
#P window setfont "Sans Serif" 10.;
#P newex 726 442 93 196618 groove~ transfer;
#P button 498 97 15 0;
#P newex 113 243 40 196618 t i i 0;
#P newex 131 196 58 196618 r bfr_end;
#P newex 564 425 57 196618 s bfr_end;
#P newex 114 220 27 196618 int;
#P message 36 305 46 196618 size $1;
#P newex 113 374 46 196618 pack f f;
#P newex 113 399 83 196618 peek~ transfer;
#N counter 0 440628;
#X flags 0 0;
#P newobj 113 299 102 196618 counter 0 440628;
#P newex 145 342 90 196618 peek~ transfer2;
#P newex 113 271 53 196618 tl.uzi;
#P newex 542 299 42 196618 bucket;
#P message 661 159 15 196618 0;
#P newex 362 240 32 196618 t b b;
#P button 661 131 15 0;
#P message 620 160 34 196618 set 0;
#P newex 527 347 40 196618 accum;
#P message 37 96 35 196618 clear;
#P message 813 411 18 196618 0.;
#P user multiSlider 243 383 176 15 0. 1. 1 2936 15 0 0 2 0 0 0;
#M frgb 68 130 180;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P toggle 838 384 15 0;
#P window setfont "Sans Serif" 9.;
#P newex 838 405 27 196617 sig~;
#P user gain~ 883 472 46 38 158 0 1.071519 7.94321 10.;
#P window setfont "Sans Serif" 10.;
#P newex 837 440 100 196618 groove~ transfer2;
#P user ezdac~ 882 543 926 576 0;
#P message 838 320 75 196618 set transfer2;
#P message 853 194 68 196618 set transfer;
#P message 717 353 235 196618 replace with waveform~ to see what’s
going on;
#P message 713 226 235 196618 replace with waveform~ to see what’s
going on;
#P newex 472 311 51 196618 vround i;
#P newex 420 456 46 196618 pack f f;
#P newex 420 481 90 196618 peek~ transfer2;
#P newex 420 426 27 196618 + 0;
#N counter 0 440628;
#X flags 0 0;
#P newobj 420 381 102 196618 counter 0 440628;
#P newex 452 426 83 196618 peek~ transfer;
#P newex 420 353 53 196618 tl.uzi;
#P newex 472 289 32 196618 float;
#P newex 94 153 140 196618 buffer~ transfer2 20000.;
#P newex 462 240 70 196618 mstosamps~;
#P newex 384 213 105 196618 info~ transfer;
#P newex 362 184 32 196618 t b b;
#P message 268 96 46 196618 replace;
#P newex 246 151 126 196618 buffer~ transfer 1000.;
#P comment 76 96 187 196618 1. start by clearing buffers etc;
#P comment 318 97 177 196618 2. click here to select sound files;
#P comment 514 98 225 196618 3. size buffer 1 to total samples & copy
back;
#P comment 275 36 234 196618 needs tl.uzi & vround (go to
maxobjects.com);
#P user panel 332 179 307 342;
#X brgb 191 191 191;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P user panel 25 187 213 256;
#X brgb 191 191 191;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P window setfont "Sans Serif" 14.;
#P comment 355 526 278 196622 A. compile buffer of different samples;
#P fasten 55 1 44 0 103 297 41 297;
#P connect 56 0 32 0;
#P fasten 48 1 55 0 133 266 43 266;
#P fasten 32 0 12 0 42 149 99 149;
#P connect 45 0 48 0;
#P connect 48 0 39 0;
#P connect 39 0 41 0;
#P connect 41 0 43 0;
#P connect 43 0 42 0;
#P fasten 49 0 45 0 503 179 119 179;
#P connect 47 0 45 1;
#P fasten 41 0 40 0 118 330 150 330;
#P fasten 40 0 43 1 150 370 154 370;
#P fasten 48 2 41 2 148 266 182 266 182 293 164 293;
#P fasten 14 3 30 0 467 376 248 376;
#P fasten 32 0 7 0 42 149 251 149;
#P fasten 44 0 7 0 41 329 24 329 24 149 251 149;
#P fasten 8 0 7 0 273 132 251 132;
#P connect 7 1 9 0;
#P connect 9 0 36 0;
#P connect 9 1 10 0;
#P fasten 20 0 14 0 477 347 425 347;
#P connect 14 0 16 0;
#P fasten 16 0 17 0 425 413 425 413;
#P fasten 17 0 19 0 425 459 425 459;
#P connect 19 0 18 0;
#P fasten 37 0 17 1 666 418 442 418;
#P fasten 33 0 17 1 532 418 442 418;
#P fasten 16 0 15 0 425 412 457 412;
#P fasten 15 0 19 1 457 452 461 452;
#P connect 10 6 11 0;
#P fasten 37 0 16 2 666 377 471 377;
#P fasten 36 0 13 0 367 274 477 274;
#P connect 13 0 20 0;
#P fasten 11 1 13 1 527 273 499 273;
#P fasten 36 1 33 0 389 341 532 341;
#P fasten 34 0 33 0 625 328 532 328;
#P fasten 37 0 38 0 666 294 547 294;
#P fasten 11 1 38 0 527 278 547 278;
#P connect 38 0 33 1;
#P fasten 33 0 54 0 532 383 569 383;
#P connect 54 0 46 0;
#P fasten 38 0 54 1 547 336 586 336;
#P fasten 35 0 34 0 666 152 625 152;
#P fasten 32 0 35 0 42 121 666 121;
#P connect 35 0 37 0;
#P connect 23 0 21 0;
#P connect 24 0 22 0;
#P connect 53 0 50 0;
#P connect 51 0 50 0;
#P connect 52 0 51 0;
#P connect 31 0 26 0;
#P connect 28 0 26 0;
#P fasten 35 0 24 0 666 152 953 152 953 312 843 312;
#P connect 29 0 28 0;
#P fasten 35 0 23 0 666 152 858 152;
#P connect 27 0 25 0;
#P fasten 50 0 27 0 731 464 888 464;
#P fasten 26 0 27 0 842 464 888 464;
#P connect 27 0 25 1;
#P pop;


April 30, 2006 | 5:10 pm

oops. a single connection got lost somewhere in there. here’s the
correct version …

max v2;
#N vpatcher 16 44 1114 686;
#P origin -65 10;
#P window setfont "Sans Serif" 14.;
#P window linecount 2;
#P comment 16 447 278 196622 B. size original buffer to fit total new
sample size and copy back;
#P window setfont "Sans Serif" 10.;
#P window linecount 1;
#P newex 37 44 51 196618 loadbang;
#P newex 38 270 70 196618 sampstoms~;
#P newex 564 396 27 196618 +;
#P message 702 409 18 196618 0.;
#P toggle 727 382 15 0;
#P window setfont "Sans Serif" 9.;
#P newex 727 407 27 196617 sig~;
#P window setfont "Sans Serif" 10.;
#P newex 726 442 93 196618 groove~ transfer;
#P button 498 97 15 0;
#P newex 113 243 40 196618 t i i 0;
#P newex 131 196 58 196618 r bfr_end;
#P newex 564 425 57 196618 s bfr_end;
#P newex 114 220 27 196618 int;
#P message 36 305 46 196618 size $1;
#P newex 113 374 46 196618 pack f f;
#P newex 113 399 83 196618 peek~ transfer;
#N counter 0 440628;
#X flags 0 0;
#P newobj 113 299 102 196618 counter 0 440628;
#P newex 145 342 90 196618 peek~ transfer2;
#P newex 113 271 53 196618 tl.uzi;
#P newex 542 299 42 196618 bucket;
#P message 661 159 15 196618 0;
#P newex 362 240 32 196618 t b b;
#P button 661 131 15 0;
#P message 620 160 34 196618 set 0;
#P newex 527 347 40 196618 accum;
#P message 37 96 35 196618 clear;
#P message 813 411 18 196618 0.;
#P user multiSlider 243 383 176 15 0. 1. 1 2936 15 0 0 2 0 0 0;
#M frgb 68 130 180;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P toggle 838 384 15 0;
#P window setfont "Sans Serif" 9.;
#P newex 838 405 27 196617 sig~;
#P user gain~ 883 472 46 38 158 0 1.071519 7.94321 10.;
#P window setfont "Sans Serif" 10.;
#P newex 837 440 100 196618 groove~ transfer2;
#P user ezdac~ 882 543 926 576 0;
#P message 838 320 75 196618 set transfer2;
#P message 853 194 68 196618 set transfer;
#P message 717 353 235 196618 transfer2;
#P message 713 226 235 196618 transfer;
#P newex 472 311 51 196618 vround i;
#P newex 420 456 46 196618 pack f f;
#P newex 420 481 90 196618 peek~ transfer2;
#P newex 420 426 27 196618 + 0;
#N counter 0 440628;
#X flags 0 0;
#P newobj 420 381 102 196618 counter 0 440628;
#P newex 452 426 83 196618 peek~ transfer;
#P newex 420 353 53 196618 tl.uzi;
#P newex 472 289 32 196618 float;
#P newex 94 153 140 196618 buffer~ transfer2 20000.;
#P newex 462 240 70 196618 mstosamps~;
#P newex 384 213 105 196618 info~ transfer;
#P newex 362 184 32 196618 t b b;
#P message 268 96 46 196618 replace;
#P newex 246 151 126 196618 buffer~ transfer 1000.;
#P comment 76 96 187 196618 1. start by clearing buffers etc;
#P comment 318 97 177 196618 2. click here to select sound files;
#P comment 514 98 225 196618 3. size buffer 1 to total samples & copy
back;
#P comment 275 36 234 196618 needs tl.uzi & vround (go to
maxobjects.com);
#P user panel 332 179 307 342;
#X brgb 191 191 191;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P user panel 25 187 213 256;
#X brgb 191 191 191;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P window setfont "Sans Serif" 14.;
#P comment 355 526 278 196622 A. compile buffer of different samples;
#P fasten 55 1 44 0 103 297 41 297;
#P connect 56 0 32 0;
#P fasten 48 1 55 0 133 266 43 266;
#P fasten 32 0 12 0 42 149 99 149;
#P connect 45 0 48 0;
#P connect 48 0 39 0;
#P connect 39 0 41 0;
#P connect 41 0 43 0;
#P connect 43 0 42 0;
#P fasten 49 0 45 0 503 179 119 179;
#P connect 47 0 45 1;
#P fasten 41 0 40 0 118 330 150 330;
#P fasten 40 0 43 1 150 370 154 370;
#P fasten 48 2 41 2 148 266 182 266 182 293 164 293;
#P fasten 14 3 30 0 467 376 248 376;
#P fasten 32 0 7 0 42 149 251 149;
#P fasten 8 0 7 0 273 132 251 132;
#P fasten 44 0 7 0 41 329 24 329 24 149 251 149;
#P connect 7 1 9 0;
#P connect 9 0 36 0;
#P connect 9 1 10 0;
#P fasten 20 0 14 0 477 347 425 347;
#P connect 14 0 16 0;
#P fasten 16 0 17 0 425 413 425 413;
#P fasten 17 0 19 0 425 459 425 459;
#P connect 19 0 18 0;
#P fasten 33 0 17 1 532 418 442 418;
#P fasten 37 0 17 1 666 418 442 418;
#P fasten 16 0 15 0 425 412 457 412;
#P fasten 15 0 19 1 457 452 461 452;
#P connect 10 6 11 0;
#P fasten 37 0 16 2 666 377 471 377;
#P fasten 36 0 13 0 367 274 477 274;
#P connect 13 0 20 0;
#P fasten 11 1 13 1 527 273 499 273;
#P connect 20 0 16 4;
#P fasten 34 0 33 0 625 328 532 328;
#P fasten 36 1 33 0 389 341 532 341;
#P fasten 11 1 38 0 527 278 547 278;
#P fasten 37 0 38 0 666 294 547 294;
#P connect 38 0 33 1;
#P fasten 33 0 54 0 532 383 569 383;
#P connect 54 0 46 0;
#P fasten 38 0 54 1 547 336 586 336;
#P fasten 35 0 34 0 666 152 625 152;
#P fasten 32 0 35 0 42 121 666 121;
#P connect 35 0 37 0;
#P connect 23 0 21 0;
#P connect 24 0 22 0;
#P connect 51 0 50 0;
#P connect 53 0 50 0;
#P connect 52 0 51 0;
#P connect 28 0 26 0;
#P connect 31 0 26 0;
#P fasten 35 0 24 0 666 152 953 152 953 312 843 312;
#P connect 29 0 28 0;
#P fasten 35 0 23 0 666 152 858 152;
#P connect 27 0 25 0;
#P fasten 26 0 27 0 842 464 888 464;
#P fasten 50 0 27 0 731 464 888 464;
#P connect 27 0 25 1;
#P pop;


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