From e36cb5b292ff26456686204dc0e6f69744aafd02 Mon Sep 17 00:00:00 2001 From: Mike Solomon Date: Thu, 8 Jul 2021 12:47:20 +0300 Subject: [PATCH] Bumps version --- CHANGELOG.md | 6 +++++ package.json | 2 +- src/WAGS/Control/Functions.purs | 32 ++++++++++++++++++++--- src/WAGS/Control/Functions/Validated.purs | 20 ++++++++++++++ 4 files changed, 56 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e2d9964..14fdf945 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.9] - 2021-08-07 + +### Added + +- `startUsingWithHint` allows the quick bootstrapping of audio graphs at the beginning of a scene for instances where a fully-determined graph type is not present but a term or function producing that graph is. + ## [0.3.8] - 2021-08-07 ### Added diff --git a/package.json b/package.json index 10e0e23b..9516fa8f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "purescript-wags", - "version": "0.3.8", + "version": "0.3.9", "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 2e92d843..25b7557e 100644 --- a/src/WAGS/Control/Functions.purs +++ b/src/WAGS/Control/Functions.purs @@ -2,6 +2,7 @@ module WAGS.Control.Functions ( start , istart , startUsing + , startUsingWithHint , modifyRes , imodifyRes , makeScene @@ -23,14 +24,15 @@ module WAGS.Control.Functions , (<@) , (<|@) , (<||@) + , class GraphHint ) 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.CreateT (class CreateT) import WAGS.Interpret (class AudioInterpret) import WAGS.Patch (class Patch, ipatch) @@ -133,11 +135,35 @@ startUsing :: AudioInterpret audio engine => Patch () graph => control -> - (forall proofA. WAG audio engine proofA res { | graph } control -> - Scene env audio engine proofA res) -> + ( 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 +class GraphHint (i :: Type) (o :: Row Type) | i -> o + +instance graphHintRec :: GraphHint { | o } o + +instance graphHintF :: GraphHint x o => GraphHint (y -> x) o + +startUsingWithHint :: + forall env audio engine res hintable hint graph control. + Monoid res => + AudioInterpret audio engine => + GraphHint hintable hint => + CreateT hint () graph => + Patch () graph => + hintable -> + control -> + ( forall proofA. + WAG audio engine proofA res { | graph } control -> + Scene env audio engine proofA res + ) -> + Scene env audio engine Frame0 res +startUsingWithHint hint 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 bb9e8abb..c7e80f88 100644 --- a/src/WAGS/Control/Functions/Validated.purs +++ b/src/WAGS/Control/Functions/Validated.purs @@ -7,6 +7,7 @@ module WAGS.Control.Functions.Validated , makeSceneR' , makeSceneR'Flipped , startUsing + , startUsingWithHint , loop , iloop , branch @@ -25,9 +26,11 @@ module WAGS.Control.Functions.Validated import Prelude import Data.Either (Either) +import WAGS.Control.Functions (class GraphHint) import WAGS.Control.Functions as Functions import WAGS.Control.Indexed (IxWAG, IxFrame) import WAGS.Control.Types (EFrame, Frame, Frame0, Scene, WAG) +import WAGS.CreateT (class CreateT) import WAGS.Interpret (class AudioInterpret) import WAGS.Patch (class Patch) import WAGS.Validation (class GraphIsRenderable) @@ -161,6 +164,23 @@ startUsing :: Scene env audio engine Frame0 res startUsing = Functions.startUsing +startUsingWithHint :: + forall env audio engine res hintable hint graph control. + Monoid res => + AudioInterpret audio engine => + GraphIsRenderable graph => + GraphHint hintable hint => + CreateT hint () graph => + Patch () graph => + hintable -> + control -> + ( forall proofA. + WAG audio engine proofA res { | graph } control -> + Scene env audio engine proofA res + ) -> + Scene env audio engine Frame0 res +startUsingWithHint = Functions.startUsingWithHint + freeze :: forall env audio engine proof res graph x. Monoid res =>