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/
A simple type alias representing the type of Node. This could be
something like "OscillatorNode" or "RefNode".
A simple type alias representing unique key used to identify nodes. Use
Keys like you would use the id attribute on a HTML element.
General way to construct Web Audio nodes. This is used to create all the
helper functions below. You can use this function to define custom nodes by
partially applying just the type parameter. This is handy if you're using a
library like Tone.js and want to use those nodes in Elm.
omniOscillator : List Property -> List Node -> Node
omniOscillator =
node "Tone-OmniOscillatorNode"
myOsc =
omniOscillator
[ Property.freq 440 ]
[ dac ]A ref node is used to refer to a keyed node elsewhere in the graph. This is how we connect multiple "chains" of nodes together and represet a graph in a simple list.
Use this function to apply a key to a node. In the case of already keyed nodes, or ref nodes, this will update the key to the new value.
a = osc [ Property.freq 440 ] [ dac ]
b = key "b" <| gain [ Property.gain 0.5 ] [ dac ]
c = ref "b"
key "myOsc" a -- Give a the key "myOsc"
key "myGain" b -- Rename b's key to "myGain"
key "myOsc" c -- c is now a RefNode to "myOsc"Audio nodes can connect to AudioParams to modulate their value. Use this function for that. The first argument is the key of an existing keyedd node and the second argument is the name of the AudioParam to connect to.
This is commonly used for frequency modulation (FM) and amplitude modulation (AM) synthesis.
a = osc [ frequency 10 ] [ param "carrier" "frequency" ]
b = key "carrier" <| osc [] [ dac ]Under the hood, this actually just creates a standard ref node! You could create this function yourself:
param key name = ref (key ++ "." name)See: https://developer.mozilla.org/en-US/docs/Web/API/OscillatorNode Common properties:
See: https://developer.mozilla.org/en-US/docs/Web/API/GainNode Common properties:
See: https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode Common properties:
See: https://developer.mozilla.org/en-US/docs/Web/API/DelayNode Common properties:
See: https://developer.mozilla.org/en-US/docs/Web/API/ConstantSourceNode Common properties:
See: https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode Common properties:
See: https://developer.mozilla.org/en-US/docs/Web/API/ConvolverNode Common properties:
See: https://developer.mozilla.org/en-US/docs/Web/API/DynamicsCompressorNode Common properties:
See: https://developer.mozilla.org/en-US/docs/Web/API/PannerNode Common properties:
See: https://developer.mozilla.org/en-US/docs/Web/API/StereoPannerNode Common properties:
See: https://developer.mozilla.org/en-US/docs/Web/API/WaveShaperNode Common properties:
To turn the json in Web Audio nodes, you need to know what that data looks like. Here's a breakdown of how everything is encoded:
Node:
{
"type": "OscillatorNode",
"properties": [
...
],
"connections": [
...
]
}Keyed:
{
"key": "myOsc",
"type": "OscillatorNode",
"properties": [
...
],
"connections": [
...
]
}Ref:
{
"key": "myOsc",
"type": "RefNode"
}Properties can come in two types, AudioParam and NodeProperty. While the Web Audio API doesn't make an official distinction between the two, how they are used differs.
AudioParams represent parameters that can be updated at either audio rate (a-rate) or control rate (k-rate). Other audio nodes can connect to an AudioParam and modulate its value in real time. Examples of AudioParams include frequency, gain, and delayTime.
AudioParam:
{
"type": "AudioParam",
"label": "frequency",
"value": 440
}NodeProperties are any other parameter on an audio node. An example of a NodeProperty is an OscillatorNode's "type" parameter.
NodeProperty:
{
"type": "NodeProperty",
"label": "type",
"value": "square"
}Converts a Node into a Json value. Use this to send a node through a port
to javascipt, where it can be constructed into a Web Audio node!
Encode a graph of nodes into a Json value. More than likely you'll use this
more than encode
The core building block of any Web Audio signal graph.
Keyednodes are just like regular nodes but with an additonalKeyproperty. This allowsRefnodes to reference them elsewhere in the graph!