Forums > MaxMSP

Dynamic recording through sfrecord~

December 15, 2006 | 7:30 am

I’m having issues dynamically recording with sfrecord~. In other words, I’d like to send a message which sets the filename of sfrecord~ and can be altered dynamically through an argument. In other words, "open $1-record". This is simple enough, and it works, but when I try a similar message for sfplay~, it can’t find the file–it’s getting stored in various directories when recording. So, I opted for an absolute path specification. I started with a message which read: "open /Users/blahblah/$1-record.aif" This didn’t recognize the argument (variable?) and actually recorded a file named "$1-record.aif". The forward slash seemed to get in the way of the dollar sign. Then, I tried passing "$1-record.aif" to a prepend object with the value "prepend open /Users/blahblah/" This doesn’t work either. When I print the output of this object, I get "open /Users/blahblah/ 1-record.aif" It is now recognizing the argument/variable, but adding the trailing space at the end of the prepend message–throwing everything off. What can I do?

Here’s a trimmed-down version of the patch:

max v2;
#N vpatcher 20 74 1005 602;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 73 132 32 196617 print;
#P message 669 135 14 196617 3;
#P message 650 135 14 196617 2;
#P message 632 135 14 196617 1;
#P window linecount 2;
#P message 632 202 72 196617 ; recordwhen 1;
#P window linecount 3;
#P message 632 157 131 196617 ; recordwhat $1-record.aif ; recordwhen 1;
#P window linecount 1;
#P newex 73 106 295 196617 prepend open /Users/Brennon/Documents/School/Recordings/;
#P message 301 221 30 196617 open;
#P newex 429 85 71 196617 r recordwhen;
#P newex 73 85 70 196617 r recordwhat;
#P newex 302 183 59 196617 r playwhat;
#P message 440 323 27 196617 stop;
#P message 366 323 65 196617 startwindow;
#P comment 366 309 69 196617 • start audio;
#P user panel 358 303 123 43;
#X brgb 255 255 255;
#X frgb 100 202 30;
#X border 2;
#X rounded 0;
#X shadow 0;
#X done;
#P message 385 183 14 196617 0;
#P message 366 183 14 196617 1;
#P newex 366 248 31 196617 dac~;
#N sfplay~ 2 120960 0 ;
#P newobj 366 215 53 196617 sfplay~ 2;
#P newex 366 131 64 196617 sfrecord~ 2;
#P newex 366 85 31 196617 adc~;
#P connect 11 0 14 0;
#P connect 14 0 20 0;
#P fasten 14 0 1 0 78 127 371 127;
#P connect 0 0 1 0;
#P fasten 12 0 1 0 434 117 371 117;
#P connect 13 0 2 0;
#P connect 10 0 2 0;
#P connect 5 0 2 0;
#P connect 4 0 2 0;
#P hidden connect 9 0 3 0;
#P hidden connect 8 0 3 0;
#P connect 2 0 3 0;
#P connect 2 1 3 1;
#P connect 0 1 1 1;
#P connect 19 0 15 0;
#P connect 18 0 15 0;
#P connect 17 0 15 0;
#P pop;

Thanks!
BB


December 15, 2006 | 8:23 am

Quote: brennon@brennonbortz.com wrote on Fri, 15 December 2006 00:30
—————————————————-
I started with a message which read: "open /Users/blahblah/$1-record.aif" This didn’t recognize the argument (variable?) and actually recorded a file named "$1-record.aif". The forward slash seemed to get in the way of the dollar sign. Then, I tried passing "$1-record.aif" to a prepend object with the value "prepend open /Users/blahblah/" This doesn’t work either. When I print the output of this object, I get "open /Users/blahblah/ 1-record.aif" It is now recognizing the argument/variable, but adding the trailing space at the end of the prepend message–throwing everything off. What can I do?

—————————————————-

How about using [sprintf]?

/dan

max v2;
#N vpatcher 20 74 1005 602;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 56 106 305 196617 sprintf open /Users/Brennon/Documents/School/Recordings/%s;
#P newex 56 130 32 196617 print;
#P message 669 135 14 196617 3;
#P message 650 135 14 196617 2;
#P message 632 135 14 196617 1;
#P window linecount 2;
#P message 632 202 72 196617 ; recordwhen 1;
#P window linecount 3;
#P message 632 157 131 196617 ; recordwhat $1-record.aif ; recordwhen 1;
#P window linecount 1;
#P message 301 221 30 196617 open;
#P newex 429 85 71 196617 r recordwhen;
#P newex 56 83 70 196617 r recordwhat;
#P newex 302 183 59 196617 r playwhat;
#P message 440 323 27 196617 stop;
#P message 366 323 65 196617 startwindow;
#P comment 366 309 69 196617 • start audio;
#P user panel 358 303 123 43;
#X brgb 255 255 255;
#X frgb 100 202 30;
#X border 2;
#X rounded 0;
#X shadow 0;
#X done;
#P message 385 183 14 196617 0;
#P message 366 183 14 196617 1;
#P newex 366 248 31 196617 dac~;
#N sfplay~ 2 120960 0 ;
#P newobj 366 215 53 196617 sfplay~ 2;
#P newex 366 131 64 196617 sfrecord~ 2;
#P newex 366 85 31 196617 adc~;
#P connect 11 0 20 0;
#P connect 20 0 19 0;
#P connect 20 0 1 0;
#P fasten 12 0 1 0 434 117 371 117;
#P connect 0 0 1 0;
#P connect 4 0 2 0;
#P connect 5 0 2 0;
#P connect 10 0 2 0;
#P connect 13 0 2 0;
#P connect 2 0 3 0;
#P hidden connect 8 0 3 0;
#P hidden connect 9 0 3 0;
#P connect 2 1 3 1;
#P connect 0 1 1 1;
#P connect 16 0 14 0;
#P connect 17 0 14 0;
#P connect 18 0 14 0;
#P pop;


January 21, 2007 | 3:06 am

That will work perfectly…thanks for the direction!


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