class::FitzHughNagumo			
summary::Neuron Firing Model Oscillator
related:: Classes/TermanWang
categories:: UGens>Generators>Chaotic
//SLUGens released under the GNU GPL as extensions for SuperCollider 3, by Nick Collins, http://composerprogrammer.com/index.html
keyword:: SLUGens


Description::
Naive Euler ODE solver implementation of the FitzHugh-Nagumo neuronal 2-dimensional model for oscillatory firing.  

du/dt= rateu*(u-0.3333*u^3 - w)
dw/dt= ratew*(b0+b1*u - w)

All inputs can have .kr rate UGens plugged in.

classmethods::

method::ar

argument::reset
input
argument::rateu
update rate for u
argument::ratew
update rate for w 
argument::b0
equation constant
argument::b1
equation constant
argument::initu
reset value for u
argument::initw
reset value for w


Examples::

code::
//Can be very noisy, high pitched and aliases badly- ie great fun, but watch out for your ears, filter, try out odd param settings. I've turned all the amplitudes down in the following


//defaults, high pitched! WARNING
{Out.ar(0,Pan2.ar(0.05*FitzHughNagumo.ar(0,0.01,0.01,1,1),0.0))}.play

//updates too fast, nice noise
{Out.ar(0,Pan2.ar(0.02*FitzHughNagumo.ar(0,1,1,1,1),0.0))}.play

//modulate constants to mess with noise
{Out.ar(0,Pan2.ar(0.01*FitzHughNagumo.ar(0,1,1,LFNoise0.kr(1,0.48,0.5),LFNoise0.kr(1,0.9,1)),0.0))}.play

//retrigger
{Out.ar(0,Pan2.ar(0.1*FitzHughNagumo.ar(Impulse.kr(10),0.0001,0.001,1,0.000001,LFNoise0.kr(10),LFNoise0.kr(10)),0.0))}.play

//more retriggering with mouse exploration 
{Out.ar(0,Pan2.ar(0.05*FitzHughNagumo.ar(Impulse.kr(10),MouseX.kr(0.0001,0.1,'exponential'),MouseY.kr(0.0001,0.1,'exponential'),0.5,0.1,LFNoise0.kr(10,0.3),LFNoise0.kr(10,0.2)),0.0))}.play

//right of the screen is most amusing
{Out.ar(0,Pan2.ar(0.1*FitzHughNagumo.ar(Impulse.kr(100),MouseX.kr(0.0001,1,'exponential'),MouseY.kr(0.0001,1,'exponential'),0.5,0.1,SinOsc.kr(10,0,0.3),SinOsc.kr(10,0,0.8)),0.0))}.play

//explore
(
{Out.ar(0,Pan2.ar(

CombN.ar(
Resonz.ar(FitzHughNagumo.ar(Impulse.kr(LFNoise1.kr(1,10,50)),MouseX.kr(0.0001,100,'exponential'),MouseY.kr(0.0001,1,'exponential'),MouseY.kr(0.1,3),MouseX.kr(0.1,3),SinOsc.kr(20,0,0.7),SinOsc.kr(21,0,0.8)),LFNoise1.kr(LFNoise1.kr(0.2,0.05,0.07),400,600),0.1),
0.05,0.05,2
)
,0.0))}.play
)

//surprise! (wait for it)
(
SynthDef("FHN-surprise",{Out.ar(0,Pan2.ar(

CombN.ar(RLPF.ar(FitzHughNagumo.ar(0,0.00001,0.00001, mul:0.1),1000,0.01),0.1,0.1,10)
,0.0))
}).play
)



//controlled surprise
(
SynthDef("FHN-surprise",{Out.ar(0,Pan2.ar(

CombN.ar(RLPF.ar(FitzHughNagumo.ar(0,0.00001,MouseY.kr(0.00001,1,'exponential'),1, mul:0.1),1000,0.01),0.1,0.1,10)
,0.0))
}).play
)




//feedback pair
(
SynthDef("FHN-surprise",{
var fn1, fn2, retrigger;

retrigger= Impulse.kr(15);

fn1= MouseX.kr(0.0,1.0)*FitzHughNagumo.ar(retrigger,0.001,0.001,LocalIn.ar(1),1);
fn2= MouseY.kr(0.0,1.0)*FitzHughNagumo.ar(retrigger,0.001,0.001,fn1,1);

LocalOut.ar(fn2);

Out.ar(0,Pan2.ar((fn1+fn2),0.0))
}).play
)

::
