Forums > MaxMSP

Schmitt trigger

December 11, 2007 | 12:21 am

Hello i’m trying to implement a Schmitt trigger (http://en.wikipedia.org/wiki/Schmitt_trigger) in the signal domain. It’s quite easy to make with non signal objects but i’d like some help doing it with signals.

I know that the Schmitt trigger is implemented in the 2threshattack~ object but i’d like to know how to construct it with standard objects.

Thanks,

John.


December 11, 2007 | 1:17 am

Hi John

To gate the amplitude envelop, I’d say a peakamp based solution works nicely, but that obviously is making this solution max based as well, so maybe it’s not quite what your after.

S

max v2;
#N vpatcher 20 148 769 750;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 377 170 117 196617 low level for gate off;
#P newex 74 152 38 196617 sig~ 1;
#P user scope~ 209 330 339 460 256 3 128 -1. 1. 0 0. 0 0. 102 255 51 135 135 135 0;
#P user scope~ 77 329 207 459 256 3 128 -1. 1. 0 0. 0 0. 102 255 51 135 135 135 0;
#P flonum 331 169 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 310 129 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user ezadc~ 143 62 187 95 0;
#P newex 185 193 124 196617 if $f1 < $f2 then 0 else 1;
#P newex 90 231 35 196617 gate~;
#P newex 164 162 157 196617 if $f1 > $f2 then 1 else out2 $f1;
#P newex 151 128 69 196617 peakamp~ 30;
#P comment 352 131 100 196617 high level for gate on;
#P connect 3 0 8 0;
#P fasten 4 0 3 0 190 218 95 218;
#P fasten 2 0 3 0 169 192 95 192;
#P connect 10 0 3 1;
#P connect 5 0 1 0;
#P connect 1 0 2 0;
#P fasten 2 1 4 0 316 186 190 186;
#P fasten 5 0 9 0 148 301 214 301;
#P connect 7 0 4 1;
#P connect 6 0 2 1;
#P pop;


December 11, 2007 | 4:39 am

Hi John,

thresh~ will fit the bill, and comes with Max.

Peter McCulloch


December 11, 2007 | 4:56 am

Thanks Peter,

I’ve been trying to brush up on my signal domain chops and had managed to completely overlook the thresh~ object.

Hi Sebastian,

Thanks for that but not really what i was after, hope things are good for you.

John.


December 11, 2007 | 5:38 am

Also, thresh~ can be pretty interesting for gated amp env. effects
when paired with slide~ or rampsmooth~.

Peter McCulloch


December 11, 2007 | 9:40 am

On 11 Dec 2007, at 04:56, Leafcutter John wrote:

>
> Thanks Peter,
>
> I’ve been trying to brush up on my signal domain chops and had
> managed to completely overlook the thresh~ object.

hi john,

here is yet another solution using only standard objects.
i did this years ago for a project, before thresh~ came to live.
it’s simplicity doesn’t reflect the time it took me to come up with
this solution…

-volker.

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 295 101 71 196617 threshold;
#P comment 260 87 71 196617 high;
#P user ezdac~ 46 211 90 244 0;
#P newex 73 89 38 196617 sig~ 0;
#P flonum 73 65 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user scope~ 282 209 412 339 256 3 128 -1. 1. 0 0. 0 0. 102 255 51
135 135 135 0;
#P newex 282 162 81 196617 thresh~ 0.2 0.5;
#P user scope~ 140 209 270 339 256 3 128 -1. 1. 0 0. 0 0. 102 255 51
135 135 135 0;
#P flonum 257 100 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 219 100 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#N vpatcher 20 74 304 338;
#P inlet 58 48 15 0;
#P inlet 139 46 15 0;
#P inlet 163 46 15 0;
#P outlet 58 180 15 0;
#P window setfont "Sans Serif" 9.;
#P newex 104 99 45 196617 < =~ 0.2;
#P newex 58 99 45 196617 >=~ 0.5;
#P newex 58 138 56 196617 sah~ 0.5;
#P connect 6 0 1 0;
#P connect 1 0 0 0;
#P connect 0 0 3 0;
#P connect 4 0 1 1;
#P connect 6 0 2 0;
#P connect 2 0 0 1;
#P connect 1 0 0 1;
#P connect 5 0 2 1;
#P pop;
#P newobj 140 162 54 196617 p hyster~;
#P comment 225 87 71 196617 low;
#P comment 63 47 100 196617 input signal;
#P fasten 9 0 2 0 78 151 145 151;
#P fasten 9 0 6 0 78 142 287 142;
#P connect 4 0 2 2;
#P connect 4 0 6 2;
#P connect 3 0 2 1;
#P connect 3 0 6 1;
#P connect 6 0 7 0;
#P connect 8 0 9 0;
#P connect 2 0 5 0;
#P window clipboard copycount 13;


December 11, 2007 | 3:44 pm

That’s a lovely elegant bit of patching volker and it’s just the kind of thing i was hoping to see so thanks for sharing it.

There is a slight issue with it however. If the input changes abruptly from below to above the trigger say from 0-1 (as the output from phasor~ connected to >=~ object might) your abstraction will not trigger. I played about with introducing a one vector delay between the different sides of the signal input to the >=~ and < =~ objects and was able to make it work by having a delay in the >=~ side to go from 0-1 and conversely having a delay in the < =~ side allowed it to go from 1-0.

Best to all,

John.


December 13, 2007 | 6:52 pm

A co-worker inquired as to the meaning of serendipity this morning.

I come in here looking for info on Forester2, without finding it.
Then I clicked this post out of curiosity, and the CutterJohn hiself is behind the curtain.

Very glad to see it’s being worked on.


December 14, 2007 | 2:25 pm

>
> There is a slight issue with it however. If the input changes
> abruptly from below to above the trigger say from 0-1 (as the
> output from phasor~ connected to >=~ object might) your abstraction
> will not trigger.

ah ja. you’re right. [sah~] doesn’t get retriggered.
originally this was intended for envelope-signals, i.e. heavily
lowpassed signals without sharp edges.
thats probably why the flaw never occred to me.
havn’t used it since [thresh~] came along anyway.
so we might better let it rest in peace…
volker.


May 28, 2010 | 4:52 pm

Did you ever try to use Schmitt trigger (2threshattack~) and/or bonk~ in an envelope follower. Wouldn’t they help in detecting noteOff in the case of reverberant sounds?
thanks,
Fabio


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