Forums > MaxMSP

saving n opening files – file path

April 21, 2006 | 5:57 pm

hi all,

for the first time in many years of maxing, I’m attempting to put
together a proper save/load system for the patch I’m building. I’ve
been looking through the help files and manual, but it’s not making
any sense to me.

My patch creates audio buffers with associated coll files (the coll
contains a list of audio segments in the buffer~, created with
record~ in append mode).

I want to save both buffer and coll with similar names – ie the user
enters a filename using textedit, and then an aiff file and a coll
text file are saved with the same name (but obviously different file
types). and then I’m going to want to do the same in reverse (ie load
the two related files).

I used to do this as two separate operations, but that’s untidy,
which is why I want to do it as a single (as far as the user is
concerned) operation. I’m also trying to avoid having the user open a
save dialog as that does require the 2 separate save dialogs – one
for the buffer and another for the coll.

So I want the user to enter a filename, click on a button, and then
everything else happen in the background.

I’ve figured out how to use textedit instead of dialog, so that bit’s
done. And I’ve managed to get coll to save using [prepend write]
following the file name. The thing I’m currently having problems with
is setting the file path – I want to save the files in a specific
folder inside the patcher folder. I need to tell both coll and
buffer~ to use this path for these specific save and load operations.

Can anyone give me any pointers as to how to go about doing this
(asuuming that it’s possible!)

thanks

David


April 21, 2006 | 6:24 pm

Hi.
welcome back. Checlout this thread:
http://www.cycling74.com/forums/index.php?t=msg&goto=60080&r id=0&S=f2cb293332080bf4e9ae814dbf484984&srch=Specifying+save +path#msg_60080

on that issue. I got to it by searching for: Specifying save path

best,
wes


April 21, 2006 | 6:34 pm

whats wrong with using savedialog and opendialog ?
simple, see below, or if i understood your wrong, sorry.
cheers,
tatsu.

max v2;
#N vpatcher 180 187 635 507;
#P window setfont "Sans Serif" 9.;
#P newex 249 209 50 196617 buffer~ bar 10 2;
#N coll b 1;
#P newobj 182 209 50 196617 coll b 1;
#N vpatcher 818 311 949 645;
#P window setfont "Sans Serif" 9.;
#P newex 46 172 39 196617 – 1;
#P newex 17 55 50 196617 tosymbol;
#N comlet parent folder path;
#P outlet 17 246 15 0;
#N comlet file path in;
#P inlet 17 32 15 0;
#P newex 17 121 69 196617 t l l 46;
#P newex 17 197 39 196617 zl slice;
#P newex 46 150 39 196617 zl sub;
#P newex 17 101 50 196617 thresh;
#P newex 17 77 50 196617 spell;
#P newex 17 220 50 196617 ascii;
#P connect 6 0 8 0;
#P connect 8 0 1 0;
#P connect 1 0 2 0;
#P connect 2 0 5 0;
#P connect 5 0 4 0;
#P connect 4 0 0 0;
#P connect 0 0 7 0;
#P connect 5 1 3 0;
#P connect 3 0 9 0;
#P connect 9 0 4 1;
#P connect 5 2 3 1;
#P pop;
#P newobj 182 125 122 196617 p remove_file_extension;
#P button 182 63 15 0;
#P newex 182 156 50 196617 sprintf read %s.txt;
#P newex 249 156 50 196617 sprintf replace %s.aif;
#P newex 182 98 107 196617 opendialog;
#P newex 115 209 50 196617 buffer~ foo 10 2;
#P newex 115 156 50 196617 sprintf write %s.aif;
#P newex 51 156 50 196617 sprintf write %s.txt;
#N coll a 1;
#P newobj 51 209 50 196617 coll a 1;
#P button 51 63 15 0;
#P newex 51 98 107 196617 savedialog;
#P connect 1 0 0 0;
#P connect 0 0 3 0;
#P connect 3 0 2 0;
#P fasten 0 0 4 0 56 148 120 148;
#P connect 4 0 5 0;
#P connect 9 0 6 0;
#P connect 6 0 10 0;
#P connect 10 0 8 0;
#P connect 8 0 11 0;
#P fasten 10 0 7 0 187 149 254 149;
#P connect 7 0 12 0;
#P pop;


April 21, 2006 | 11:14 pm

hi tatsu,

thanks for that. the missing ingredient for me was [sprintf] –
another object that I’ve managed to avoid getting my head around
before now. Getting the write message on the front of the filepath
was what i couldn’t get working.
I’ve assumed that the [ascii] object in the sub-patch is the same as
[itoa]/

thanks again

David


April 21, 2006 | 11:16 pm

thanks Wes,

you may already have seen in my previous reply that [sprintf] was the
missing ingredient. I also noticed whilst working on this that I
still haven’t gotten my head all the way around the symbol/message
thang in max. Time for some more brain enhancing smart pills!

David


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