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.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
{ init : flags -> ( model, Cmd msg )
, update : msg -> model -> ( model, Cmd msg )
, audio : model -> Graph
, subscriptions : model -> Sub msg
, audioPort : Value -> Cmd msg
}
-> Program flags model msg