API Docs for: 0.0.1
Show:

baseSM (Function) Class

Defined in: jsaSndLib\baseSM.js:7
Module: baseSM.js

Base factory for sound models

Methods

(baseSM)

(
  • i_node
  • i_inputs
  • i_outputs
)
Interface Object

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 Object

    should be empty literal object {}

  • i_inputs AudioNode Array

    an array of audio nodes that can be use to connect to this GraphNode

  • i_outputs AudioNode Array

    an array of audio nodes that will be used to connect this GraphNode to other audio nodes or the audio destinations

Returns:

Interface Object:

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:

String:

text descritption of model, hints, created with setAboutText

getNumParams

() Number

Returns:

Number:

the number of paramters the model exposes

getParam

(
  • i_name
  • i_prop
)

Get specified information about a parameter

Parameters:

  • i_name String

    the name of the param you want info about

  • i_prop String

    on of ["name", "type", "val", "normval", "min" or "max"]

Returns:

the value of the property you requested

getParamNames

() Array of Strings

Returns:

Array of Strings:

array of model parameter names

getParamNames

(
  • index
)
String

Parameters:

  • index Object

    index of the parameter whose name you want

Returns:

String:

the name of the parameter with the secified index

onPlay

(
  • i_time
)

Override this in your sound model

Parameters:

  • i_time Number

    time 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 Number

    time 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 Number

    time to stop (can be fed to Web Audio API nodes)

play

(
  • i_time
)

Parameters:

  • i_time Number

    what 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 String

    name of the child parameter to expose

  • [parentPname=childPname] String optional

    name 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 String

    name to expose to the world for this param

  • i_type String

    type ["range", "URL"]

  • i_val String

    initial value

  • i_f String

    function 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 Number

    the String value used to refer to this parameters

  • the String

    jsaSound type of the parameter (either "range" or "URL"), the latter of which would better be called a string parameter.

  • with Object

    three numberical properties: ("min", "max", and "val"), the minimumum, maximum, and default values of the parameter.

  • function Function

    to execute when the parameter is set with setParam()

release

(
  • i_time
)

Parameters:

  • i_time Number

    time 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 Number

    time to execute

  • {Function Object

    function to execute at time t

setAboutText

(
  • i_text
)

Parameters:

  • i_text String

    text 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 String

    the name of the param you want to set

  • i_val Number

    the value to set the parameter

setParamNorm

(
  • i_name
  • i_val
)

Set the parameter using values in [0,1]

Parameters:

  • i_name String

    the name of the param you want to set

  • i_val Number

    the 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 Number

    time 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 Number

    index of parameter

Returns:

either the parmaeter name (if it exists) or undefined