diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e804d40..3e2d9964 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.3.8] - 2021-08-07 + +### Added + +- `startUsing` allows the quick bootstrapping of audio graphs at the beginning of a scene. + ## [0.3.7] - 2021-07-07 ### Changed diff --git a/package.json b/package.json index 5d7138ec..10e0e23b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "purescript-wags", - "version": "0.3.7", + "version": "0.3.8", "description": "Web Audio Graphs as a Stream", "scripts": { "build": "spago build", diff --git a/src/WAGS/Control/Functions.purs b/src/WAGS/Control/Functions.purs index ff849c21..2e92d843 100644 --- a/src/WAGS/Control/Functions.purs +++ b/src/WAGS/Control/Functions.purs @@ -1,6 +1,7 @@ module WAGS.Control.Functions ( start , istart + , startUsing , modifyRes , imodifyRes , makeScene @@ -25,11 +26,13 @@ module WAGS.Control.Functions ) where import Prelude + import Control.Comonad (extract) import Data.Either (Either(..)) import WAGS.Control.Indexed (IxWAG(..), IxFrame) import WAGS.Control.Types (AudioState', EFrame, Frame, Frame0, InitialWAG, Scene(..), Scene', WAG, oneFrame, unsafeUnWAG, unsafeWAG) import WAGS.Interpret (class AudioInterpret) +import WAGS.Patch (class Patch, ipatch) -- | The initial `Frame` that is needed to begin any `Scene`. -- | @@ -124,6 +127,17 @@ istart m = makeSceneR (\e -> let IxWAG f = m e in f start) infixr 6 istart as @!> +startUsing :: + forall env audio engine res graph control. + Monoid res => + AudioInterpret audio engine => + Patch () graph => + control -> + (forall proofA. WAG audio engine proofA res { | graph } control -> + Scene env audio engine proofA res) -> + Scene env audio engine Frame0 res +startUsing control next = const (ipatch $> control) @!> next + -- | Loops audio. -- | -- | The first argument is the loop and the second argument is the incoming graph that gets rendered before the loop. diff --git a/src/WAGS/Control/Functions/Validated.purs b/src/WAGS/Control/Functions/Validated.purs index 8c8d821b..bb9e8abb 100644 --- a/src/WAGS/Control/Functions/Validated.purs +++ b/src/WAGS/Control/Functions/Validated.purs @@ -6,6 +6,7 @@ module WAGS.Control.Functions.Validated , makeSceneRFlipped , makeSceneR' , makeSceneR'Flipped + , startUsing , loop , iloop , branch @@ -22,11 +23,13 @@ module WAGS.Control.Functions.Validated ) where import Prelude + import Data.Either (Either) import WAGS.Control.Functions as Functions import WAGS.Control.Indexed (IxWAG, IxFrame) import WAGS.Control.Types (EFrame, Frame, Frame0, Scene, WAG) import WAGS.Interpret (class AudioInterpret) +import WAGS.Patch (class Patch) import WAGS.Validation (class GraphIsRenderable) makeScene :: @@ -146,6 +149,18 @@ istart = Functions.istart infixr 6 istart as @!> +startUsing :: + forall env audio engine res graph control. + Monoid res => + AudioInterpret audio engine => + GraphIsRenderable graph => + Patch () graph => + control -> + (forall proofA. WAG audio engine proofA res { | graph } control -> + Scene env audio engine proofA res) -> + Scene env audio engine Frame0 res +startUsing = Functions.startUsing + freeze :: forall env audio engine proof res graph x. Monoid res =>