Audio Transformation
Although users could use AudioCommonOption to specify playing rate and starting point, users may want to change some property of the playing stream when it is playing, such as fading effects.
Messenger allows users to transform an audio dynamically.
The definition of the SOM call is:
SOMTransformAudio AudioTarget (Audio -> Audio)
The first argument is the target, and the second argument if a transformation function.
Existing transformation functions are provided in elm-audio. See its documentation for detailed explanation.
Example 1. Change the volume of a playing audio:
SOMTransformAudio (AudioName 0 "bg") (scaleVolume 0.5)
Example 2. Fading effects:
let
ts =
env.globalData.currentTimeStamp
nts =
Time.millisToPosix <| floor ts + 2000
lts =
Time.millisToPosix <| floor ts + 6000
in
SOMTransformAudio (AudioName 0 "bg") (scaleVolumeAt [ ( Time.millisToPosix <| floor env.globalData.currentTimeStamp, 0 ), ( nts, 2 ), ( lts, 0 ) ])