lue-bird/elm-state-interface/2.0.4

Web.Audio.Parameter

at : Float -> AudioParameterTimeline

Set it to a constant value. Add through to make it transition from this starting value over time

through : Posix -> Float -> AudioParameterTimeline -> AudioParameterTimeline

Specify a key value at a given absolute point in time. The parameter will then transition linearly between those points.

Let's define an audio function that fades in to 1 and then fades out until it's 0 again.

import Duration
import Time
import Web.Audio.Parameter




-- 1                ________
--                /         \
-- 0 ____________/           \_______
--    t ->    fade in     fade out
fadeInOut fadeInStartTime fadeOutEndTime audio =
    Web.Audio.Parameter.at 0
        |> Web.Audio.Parameter.through fadeInStartTime 1
        |> Web.Audio.Parameter.through (Duration.addTo fadeInStartTime Duration.second) 1
        |> Web.Audio.Parameter.through (Duration.subtractFrom fadeOutEndTime Duration.second) 1
        |> Web.Audio.Parameter.through fadeOutEndTime 0

You do not have to worry about order.