baseSM (Function) Class
Base factory for sound models
Item Index
Methods
(baseSM)
-
i_node
-
i_inputs
-
i_outputs
Creates a new "GraphNode" that can be connected in an audio graph just like a Web Audio API audioNode (). The GraphNode returned also provides the generic interface (play, stop, setParam) for control. Also provides methods the sound modeler uses to, for example, register parameters to expose to users.
Parameters:
-
i_node
Objectshould be empty literal object {}
-
i_inputs
AudioNode Arrayan array of audio nodes that can be use to connect to this GraphNode
-
i_outputs
AudioNode Arrayan array of audio nodes that will be used to connect this GraphNode to other audio nodes or the audio destinations
Returns:
The object used as "the model" providing the interface for configuring and controling. All other methods in this module belong to this object.
getAboutText
()
String
Returns:
text descritption of model, hints, created with setAboutText
getNumParams
()
Number
Returns:
the number of paramters the model exposes
getParam
-
i_name
-
i_prop
Get specified information about a parameter
Parameters:
-
i_name
Stringthe name of the param you want info about
-
i_prop
Stringon of ["name", "type", "val", "normval", "min" or "max"]
Returns:
the value of the property you requested
getParamNames
()
Array of Strings
Returns:
array of model parameter names
getParamNames
-
index
Parameters:
-
index
Objectindex of the parameter whose name you want
Returns:
the name of the parameter with the secified index
onPlay
-
i_time
Override this in your sound model
Parameters:
-
i_time
Numbertime to play (can be fed to Web Audio API nodes in your override)
onRelease
-
i_time
Override this in your sound model to send the model in to its release phase
Parameters:
-
i_time
Numbertime to release (can be fed to Web Audio API nodes in your override)
onStop
-
i_time
override this in your sound model (optional)
Parameters:
-
i_time
Numbertime to stop (can be fed to Web Audio API nodes)
play
-
i_time
Parameters:
-
i_time
Numberwhat time to play (recommended use: 0 or no argument; use schedule(t,func) to scheudle play in the future)
qClear
()
Clear the queue of all future events for this model.
registerChildParam
-
childModel
-
childPname
-
[parentPname=childPname]
Grabs a parameter from a child model, registers it on this model, and just reflects all calls to the child
Parameters:
-
childModel
SoundModel -
childPname
Stringname of the child parameter to expose
-
[parentPname=childPname]
String optionalname to use for the parameter
registerParam
-
i_name
-
i_type
-
i_val
-
i_f
Creates a parameter that will be used to control the model and provide information
Parameters:
-
i_name
Stringname to expose to the world for this param
-
i_type
Stringtype ["range", "URL"]
-
i_val
Stringinitial value
-
i_f
Stringfunction to execute when setParam(name, val) is called.
registerParam
-
name
-
the
-
with
-
function
Register a param which will then be accessible through the interface functions: setParam, getParam, etc.
Parameters:
-
name
Numberthe String value used to refer to this parameters
-
the
StringjsaSound type of the parameter (either "range" or "URL"), the latter of which would better be called a string parameter.
-
with
Objectthree numberical properties: ("min", "max", and "val"), the minimumum, maximum, and default values of the parameter.
-
function
Functionto execute when the parameter is set with setParam()
release
-
i_time
Parameters:
-
i_time
Numbertime to release (recommended use: 0 or no argument; use schedule(t,func) to scheudle releases in the future)
schedule
-
t
-
{Function
schedule a function to run in the future (uses a queue and a single timer)
Parameters:
-
t
Numbertime to execute
-
{Function
Objectfunction to execute at time t
setAboutText
-
i_text
Parameters:
-
i_text
Stringtext descritption of model, hints, etc
setParam
-
i_name
-
i_val
set the parameter using values using its own units in [min,max]
Parameters:
-
i_name
Stringthe name of the param you want to set
-
i_val
Numberthe value to set the parameter
setParamNorm
-
i_name
-
i_val
Set the parameter using values in [0,1]
Parameters:
-
i_name
Stringthe name of the param you want to set
-
i_val
Numberthe value to set the parameter
startRecording
()
Start recording audio output from the model
stop
-
i_time
Stop the model from playing, disconnects it from output so it won't waste system resources anymore. Your onRelease() method should schedule or call stop when it is done
Parameters:
-
i_time
Numbertime to stop (recommended use: 0 or no argument; use schedule(t,func) to scheudle stops in the future)
stopRecording
()
Stop recording audio output from the model
testPName
-
i_ind
test a parameter number for existence
Parameters:
-
i_ind
Numberindex of parameter
Returns:
either the parmaeter name (if it exists) or undefined