Reset signal to default value upon cable detachment

Timo's icon

Hey,

so I have this simple patch which uses a cycle~ 10 object to modulate the amplitude of another cycle~.
What I want to achieve is for the multiplication object *~ 1. to revert to it's default value after the cable gets pulled from the inlay.

If I connect the LFO directly to the multiplication object and remove the cable, everything works fine - the multiplication object reverts to its default value.
But as soon as there is an inlet in-between and I remove the connection, the multiplication object receives a constant stream of zeros (0).

I built a patch to solve the issue, but it feels way too complicated...
Can someone point me to an easier and more straightforward solution?

Thank you very much

Max Patch
Copy patch and select New From Clipboard in Max.


Roman Thilenius's icon

you can use [dspstatus] to reset signal objects by messages whenever the signal chain interrupts.

but it might not be cool in every situation, because it will do that also after you open the patcher.

nouserid's icon

Max Patch
Copy patch and select New From Clipboard in Max.

Timo's icon

@Kyle
Thank you for the patch, but it has one problem.
When I remove the patch cord, it doesn't get set to 1., but to 44100 (my current sample rate) and the output goes into clipping immediately.


Timo's icon

@Roman
Thank you, but I can't find the object dspstatus; only dspstate~ and this one only reports the overall dsp state.

nouserid's icon

Dang, I'm getting a 1. here. Sorry, but I have no idea what could be the cause of this discrepancy.

Timo's icon

Weird...
Thank you anyway!

Timo's icon

Even the simplest setup will produce the 44100.
With @min and @max set it works.
I will report a bug.

Max Patch
Copy patch and select New From Clipboard in Max.


Cory Metcalf's icon

Hi Timo, I can confirm that this happens and is a Windows only issue. @default appears to be completely ignored and the inlet defaults to the current sample rate. Thanks for the report, the issue is now ticketed.

Roman Thilenius's icon

"only dspstate~ and this one only reports the overall dsp state."

which is enough. when you change a connection, the DSP is interrupted, dspstate will output the current SR (again) - now you connect a [t b] to it and you have a mechanism which recognizes any interruption.

Roman Thilenius's icon

ah, i missed that the object also has an output for on and off :) so you were using that and ran into a bug. :)

on/off and SR works both for me in max4-win and max7-win

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 186 149 100 9109513 <-- move me;
#P newex 375 209 118 9109513 if ($i1==1) then 15.;
#P newex 385 291 50 9109513 t 15;
#P flonum 542 211 59 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 382 178 59 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 475 129 83 9109513 dspstate~;
#P number 143 150 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 143 177 50 9109513 sig~ 0.;
#P toggle 47 397 15 0;
#P newex 47 453 50 9109513 dac~;
#P user number~ 181 406 241 421 9 139 3 2 0. 0. 35 0. 20 0. 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 73 151 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 73 179 50 9109513 sig~ 0.;
#P newex 160 345 50 9109513 +~ 15.;
#P comment 179 251 100 9109513 <-- then cut me off;
#P connect 7 0 1 1;
#P connect 10 0 13 0;
#P connect 11 0 12 0;
#P connect 12 0 1 1;
#P connect 1 0 4 0;
#P connect 2 0 1 0;
#P connect 9 1 11 0;
#P connect 9 0 10 0;
#P connect 8 0 7 0;
#P connect 6 0 5 0;
#P connect 3 0 2 0;
#P window clipboard copycount 15;