/* This is an extended object, which computes sine (simulation time)
every processing step.
Made after documentation in Extended.doc.
*/
float TWOPI = 2 * 3.141593
float modulation
create neutral /sine
// Create field called output
addfield /sine output
addfield /sine period
addfield /sine amplitude
addfield /sine background_level
addfield /sine phase
// Define a PROCESS and make the sine object a device
// class object
addaction /sine PROCESS __sinePROCESS__
addclass /sine device
// PROCESS action script function
function __sinePROCESS__(action)
modulation = {sin {{TWOPI} * {getstat -time} / {getfield . period} + {getfield . phase}}}
// echo {modulation}
// setfield . output {{getfield . amplitude} * {modulation + 1} + {getfield . background_level}}
setfield . output {{getfield . amplitude} * {modulation} + {getfield . background_level}}
end
// create the sine object
addobject sine /sine -author "J. R. Maex" \
-description "Computes sine of simulation time"