Last active
September 25, 2021 14:54
-
-
Save mikesol/d488e591fe57aebffc407ce7435fbf6c to your computer and use it in GitHub Desktop.
Anamorphism
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
module Main where | |
import Prelude | |
import Data.NonEmpty ((:|)) | |
import Effect (Effect) | |
import Data.Function (on) | |
import WAGS.Lib.Learn (play) | |
import WAGS.Lib.Learn.Note (accelerando, noteFromPitch_, repeat, seq) | |
import WAGS.Lib.Learn.Pitch (at, fuse, c4, d4, e4, fSharp4, gSharp4, bFlat4, c5, wholeTone) | |
import WAGS.Lib.Cofree (ana) | |
main :: Effect Unit | |
main = | |
play | |
$ map fuse | |
$ (map <<< map) _.note | |
$ ana | |
((<*>) \time { note, rising } -> | |
if on (>=) (at time) note c5 then { note: bFlat4, rising: false } | |
else if on (<=) (at time) note c4 then { note: d4, rising: true } | |
else { note: (if rising then add else sub) note wholeTone, rising } | |
) | |
(const { note: c4, rising: true }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment