Forums > MaxMSP

Offline file slicer/creator

November 23, 2006 | 12:16 pm

Hi
I am creating a very simple non-realtime (offline)
patch that slices an audio file (aiff, wav etc) into lots of equal length files and names them.

So far I am using Buffer~ and info~ to get the info on how long each new file should be, but i am not sure where to go next. Should I use peek~ or poke~ or index~…..
I have included the patch below. If anyone can point me in the right direction it would much appreciated.
Thanks in advance

David

max v2;
#N vpatcher 203 63 1209 607;
#P origin 3 0;
#P window setfont Monaco 9.;
#P flonum 588 324 108 9 0 0 0 4 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 588 361 125 9 0 0 0 4 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 588 341 157 262153 peek~ cutup;
#P window linecount 5;
#P comment 38 373 217 262153 this is where I am getting stuck. Not sure whether to use poke~ , peek~ , index~….. to tell buffer~ to divide up the sample into individual slices;
#P user panel 27 366 236 71;
#X brgb 184 170 211;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P window linecount 1;
#P message 26 36 184 262153 This is the patch so far…..;
#P window setfont "Sans Serif" 9.;
#P window linecount 2;
#P comment 129 324 52 196617 samples per slice;
#P flonum 28 325 97 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont Monaco 14.;
#P flonum 125 239 56 14 1. 0 5 4 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont Monaco 9.;
#P window linecount 1;
#P newex 38 269 72 262153 t b f f;
#P newex 28 290 41 262153 / 16.;
#P flonum 28 210 88 9 0 0 0 4 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 28 93 40 262153 clear;
#P hidden newex 28 73 58 262153 loadbang;
#P hidden message 342 302 46 262153 set $1;
#P window setfont "Sans Serif" 9.;
#P comment 339 189 88 196617 display length ms;
#P flonum 352 204 84 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont Monaco 9.;
#P message 305 167 76 262153 set cutup 2;
#P button 305 141 15 0;
#P window setfont "Sans Serif" 9.;
#P user waveform~ 305 224 200 74 3 9;
#W mode select;
#W mouseoutput continuous;
#W unit ms;
#W grid 1000.;
#W ticks 0;
#W labels 1;
#W vlabels 0;
#W vticks 1;
#W bpm 120. 4.;
#W frgb 33 0 0;
#W brgb 60 178 173;
#W rgb2 0 95 255;
#W rgb3 0 0 0;
#W rgb4 0 0 0;
#W rgb5 190 137 255;
#W rgb6 100 100 100;
#W rgb7 100 100 100;
#P newex 601 215 51 196617 tosymbol;
#B color 5;
#P newex 601 147 52 196617 t b s path;
#P newex 601 177 36 196617 zl reg;
#P message 601 127 83 196617 mysoundfile.aiff;
#P newex 601 196 72 196617 sprintf %s%s;
#P newex 601 235 73 196617 prepend write;
#N thispatcher;
#Q end;
#P newobj 722 167 61 196617 thispatcher;
#P newex 601 254 71 196617 buffer~ cutup;
#P window linecount 2;
#P comment 183 239 83 196617 # of slices to be created;
#P window linecount 1;
#P newex 28 183 66 196617 mstosamps~;
#B color 5;
#P message 120 179 75 196617 1234.aif;
#P newex 120 160 62 196617 prepend set;
#P window setfont Monaco 9.;
#P message 73 93 52 262153 replace;
#P newex 28 140 105 262153 info~ cutup;
#P newex 28 113 88 262153 buffer~ cutup;
#P window linecount 3;
#P comment 602 83 256 262153 Thinking of using this to name and write files to a folder ie file001 , file002 , file003 etc;
#P comment 338 127 100 262153 this is just here for aesthetics;
#P user panel 297 115 229 223;
#X brgb 80 142 152;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P user panel 583 79 319 221;
#X brgb 135 182 116;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P user panel 19 30 254 414;
#X brgb 176 171 104;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P background;
#P hidden connect 26 0 27 0;
#P hidden connect 27 0 5 0;
#P hidden connect 7 0 5 0;
#P connect 5 1 6 0;
#P connect 6 6 10 0;
#P connect 10 1 28 0;
#P connect 28 0 29 0;
#P connect 30 0 29 0;
#P connect 29 0 32 0;
#P connect 31 0 30 0;
#P connect 30 1 29 1;
#P connect 6 7 8 0;
#P connect 8 0 9 0;
#P connect 5 1 21 0;
#P connect 21 0 22 0;
#P connect 22 0 20 0;
#P hidden connect 20 1 25 0;
#P hidden connect 25 0 23 0;
#P connect 23 0 20 1;
#P connect 39 0 37 0;
#P connect 37 0 38 0;
#P connect 16 0 18 0;
#P connect 18 0 17 0;
#P connect 17 0 15 0;
#P connect 15 0 19 0;
#P connect 19 0 14 0;
#P connect 14 0 12 0;
#P connect 13 1 17 1;
#P connect 18 1 15 1;
#P connect 18 2 13 0;
#P pop;


November 23, 2006 | 3:10 pm



grg
November 23, 2006 | 4:19 pm

Am 23.11.2006 um 13:16 schrieb David Atkinson:
> So far I am using Buffer~ and info~ to get the info on how long each
> new file should be, but i am not sure where to go next. Should I use
> peek~ or poke~ or index~…..

Just make a 2nd buffer with the length of one slice, then use uzi with
your "samples per slice" and peek~ to read the samples from the cutup
buffer into another peek~ to set the samples to the slice buffer. Then
save the slice buffer. Wrap a counter arround this somehow that
increments an offset for the first peek~ and the filename. You can also
check out bufcopy~ from Bill Orcut, also I think Eric Lyons just
released MSP Potpourri has an object for copying parts of a buffer,
forgot the name though. These might be faster than peek and uzi.

Cheers, g.


November 23, 2006 | 7:26 pm

Perhaps you could use sfinfo~ to get the length of the sound file in
ms. Divide this by the number of slices you want (n) to get the slice
size (ss). Then use the read message to buffer~ with two floats after
the original file name specifying offset into the file and length to
read…

For each slice use the message:

[read file.aif < (n*ss)> < (n*ss)+ss>]

where for the first slice n = 0. Then use your write message to save
the buffer to file before reading in the next slice

hope that follows, and indeed works – I’ve not tested the idea.

sdf

On 23/11/06, Georg Bosch wrote:
>
> Am 23.11.2006 um 13:16 schrieb David Atkinson:
> > So far I am using Buffer~ and info~ to get the info on how long each
> > new file should be, but i am not sure where to go next. Should I use
> > peek~ or poke~ or index~…..
>
> Just make a 2nd buffer with the length of one slice, then use uzi with
> your "samples per slice" and peek~ to read the samples from the cutup
> buffer into another peek~ to set the samples to the slice buffer. Then
> save the slice buffer. Wrap a counter arround this somehow that
> increments an offset for the first peek~ and the filename. You can also
> check out bufcopy~ from Bill Orcut, also I think Eric Lyons just
> released MSP Potpourri has an object for copying parts of a buffer,
> forgot the name though. These might be faster than peek and uzi.
>
> Cheers, g.
>
>


November 23, 2006 | 8:41 pm


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