pd-andy/elm-web-audio/2.2.0

NOTE: the latest version is 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 (fork, verified). The original repository is gone. This copy comes from a fork that still has the tag. The Lamdera package server serves a copy recovered from https://github.com/munozu/elm-web-audio (a fork).

What we checked: Rebuilt with git archive from commit 25d471f6363c of https://github.com/munozu/elm-web-audio (a fork) (zip prefix pd-andy-elm-web-audio-2ccf2bb/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 ceab29dfc967d58f704429d4423ded6682e82ec8.

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.2.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