Skip to content

Instantly share code, notes, and snippets.

@TheSeamau5
Created May 7, 2015 17:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheSeamau5/78adb0d3482445e22270 to your computer and use it in GitHub Desktop.
Save TheSeamau5/78adb0d3482445e22270 to your computer and use it in GitHub Desktop.
Outline for Web Audio API in Elm
----------------------------
-- Basic Audio Operations --
----------------------------
getAudio : String -> Task Http.Error Audio
play : Audio -> Task error ()
stop : Audio -> Task error ()
pause : Audio -> Task error ()
seek : Time -> Audio error ()
startAt : Time -> Audio -> Task error ()
loop : Audio -> Task error ()
getSupportedFormats : Task error (List String)
setVolume : Float -> Audio -> Task error ()
mute : Audio -> Task error ()
mute = setVolume 0
setSpeed : Float -> Audio -> Task error ()
-------------
-- Filters --
-------------
-- Either have filters be of this type
type alias Filter = Audio -> Audio
-- or have a way to apply filters to an Audio
filter : Filter -> Audio -> Audio
-- This way is simply imperative
connect : Audio -> AudioOutput -> Task error ()
disconnect : Audio -> Task error ()
-- Alternatively, you can module the Audio as a tree of nodes eventually
-- connecting to one or more outputs. This would make the
-- connect an disconnect functions functional and hence not involve tasks
-- The gain filter options should follow the Web Audio API
gainFilter : GainFilterOptions -> Filter
-- The bi-quad filter options should follow the Web Audio API
biquadFilter : BiquadFilterOptions -> Filter
-- The oscillator options should follow the Web Audio API
oscilator : OscillatorOptions -> Audio
-- You can the define square, triangular, or whatever types of waves
-- from this function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment