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

Each of the functions contained in this module are wrappers for the existing Browser application types. They need just two additions to the record:

  • An audio function that takes your model and returns a WebAudio.Graph.
audio : Model -> WebAudio.Graph
audio model =
  List.map voice model.notes
  • A port to send the encoded audio graph to javascript.
port audioPort : Json.Encode.Value -> Cmd msg

With these programs, your audio function is called automatically after every update just like your view function is. So if we wanted to create a Browser.element program, we'd instead do:

main : Program () Model Msg
main =
  WebAudio.Program.element
    { init = init
    , update = update
    , audio = audio
    , view = view
    , subscriptions = subscriptions
    , audioPort = audioPort
    }

The only program from Browser not support is Browser.sandbox as those programs cannot produce Cmds and so can't call the port needed to send our audio graph to javascript.

{ init : flags -> ( model, Cmd msg )
, update : msg -> model -> ( model, Cmd msg )
, audio : model -> Graph
, view : model -> Html msg
, subscriptions : model -> Sub msg
, audioPort : Value -> Cmd msg
}
-> Program flags model msg
{ init : flags -> ( model, Cmd msg )
, update : msg -> model -> ( model, Cmd msg )
, audio : model -> Graph
, view : model -> Document msg
, subscriptions : model -> Sub msg
, audioPort : Value -> Cmd msg
}
-> Program flags model msg
{ init : flags -> Url -> Key -> ( model, Cmd msg )
, update : msg -> model -> ( model, Cmd msg )
, audio : model -> Graph
, view : model -> Document msg
, subscriptions : model -> Sub msg
, audioPort : Value -> Cmd msg
, onUrlRequest : UrlRequest -> msg
, onUrlChange : Url -> msg
}
-> Program flags model msg