Created
May 7, 2015 17:34
-
-
Save TheSeamau5/78adb0d3482445e22270 to your computer and use it in GitHub Desktop.
Outline for Web Audio API in Elm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---------------------------- | |
-- 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