pd-andy/elm-web-audio/2.3.0

Renamed to hayleigh-dot-dev/elm-web-audio. It is published under that name, and new versions come out there.

Versions published as pd-andy/elm-web-audio still install under that name. 5 versions of 5 come from the new location (see their notes).

Rerouted (cache, verified). The original is gone. This copy comes from a Lamdera package cache made before it went. The Lamdera package server serves a copy recovered from a Lamdera package cache from 2021-02-13.

What we checked: Rebuilt from the unpacked sources in a Lamdera package cache (5 copies agree), which Elm only writes after the published SHA-1 checked out; elm.json is byte-identical to package.elm-lang.org's; the exposed modules match docs.json; the zip is our own, so its SHA-1 is not the published one.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/pd-andy/elm-web-audio/zipball/2.3.0/

WebAudio.Property

Types

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.

type Value

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!

Basic Constructors

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.

Primatives

bool : Bool -> Value

Convert a Bool to a Property value.

import WebAudio.Property exposing (nodeProperty, bool)


nodeProperty "loop" (bool True)
float : Float -> Value

Convert a Float to a Property value.

import WebAudio.Property exposing (audioParam, float)


audioParam "detune" (float 0.2)
floatList : List Float -> Value

Convert a list of Floats to a Property value.

import WebAudio.Property exposing (nodeProperty, floatList)


nodeProperty "buffer" (floatList [0, 0.5, 1, 0.5, 0, -0.5, -1])
int : 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")

Scheduled Audio Params

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.

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.

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.

Properties

attack : Float -> Property
buffer : List Float -> Property
curve : List Float -> Property
delayTime : Float -> Property
detune : Float -> Property
fftSize : Int -> Property
frequency : Float -> Property
gain : Float -> Property
knee : Float -> Property
loop : Bool -> Property
loopEnd : Float -> Property
loopStart : Float -> Property
offset : Float -> Property
oversample : String -> Property
pan : Float -> Property
positionX : Float -> Property
positionY : Float -> Property
positionZ : Float -> Property
q : Float -> Property
ratio : Float -> Property
reduction : Float -> Property
release : Float -> Property
threshold : Float -> Property
type_ : String -> Property

JSON Encoding

encode : Property -> Value