A type to encapsulate all the different properties that can exist on a Web Audio node. This could be something like an oscillator's frequency, whether an audio buffer is set to loop, or whether a filter is a highpass or a lowpass filter.
The implementation is currently concealled because I don't think it is necessary to distinguish between the different types of Property when developing.
Properties can have different types of value, for example the frequency
property of an oscillator is a Float
but its type property is a String
. To
capture all these posibilities we have a special Value type.
See the Primatives section below for functions create Values yourself. This is only necessary if you're creating a Property manually because you're using some custom audio nodes or you can't find a Property below.
Note: If you can't find a Property but it's exists on a standard Web Audio node, consider submitting an issue or a pull request to add it!
nodeProperty : String -> Value -> Property
Note: It is rare to need to create your own properties in this way.
audioParam : String -> Value -> Property
Node: It is rare to need to create your own properties in this way.
bool : Basics.Bool -> Value
Convert a Bool
to a Property value.
import WebAudio.Property exposing (nodeProperty, bool)
nodeProperty "loop" (bool True)
float : Basics.Float -> Value
Convert a Float
to a Property value.
import WebAudio.Property exposing (audioParam, float)
audioParam "detune" (float 0.2)
floatList : List Basics.Float -> Value
Convert a list of Float
s to a Property value.
import WebAudio.Property exposing (nodeProperty, floatList)
nodeProperty "buffer" (floatList [0, 0.5, 1, 0.5, 0, -0.5, -1])
int : Basics.Int -> Value
Convert an Int
to a Property value.
import WebAudio.Property exposing (nodeProperty, int)
nodeProperty "fftSize" (int 512)
string : String -> Value
Convert a String
to a Property value.
import WebAudio.Property exposing (nodeProperty, string)
nodeProperty "type" (string "triangle")
setValueAtTime : Property -> Basics.Float -> Property
Schedule an update to a property to take place at some point in the future.
import WebAudio.Property exposing (setValueAtTime, frequency)
setValueAtTime (frequency 440) 1
It's important to note that 1
refers to one second after an Audio Context has
started, not one second from now. This is best used once you have the
current time from an existing Audio Context.
linearRampToValueAtTime : Property -> Basics.Float -> Property
Schedule a linear ramp of a property value from now untl some point in the future.
import WebAudio.Property exposing (linearRampToValueAtTime, frequency)
linearRampToValueAtTime (frequency 440) 1
It's important to note that 1
refers to one second after an Audio Context has
started, not one second from now. This is best used once you have the
current time from an existing Audio Context.
exponentialRampToValueAtTime : Property -> Basics.Float -> Property
Schedule an exponential ramp of a property value from now untl some point in the future. Try to make sure the value is non-zero!
import WebAudio.Property exposing (exponentialRampToValueAtTime, frequency)
exponentialRampToValueAtTime (frequency 440) 1
It's important to note that 1
refers to one second after an Audio Context has
started, not one second from now. This is best used once you have the
current time from an existing Audio Context.
attack : Basics.Float -> Property
buffer : List Basics.Float -> Property
coneInnerAngle : Basics.Float -> Property
coneOuterAngle : Basics.Float -> Property
coneOuterGain : Basics.Float -> Property
curve : List Basics.Float -> Property
delayTime : Basics.Float -> Property
detune : Basics.Float -> Property
distanceModel : String -> Property
fftSize : Basics.Int -> Property
frequency : Basics.Float -> Property
gain : Basics.Float -> Property
knee : Basics.Float -> Property
loop : Basics.Bool -> Property
loopEnd : Basics.Float -> Property
loopStart : Basics.Float -> Property
maxChannelCount : Basics.Int -> Property
maxDecibels : Basics.Float -> Property
minDecibels : Basics.Float -> Property
normalize : Basics.Bool -> Property
offset : Basics.Float -> Property
orientationX : Basics.Float -> Property
orientationY : Basics.Float -> Property
orientationZ : Basics.Float -> Property
oversample : String -> Property
pan : Basics.Float -> Property
panningModel : String -> Property
playbackRate : Basics.Float -> Property
positionX : Basics.Float -> Property
positionY : Basics.Float -> Property
positionZ : Basics.Float -> Property
q : Basics.Float -> Property
ratio : Basics.Float -> Property
reduction : Basics.Float -> Property
refDistance : Basics.Float -> Property
release : Basics.Float -> Property
rolloffFactor : Basics.Float -> Property
smoothingTimeConstant : Basics.Float -> Property
threshold : Basics.Float -> Property
type_ : String -> Property
encode : Property -> Json.Encode.Value