A set of currently active oscillators. Each oscillator is represented as a map containing:
:osc-node -- the oscillator node :gain-node -- the gain node it's connected to :model-id -- the ID of the model that was used as a blueprint to create the oscillator
A set of currently active oscillators. Each oscillator is represented as a map containing: :osc-node -- the oscillator node :gain-node -- the gain node it's connected to :model-id -- the ID of the model that was used as a blueprint to create the oscillator
(osc & {:keys [type context clock] :as osc-map})
Models the state of an oscillator.
e.g. (osc :type :square :freq 440 :gain 0.5)
This produces a map that is used to create a fresh oscillator every time one is needed. Because oscillators can only be started once, this provides an abstraction for a 'persistent oscillator' that can be reused any number of times (but under the hood, it's just a blueprint for any number of oscillators).
:type, :freq and :gain are all optional.
:type defaults to a sine wave.
:freq and :gain are optional default values that, when present, are used when playing notes that do not specify frequency/gain values. If left out, they default to 440 Hz and 1.0 (full volume), respectively.
You can also supply your own AudioContext as :context, otherwise Mantra will create and use its own AudioContext.
Similarly, you can supply your own chronoid clock as :clock, otherwise Mantra will create one for you.
Models the state of an oscillator. e.g. (osc :type :square :freq 440 :gain 0.5) This produces a map that is used to create a fresh oscillator every time one is needed. Because oscillators can only be started once, this provides an abstraction for a 'persistent oscillator' that can be reused any number of times (but under the hood, it's just a blueprint for any number of oscillators). :type, :freq and :gain are all optional. :type defaults to a sine wave. :freq and :gain are optional default values that, when present, are used when playing notes that do not specify frequency/gain values. If left out, they default to 440 Hz and 1.0 (full volume), respectively. You can also supply your own AudioContext as :context, otherwise Mantra will create and use its own AudioContext. Similarly, you can supply your own chronoid clock as :clock, otherwise Mantra will create one for you.
(osc* {:keys [id type freq context clock]})
Creates a one-off oscillator based on a map, hooks it up to a gain node, and hooks the gain node up to the destination of the AudioContext.
Returns a map including the oscillator and gain nodes and the ID of the oscillator model used as a blueprint.
Creates a one-off oscillator based on a map, hooks it up to a gain node, and hooks the gain node up to the destination of the AudioContext. Returns a map including the oscillator and gain nodes and the ID of the oscillator model used as a blueprint.
(start-osc {:keys [osc-node] :as osc-impl})
Start an oscillator and add it to oscillators.
Start an oscillator and add it to *oscillators*.
(stop-all-oscs)
Silences and stops all currently playing oscillators.
Silences and stops all currently playing oscillators.
(stop-osc osc)
Silences and stops a currently playing oscillator.
This fn can take either an osc-model or an osc-impl as an argument.
Silences and stops a currently playing oscillator. This fn can take either an osc-model or an osc-impl as an argument.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close