Forums > MaxMSP

Problems in sfrecord~ ?

March 20, 2008 | 7:54 pm

I’m running under 10.5.2, and seem to be having problems with the sfrecord~ object. In the patch I’m working on, sfrecord~ is used to capture a buffered audio stream to disc at different intervals over long periods of time. The system works great for an hour or so, capturing a hundred or more samples. But, it will eventually go into spin-lock, and will require a force quit and relaunch in order to continue. This also happens if I run the patch using the Max runtime instead of in the IDE.

I find it interesting that when I do a process sample using the Sampler utility in the Developer tools, it shows the sfrecord~ process taking up 100% of the cpu time. I’ve attached a screenshot that illustrates this.

Has anyone else encountered problems like this with sfrecord~? I’ve down quite a bit of debugging, and don’t think it’s something in my patch, though that possibility always exists. I can post a barebones example if it will help get to the root of the problem.

Oh, and I have also tested the patch under 10.4.11, and the same thing occurs…

Thanks for any input,
A


March 21, 2008 | 1:44 am

Here is a scaled-down version of the patch that crashes. It’s a very simple patch, which makes me wonder if it is a bug in the sfrecord~ object causing this behavior.

Basically, the system monitors the level of incoming audio, and triggers a sample recording when the level exceeds the value set for Trigger Level. The recording will continue until the incoming audio level dips below the tTrigger Level for the period specified by Gate Time.

The patch seems to work fine when you first run it. However, if you let it run a while, it will eventually lock up.

Can anyone tell me why this patch causes a spinning-cursor lock after running a period of time?

Thanks in advance for any help.

A

- – - – - – - – - (snip) – - – - – - – - – - –

max v2;
#N vpatcher 20 74 620 474;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 441 -6 68 196617 start/stop;
#P message 180 258 14 196617 1;
#P toggle 404 656 57 0;
#P toggle 406 -15 21 0;
#P newex 211 308 67 196617 r gGateTime;
#B color 9;
#P newex 219 41 82 196617 s gGateTime;
#B color 9;
#P newex 385 528 50 196617 defer;
#P newex 367 215 79 196617 r gTriggerLevel;
#B color 9;
#P newex 114 22 82 196617 s gTriggerLevel;
#B color 9;
#P newex 184 140 84 196617 r gTriggerLevel;
#B color 9;
#N vpatcher 10 59 610 459;
#P inlet 244 61 15 0;
#P outlet 147 159 15 0;
#P inlet 145 59 15 0;
#P connect 2 0 1 0;
#P connect 0 0 1 0;
#P pop;
#P newobj 392 164 49 196617 p levels;
#P window setfont "Sans Serif" 24.;
#P number 554 83 63 24 0 0 8228 3 0 0 0 255 255 255 222 222 222 0 0 0;
#P objectname number[4];
#P window setfont "Sans Serif" 12.;
#P comment 603 98 24 196620 dB;
#P window setfont "Sans Serif" 24.;
#P number 328 82 63 24 0 0 8228 3 0 0 0 255 255 255 222 222 222 0 0 0;
#P objectname number[3];
#P window setfont "Sans Serif" 12.;
#P comment 378 98 24 196620 dB;
#P user levelmeter~ 524 65 124 62 20 0 1000 0 -60 0 0 0 0 0 0;
#X brgb 240 240 240;
#X frgb 200 200 200;
#X rgb2 0 0 0;
#X rgb3 0 0 0;
#X rgb4 0 0 0;
#X rgb5 255 0 0;
#X rgb6 220 100 100;
#X rgb7 220 150 80;
#X rgb8 220 200 100;
#X rgb9 180 210 100;
#X markers 12 6 0 -6 -12 -24 -36 -48 0;
#X markersused 8;
#X done;
#P user levelmeter~ 298 65 124 62 20 0 1000 0 -60 0 0 0 0 0 0;
#X brgb 240 240 240;
#X frgb 200 200 200;
#X rgb2 0 0 0;
#X rgb3 0 0 0;
#X rgb4 0 0 0;
#X rgb5 255 0 0;
#X rgb6 220 100 100;
#X rgb7 220 150 80;
#X rgb8 220 200 100;
#X rgb9 180 210 100;
#X markers 12 6 0 -6 -12 -24 -36 -48 0;
#X markersused 8;
#X done;
#P window setfont "Sans Serif" 10.;
#P comment 218 -22 81 196618 Gate Time;
#P window setfont "Sans Serif" 9.;
#P comment 263 3 32 196617 secs;
#P comment 155 3 32 196617 (dB);
#P newex 385 505 20 196617 t b;
#P message 143 258 31 196617 reset;
#P newex 143 227 47 196617 sel 0;
#P flonum 220 -1 42 9 2. 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname flonum[2];
#P newex 164 359 32 196617 sel 1;
#P number 143 309 46 9 1 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname number[2];
#P newex 143 286 43 196617 clocker;
#B color 2;
#P newex 190 332 31 196617 >;
#P objectname >=;
#P newex 220 20 53 196617 * 1000.;
#P objectname *;
#P window setfont "Sans Serif" 12.;
#P comment 538 131 97 196620 Input 2 Level;
#B color 15;
#P comment 313 130 98 196620 Input 1 Level;
#B color 15;
#P window setfont "Sans Serif" 9.;
#P newex 396 330 51 196617 sel 0 1;
#P newex 406 15 61 196617 adc~ 1 2;
#P newex 164 386 54 196617 onebang 0;
#P flonum 114 -1 42 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname flonum[4];
#P button 472 372 15 0;
#P newex 143 204 42 196617 < ;
#P objectname < =;
#P newex 425 401 57 196617 onebang 1;
#B color 6;
#P button 424 356 17 0;
#N vpatcher 633 286 1358 844;
#P origin 10 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 0;
#P comment 192 30 100 196617 bang for name gen;
#P newex 304 354 66 196617 conformpath;
#P newex 636 264 52 196617 % 10000;
#P number 600 228 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 557 228 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 503 228 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 503 191 119 196617 unpack 0 0 0;
#P message 366 115 30 196617 time;
#N comlet Bang to generate name;
#P inlet 170 28 15 0;
#P newex 170 71 288 196617 t b b b b;
#P message 423 115 32 196617 ticks;
#P newex 304 323 51 196617 tosymbol;
#P newex 154 177 78 196617 filepath default;
#P newex 304 294 332 196617 sprintf %s%i-%02i-%02i (%02i.%02i.%02i.%i).aif;
#P outlet 304 460 15 0;
#P number 366 228 40 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 435 228 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 305 228 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 305 191 150 196617 unpack 0 0 0;
#P newex 306 155 351 196617 date;
#B color 5;
#P message 307 115 33 196617 date;
#P connect 11 0 8 0;
#P connect 12 0 11 0;
#P connect 8 0 7 0;
#P connect 7 0 9 0;
#P connect 9 0 19 0;
#P connect 19 0 6 0;
#P connect 1 0 2 0;
#P connect 2 0 3 0;
#P connect 13 0 1 0;
#P connect 0 0 1 0;
#P connect 10 0 1 0;
#P connect 11 1 0 0;
#P connect 5 0 7 1;
#P connect 11 2 13 0;
#P connect 2 2 5 0;
#P connect 3 0 7 2;
#P connect 11 3 10 0;
#P connect 2 1 4 0;
#P connect 4 0 7 3;
#P connect 15 0 7 4;
#P connect 1 1 14 0;
#P connect 14 0 15 0;
#P connect 16 0 7 5;
#P connect 14 1 16 0;
#P connect 17 0 7 6;
#P connect 14 2 17 0;
#P connect 18 0 7 7;
#P fasten 1 2 18 0 651 223 641 223;
#P pop;
#P newobj 425 426 46 196617 p namer;
#B color 2;
#P newex 425 475 57 196617 append aif;
#P newex 425 452 68 196617 prepend open;
#P message 386 605 14 196617 1;
#P message 408 605 14 196617 0;
#P newex 396 307 27 196617 +;
#P objectname +;
#P number 298 264 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname number[1];
#P newex 298 241 40 196617 >=;
#P objectname >[1];
#P number 500 266 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P objectname number;
#P newex 500 243 30 196617 >=;
#P objectname >;
#P window setfont "Sans Serif" 10.;
#P comment 111 -22 82 196618 Trigger Level;
#P window setfont "Sans Serif" 9.;
#P newex 530 637 115 196617 adc~ 1 2;
#P comment 403 717 68 196617 record status;
#P user number~ 530 714 635 729 9 3 2 2 0. 0. 128 0. 100 0. 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 530 686 115 196617 sfrecord~ 2;
#P connect 19 0 45 0;
#P connect 43 0 17 0;
#P connect 17 0 31 0;
#P connect 31 0 32 0;
#P fasten 11 0 32 0 391 628 285 628 285 252 148 252;
#P lcolor 7;
#P connect 32 0 27 0;
#P connect 52 0 27 0;
#P connect 27 0 28 0;
#P connect 26 0 29 0;
#P connect 29 0 20 0;
#P connect 44 0 17 1;
#P connect 31 1 52 0;
#P connect 28 0 26 0;
#P connect 11 0 20 1;
#P connect 49 0 26 1;
#P connect 25 0 48 0;
#P connect 30 0 25 0;
#P connect 21 0 37 0;
#P connect 43 0 7 0;
#P connect 7 0 8 0;
#P connect 37 0 40 0;
#P connect 46 0 7 1;
#P connect 13 0 33 0;
#P connect 33 0 47 0;
#P connect 47 0 11 0;
#P connect 37 0 43 0;
#P connect 8 0 9 0;
#P connect 9 0 22 0;
#P connect 10 0 51 0;
#P connect 11 0 51 0;
#P connect 50 0 21 0;
#P fasten 20 0 10 0 169 553 413 553;
#P connect 6 0 9 1;
#P connect 22 1 15 0;
#P connect 22 2 15 0;
#P connect 15 0 16 0;
#P connect 16 0 14 0;
#P connect 14 0 12 0;
#P connect 12 0 13 0;
#P connect 38 0 43 1;
#P fasten 10 0 18 0 413 630 533 630 533 366 477 366;
#P lcolor 4;
#P connect 18 0 16 1;
#P connect 43 0 5 0;
#P connect 5 0 6 0;
#P connect 46 0 5 1;
#P connect 21 1 38 0;
#P connect 3 0 0 0;
#P connect 13 0 0 0;
#P connect 10 0 0 0;
#P connect 11 0 0 0;
#P connect 0 0 1 0;
#P connect 38 0 42 0;
#P connect 3 1 0 1;
#P pop;


March 21, 2008 | 8:29 am

On 21 mars 08, at 02:44, Adam Watson wrote:
>
> Here is a scaled-down version of the patch that crashes. It’s a
> very simple patch, which makes me wonder if it is a bug in the
> sfrecord~ object causing this behavior.
>
> Basically, the system monitors the level of incoming audio, and
> triggers a sample recording when the level exceeds the value set for
> Trigger Level. The recording will continue until the incoming audio
> level dips below the tTrigger Level for the period specified by Gate
> Time.

I would use [deferlow] rather than [defer].

Maybe your sound level changes to fast around the threshold value,
causing Max to create to many new files to fast? You may need to
smooth the output of the meters.

_____________________________
Patrick Delges

Centre de Recherches et de Formation Musicales de Wallonie asbl

http://www.crfmw.be/max


March 21, 2008 | 4:23 pm

Quote: Patrick Delges wrote on Fri, 21 March 2008 04:29
—————————————————-

> I would use [deferlow] rather than [defer].
>
> Maybe your sound level changes to fast around the threshold value,
> causing Max to create to many new files to fast? You may need to
> smooth the output of the meters.
>

Hi Patrick,

Thanks for the response. I altered the patch to take your suggestions into account, to no avail. I also added in a hardcoded delay of 500ms after the closure of the current file, to make sure that the object wasn’t being "overloaded" with open/close requests.

The hang always seems to occur on file close, but the fact that the system can run for 30 minutes or more without a hang makes this very confusing. i can’t nail down any other commonalities.

I think this may be a bug in sfrecord when used in conjunction with many different files. I’m going to set up a patch that simply creates a bunch of recordings over time, ignoring input and levels, and see if the same hang occurs.

A


March 22, 2008 | 1:28 am

Here is one more wrinkle: I turned off Overdrive and eventually it hung up, as usual. But now I also got this output message in the Max window:

freeobject: 32543280: bad object

Any ideas what this could mean?

Thanks,

A


June 23, 2009 | 11:03 am

Hi atom,

I’m running into the same problem at the moment on Max 4.6.3, Mac OS 10.5.6.

In my case the hang occurs once in approximately 20 to 40 times when a 1 is sent to sfrecord~, sfrecord~ hangs on doInt().

I’m curious whether you found any new leads in the mean time?

I’ll continue to isolate the problem in a small patch and test on more recent versions of Max.

Mattijs


June 27, 2009 | 10:12 pm

What’s the size of the file when you turn off the recording? Max cannot create file bigger than 2 GB something.


June 28, 2009 | 10:27 am
Emmanuel Jourdan wrote on Sun, 28 June 2009 00:12
What’s the size of the file when you turn off the recording? Max cannot create file bigger than 2 GB something.

Hey Emmanuel,

The recordings are small, around a few seconds.

Btw, for me the hang happens when recording is turned ON, not off.

I have the feeling this problem has something to do with starting the recording immediately after opening the file. I rewrote my patch so that there are a few seconds between the open command and the record start. That way, the hangs happens much less frequently.

On the other hand, I can’t make the hang happen with a small patch that simply makes a huge amount of recordings in a short time, it only happens in an uber-patch I’m working on. Maybe the hang only happens when other disc activity is going on, or when the system is performing heavily and the queue is getting longer, I have no clue yet.

Mattijs


June 28, 2009 | 11:03 am

* i know this shouldn’t be necessary but try using 2 (or more) sfrecords alternatively which ideally would even write to different disks (or at least partitions)

* i would do the triggerlevel-tracking differently especially calming down the results of your []. something like:

– Pasted Max Patch, click to expand. –

hth

p


July 9, 2009 | 5:45 am
Mattijs wrote on Sun, 28 June 2009 12:27
Btw, for me the hang happens when recording is turned ON, not off.

I have occasionally hanging sfrecord~ when turning off. Max hangs completely by the way. Its maybe 1 out of 40 when it hangs. I have to repaitr the header after force quiting Max. This problem exists for a long time (pre Max 5). Its more likely if I stop recording several sfrecords at the same time (seems logical…)

Btw, never had files bigger than 2 GB when it happened, could happen after a short recording time…

Unfortunately nothing reproducible…

Stefan


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