Skip to content

Instantly share code, notes, and snippets.

@mikesol
Last active September 24, 2020 21:33
Show Gist options
  • Save mikesol/c28a01d3bb382d8a9d24dbb636835a21 to your computer and use it in GitHub Desktop.
Save mikesol/c28a01d3bb382d8a9d24dbb636835a21 to your computer and use it in GitHub Desktop.
A forest sound with a drone underneath
module Klank.Dev where
-- new to purescript? check out https://www.purescript.org/ for learning resources!
import Prelude
import Data.List ((:), List(..))
import Data.NonEmpty ((:|))
import Data.Typelevel.Num (D1)
import FRP.Behavior (Behavior)
import FRP.Behavior.Audio (AudioUnit, gain', runInBrowser_, play, sinOsc, speaker)
import Math (pi, sin)
scene :: Behavior Number -> Behavior (AudioUnit D1)
scene _ =
pure
( speaker
$ ( (gain' 0.2 $ sinOsc 110.0)
:| (gain' 0.1 $ sinOsc 220.0)
: (gain' 0.5 $ (play "forest"))
: Nil
)
)
-- change to true if you use `microphone` above
enableMicrophone = false
-- add a mouse, keyboard or other device here if needed
main = runInBrowser_ (pure scene)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment