I made an abstraction that writes multiple output files with a maximum
size setable by the user. Only stereo output files are supported, and
the control is via multiple messages so it isn't a straight drop-in
replacement. The patch uses two [writesf~] objects for double buffering
as the help file says there must be a delay between a "stop" and the
next "open".
Attached are the patch and help patch. It is advisable to send the
messages to the writesafe2~ in the order given in the help patch, I
haven't tested other orderings.
Still in the patch are [print]s to show what the [writesf~]s are
receiving, example output from the help patch, playing with the start
and stop controls towards the end:
===
writesafe2~-0: open -bytes 4 -wave -rate 44100 /home/claude/tmp/test0003.wav
writesafe2~-0: start
writesafe2~-0: stop
writesafe2~-1: open -bytes 4 -wave -rate 44100 /home/claude/tmp/test0004.wav
writesafe2~-1: start
writesafe2~-1: stop
writesafe2~-0: open -bytes 4 -wave -rate 44100 /home/claude/tmp/test0005.wav
writesafe2~-0: start
writesafe2~-0: stop
writesafe2~-1: open -bytes 4 -wave -rate 44100 /home/claude/tmp/test0006.wav
writesafe2~-1: start
writesafe2~-1: stop
writesafe2~-0: open -bytes 4 -wave -rate 44100 /home/claude/tmp/test0007.wav
writesafe2~-0: start
writesafe2~-0: stop
writesafe2~-1: open -bytes 4 -wave -rate 44100 /home/claude/tmp/test0008.wav
writesafe2~-1: start
writesafe2~-1: stop
writesafe2~-0: open -bytes 4 -wave -rate 44100 /home/claude/tmp/test0009.wav
writesafe2~-0: start
writesafe2~-0: stop
writesafe2~-1: open -bytes 4 -wave -rate 44100 /home/claude/tmp/test0010.wav
writesafe2~-1: start
writesafe2~-1: stop
writesafe2~-0: open -bytes 4 -wave -rate 44100 /home/claude/tmp/test0011.wav
writesafe2~-0: start
writesafe2~-0: stop
writesafe2~-1: open -bytes 4 -wave -rate 44100 /home/claude/tmp/test0012.wav
writesafe2~-1: start
writesafe2~-1: stop
writesafe2~-1: stop
writesafe2~-0: open -bytes 4 -wave -rate 44100 /home/claude/tmp/test0013.wav
writesafe2~-0: start
writesafe2~-0: stop
writesafe2~-1: open -bytes 4 -wave -rate 44100 /home/claude/tmp/test0014.wav
writesafe2~-1: start
writesafe2~-1: stop
writesafe2~-1: stop
writesafe2~-0: open -bytes 4 -wave -rate 44100 /home/claude/tmp/test0015.wav
writesafe2~-0: start
writesafe2~-0: stop
writesafe2~-0: stop
writesafe2~-1: open -bytes 4 -wave -rate 44100 /home/claude/tmp/test0016.wav
writesafe2~-1: start
writesafe2~-1: stop
===
And the resulting files:
===
$ ls ~/tmp/ -l
-rw-rw-r-- 1 claude claude 799788 Oct 29 09:51 test0003.wav
-rw-rw-r-- 1 claude claude 799788 Oct 29 09:51 test0004.wav
-rw-rw-r-- 1 claude claude 800300 Oct 29 09:51 test0005.wav
-rw-rw-r-- 1 claude claude 799788 Oct 29 09:51 test0006.wav
-rw-rw-r-- 1 claude claude 800300 Oct 29 09:51 test0007.wav
-rw-rw-r-- 1 claude claude 799788 Oct 29 09:51 test0008.wav
-rw-rw-r-- 1 claude claude 800300 Oct 29 09:51 test0009.wav
-rw-rw-r-- 1 claude claude 799788 Oct 29 09:51 test0010.wav
-rw-rw-r-- 1 claude claude 800300 Oct 29 09:52 test0011.wav
-rw-rw-r-- 1 claude claude 498732 Oct 29 09:52 test0012.wav
-rw-rw-r-- 1 claude claude 799788 Oct 29 09:52 test0013.wav
-rw-rw-r-- 1 claude claude 655916 Oct 29 09:52 test0014.wav
-rw-rw-r-- 1 claude claude 179756 Oct 29 09:52 test0015.wav
-rw-rw-r-- 1 claude claude 145452 Oct 29 09:52 test0016.wav
===
I hope this is useful for some of you :-)
#N canvas 75 83 489 521 10;
#X obj 15 121 osc~ 440;
#X obj 15 161 writesafe2~;
#X msg 95 121 start;
#X msg 145 121 stop;
#X msg 87 79 samples 100000 \, bytes 4 \, format wave \, rate 44100
\, open /home/claude/tmp/test%04d.wav \, index 3;
#X text 15 4 writesafe2~.pd and writesafe2~-help.pd (c) 2004 ClaudiusMaximus
\, licensed to you under GPL;
#X text 24 243 bytes <float> -- sample format: 2 (integer PCM) or 3
(integer PCM) or 4 (float);
#X text 24 275 format wave \, format aiff -- choice of file format
\, default is wave;
#X text 24 211 samples <float> -- approximate maximum number of samples
in each output file;
#X text 24 307 rate <float> -- sets file header \, does NOT resample
;
#X text 24 326 open <symbol> -- set pattern for filenames \, should
include one %d or variant;
#X text 24 358 index <integer> -- set starting file index number;
#X obj 38 469 writesf~;
#X text 24 447 SEE ALSO:;
#X text 24 377 start -- when not recording = start recording \; when
recording = skip to the next index;
#X text 24 409 stop -- stop recording;
#X text 86 61 click this one first;
#X text 185 122 then control recording with these;
#X connect 0 0 1 0;
#X connect 0 0 1 1;
#X connect 2 0 1 2;
#X connect 3 0 1 2;
#X connect 4 0 1 2;
#N canvas 156 0 788 978 10;
#X obj 20 927 writesf~ 2;
#X obj 20 13 inlet~ audio-L;
#X obj 124 13 inlet~ audio-R;
#X obj 244 13 inlet control;
#X msg 289 113 2;
#X obj 214 209 min;
#X obj 289 93 select 2 3 4;
#X msg 315 113 3;
#X msg 341 113 4;
#X obj 368 113 print writesafe2~-error-bytes;
#X obj 610 53 print writesafe2~-error;
#X text 289 180 max number of samples in a 1GB file;
#X msg 410 143 1e+09;
#X obj 59 947 writesf~ 2;
#X obj 263 797 + 1;
#X obj 263 817 % 2;
#X obj 169 847 demux 2;
#X obj 506 286 samplerate~;
#X obj 521 365 expr $f2 / $f1 * 1000;
#X obj 462 256 t b b;
#X obj 308 592 print writesafe2~-error-format;
#X obj 289 143 t f f;
#X obj 289 163 expr $f2 / $f1 / 2;
#X msg 224 140 1e+08;
#X obj 418 13 t b b b b b;
#X msg 194 706 stop;
#X obj 213 777 float;
#X msg 243 757 0;
#X msg 223 828 1;
#X obj 350 13 loadbang;
#X obj 169 519 makefilename;
#X msg 169 449 set \$1;
#X obj 506 338 spigot;
#X obj 521 236 t f b;
#X msg 551 257 0;
#X obj 214 163 max 10000;
#X obj 226 479 float;
#X msg 266 459 0;
#X text 268 480 index;
#X text 260 774 write select;
#X obj 276 509 + 1;
#X obj 462 408 metro;
#X obj 213 927 print writesafe2~-1;
#X obj 169 947 print writesafe2~-0;
#X obj 201 572 select wave aiff;
#X msg 582 256 1;
#X msg 462 368 1;
#X msg 478 388 0;
#X obj 244 33 route samples bytes format rate open start stop index
;
#X obj 462 428 t b b b;
#X obj 169 429 messageprepend list;
#X obj 201 552 messageprepend symbol;
#X msg 254 612 symbol -aiff;
#X obj 169 652 pack s s f f;
#X obj 169 867 t a a;
#X obj 213 867 t a a;
#X msg 169 682 open -bytes \$3 \$2 -rate \$4 \$1 \, start;
#X msg 201 592 symbol -wave;
#X text 418 770 writesafe2~.pd and writesafe2~-help.pd (c) 2004 ClaudiusMaximus
\, licensed to you under GPL;
#X connect 1 0 0 0;
#X connect 1 0 13 0;
#X connect 2 0 0 1;
#X connect 2 0 13 1;
#X connect 3 0 48 0;
#X connect 4 0 21 0;
#X connect 5 0 18 1;
#X connect 6 0 4 0;
#X connect 6 1 7 0;
#X connect 6 2 8 0;
#X connect 6 3 9 0;
#X connect 7 0 21 0;
#X connect 8 0 21 0;
#X connect 12 0 22 1;
#X connect 14 0 15 0;
#X connect 15 0 26 1;
#X connect 16 0 54 0;
#X connect 16 1 55 0;
#X connect 17 0 32 0;
#X connect 18 0 41 1;
#X connect 19 0 46 0;
#X connect 19 1 17 0;
#X connect 21 0 22 0;
#X connect 21 1 53 2;
#X connect 22 0 5 1;
#X connect 23 0 35 0;
#X connect 24 0 12 0;
#X connect 24 0 17 0;
#X connect 24 1 4 0;
#X connect 24 2 23 0;
#X connect 24 3 45 0;
#X connect 24 4 27 0;
#X connect 25 0 16 0;
#X connect 26 0 14 0;
#X connect 26 0 16 1;
#X connect 27 0 26 1;
#X connect 28 0 16 1;
#X connect 29 0 24 0;
#X connect 30 0 53 0;
#X connect 31 0 30 0;
#X connect 32 0 18 0;
#X connect 32 0 53 3;
#X connect 33 0 18 0;
#X connect 33 0 53 3;
#X connect 33 1 34 0;
#X connect 34 0 32 1;
#X connect 35 0 5 0;
#X connect 36 0 40 0;
#X connect 36 0 30 0;
#X connect 37 0 36 1;
#X connect 40 0 36 1;
#X connect 41 0 49 0;
#X connect 44 0 57 0;
#X connect 44 1 52 0;
#X connect 44 2 20 0;
#X connect 45 0 32 1;
#X connect 46 0 41 0;
#X connect 47 0 41 0;
#X connect 48 0 35 0;
#X connect 48 1 6 0;
#X connect 48 2 51 0;
#X connect 48 3 33 0;
#X connect 48 4 50 0;
#X connect 48 5 19 0;
#X connect 48 6 47 0;
#X connect 48 6 25 0;
#X connect 48 7 36 1;
#X connect 48 8 10 0;
#X connect 49 0 36 0;
#X connect 49 1 26 0;
#X connect 49 2 25 0;
#X connect 50 0 31 0;
#X connect 51 0 44 0;
#X connect 52 0 53 1;
#X connect 53 0 56 0;
#X connect 54 0 0 0;
#X connect 54 1 43 0;
#X connect 55 0 13 0;
#X connect 55 1 42 0;
#X connect 56 0 16 0;
#X connect 57 0 53 1;