zwirn 0.2.2.0 → 0.2.2.1
raw patch · 12 files changed
+54/−61 lines, 12 files
Files
- README.md +1/−6
- app/zwirnzi/CI/Config.hs +25/−27
- src/zwirn-core/Zwirn/Core/Lib/Cord.hs +2/−0
- src/zwirn-core/Zwirn/Core/Lib/Core.hs +3/−0
- src/zwirn-core/Zwirn/Core/Lib/Modulate.hs +2/−0
- src/zwirn-core/Zwirn/Core/Tree.hs +2/−0
- src/zwirn-lang/Zwirn/Language/Builtin/Prelude.hs +4/−4
- src/zwirn-lang/Zwirn/Language/Evaluate/Internal.hs +0/−3
- src/zwirn-lang/Zwirn/Language/Lexer.x +9/−6
- src/zwirn-lang/Zwirn/Language/Parser.y +1/−1
- src/zwirn-lang/Zwirn/Stream/UI.hs +3/−12
- zwirn.cabal +2/−2
README.md view
@@ -12,13 +12,8 @@ ## Installing zwirn -tba--## Limitations--due to the representation of signals and the way they are queried, there can only be a limited amount of triggers per cycle, if this number is exceeded zwirn fails to find any triggers. Currently the threshold seems to be at 500 triggers per cycle:+See in the [the wiki](https://codeberg.org/uzu/zwirn/wiki/Installation). -while ``` fast 499 $ s "bd" ``` works as expected, ``` fast 500 $ s "bd" ``` is silent. if you would like to increase the amount of trigger per *second* (not cycle!), increase the cycles per second, for example by running ``` :cps 1 ```. ## Documentation
app/zwirnzi/CI/Config.hs view
@@ -1,5 +1,4 @@ {-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE MultilineStrings #-} {-# LANGUAGE OverloadedStrings #-} {-# OPTIONS_GHC -Wno-orphans #-} @@ -159,32 +158,31 @@ defaultConfigFile :: BL.ByteString defaultConfigFile =- BL.fromString- """- ci:- listener: true- bootpath: ""- overwritebuiltin: false- dynamictypes: false- stream:- targets:- - name: "superdirt"- oscpath: "/dirt/play"- busoscpath: "/c_set"- address: "127.0.0.1"- port: 57120- busport: 57110- defaulttarget: "superdirt"- localport: 52323- precision: 0.005- clock:- quantum: 4- beatspercycle: 4- frametimespan: 0.05- enablelink: false- skipticks: 10- processahead: 0.3- """+ BL.fromString "ci:"+ <|> " listener: true"+ <|> " bootpath: \"\""+ <|> " overwritebuiltin: false"+ <|> " dynamictypes: false"+ <|> "stream:"+ <|> " targets:"+ <|> " - name: \"superdirt\""+ <|> " oscpath: \"/dirt/play\""+ <|> " busoscpath: \"/c_set\""+ <|> " address: \"127.0.0.1\""+ <|> " port: 57120"+ <|> " busport: 57110"+ <|> " defaulttarget: \"superdirt\""+ <|> " localport: 52323"+ <|> " precision: 0.005"+ <|> " clock:"+ <|> " quantum: 4"+ <|> " beatspercycle: 4"+ <|> " frametimespan: 0.05"+ <|> " enablelink: false"+ <|> " skipticks: 10"+ <|> " processahead: 0.3"+ where+ (<|>) x y = x <> "\n" <> y getFile :: String -> IO String getFile p = do
src/zwirn-core/Zwirn/Core/Lib/Cord.hs view
@@ -26,6 +26,7 @@ import Control.Monad (join) import Data.Bifunctor (first)+import Data.Foldable (Foldable (..), foldl') import Zwirn.Core.Cord as C import Zwirn.Core.Core import Zwirn.Core.Lib.Conditional (iff)@@ -36,6 +37,7 @@ import Zwirn.Core.Tree import qualified Zwirn.Core.Tree as Tree import Zwirn.Core.Types+import Prelude hiding (Foldable (..)) -- | get the current depth of the cord depth :: Cord st i a -> Cord st i Int
src/zwirn-core/Zwirn/Core/Lib/Core.hs view
@@ -37,6 +37,9 @@ trig :: (Functor k) => ZwirnT k st i a -> ZwirnT k st i Bool trig = withValue (\(Value _ t i) -> Value (breakpointCondition 0.005 t) t i) +setInnerTime :: (Applicative k) => ZwirnT k st i Double -> ZwirnT k st i a -> ZwirnT k st i a+setInnerTime = withInner2 (liftA2 (\(vt, _) (va, st) -> (va {time = Time (realToFrac $ value vt) 1}, st)))+ getInnerTime :: (Functor k) => ZwirnT k st i a -> ZwirnT k st i Double getInnerTime = withValue (\v -> v {value = realToFrac $ tTime $ time v})
src/zwirn-core/Zwirn/Core/Lib/Modulate.hs view
@@ -22,11 +22,13 @@ -} import Data.Fixed (mod')+import Data.Foldable (Foldable (..), foldl') import Zwirn.Core.Core import Zwirn.Core.Lib.Core import Zwirn.Core.Time import Zwirn.Core.Tree import Zwirn.Core.Types+import Prelude hiding (Foldable (..)) rev :: ZwirnT k st i a -> ZwirnT k st i a rev = modulateTime (\_ t _ -> -t) ()
src/zwirn-core/Zwirn/Core/Tree.hs view
@@ -26,7 +26,9 @@ -} import Data.Fixed (mod')+import Data.Foldable (foldl, foldl', length) import Zwirn.Core.Types+import Prelude hiding (Foldable (..)) nth :: (RealFrac r) => r -> [a] -> a nth = wrapAt
src/zwirn-lang/Zwirn/Language/Builtin/Prelude.hs view
@@ -132,6 +132,10 @@ === toExp (getInnerTime :: Zwirn Expression -> Zwirn Double) <:: "a -> Number" --| "get the inner time of a zwirn",+ "setinner"+ === toExp (setInnerTime :: Zwirn Double -> Zwirn Expression -> Zwirn Expression)+ <:: "Number -> a -> a"+ --| "set the inner time of a zwirn", "diff" === toExp (getSpeed :: Zwirn Expression -> Zwirn Double) <:: "a -> Number"@@ -945,10 +949,6 @@ === toExp noneID <:: "Text" --| "special identifier to remove effects from all channels",- "tempo"- === toExp tempo- <:: "Number"- --| "current tempo in bpm", "bpc" === toExp bpc <:: "Number"
src/zwirn-lang/Zwirn/Language/Evaluate/Internal.hs view
@@ -163,9 +163,6 @@ where targs = innerJoin $ foldl (liftA2 (\m t -> Map.insert t (EText t) m)) (pure Map.empty :: Zwirn ExpressionMap) <$> collect tz -tempo :: Zwirn Expression-tempo = getStateN (pure "tempo")- bpc :: Zwirn Expression bpc = getStateN (pure "_beatsPerCycle")
src/zwirn-lang/Zwirn/Language/Lexer.x view
@@ -54,10 +54,13 @@ $alpha = [a-zA-Z] @id = ($alphasmall) ($alpha | $digit | \_ )*-@singles = ("&" | "$" | "?" | "#" | "." | "^" | ":")-@otherops = ("|" | "=" | "~" | "<" | ">" | "%" | "!")-@specialop = ("*" | "/" | "'" | "+" | "-")-@op = ((@singles (@singles | @otherops | @specialop)*) | ((@otherops | @specialop) (@singles | @otherops | @specialop)+))+@single = ("&" | "$" | "?" | "#" | "." | "^" | ":")+@reserved = ("|" | "=" | "~" | "%" | "!")+@special = ("*" | "/" | "'" | "+" | "-")+@op = ((@single (@single | @reserved | @special)*)+ |((@reserved | "<" | @special) (@single | @reserved | @special)+)+ |((@reserved | ">" | @special) (@single | @reserved | ">") (@single | @reserved | ">" | @special)+)+ ) @num = ("-")? ($digit)+ ("." ($digit)+)? @path = $white ($alpha | "/" | ".")+ @flag = $alphabig $alpha*@@ -88,7 +91,7 @@ <ty> [A-Z] $alphasmall+ { tokText TypeClassTok } <ty> @id { tokText IdentifierTok } <ty> @op { tokText OperatorTok }-<ty> @specialop { tokText SpecialOperatorTok }+<ty> @special { tokText SpecialOperatorTok } -- Single Line Comments <0> "--" .* (\n?) ;@@ -164,7 +167,7 @@ -- Operators <0> @op { tokText OperatorTok }-<0> @specialop { tokText SpecialOperatorTok }+<0> @special { tokText SpecialOperatorTok } -- Alternations <0> "<" { tok LAngleTok }
src/zwirn-lang/Zwirn/Language/Parser.y view
@@ -181,7 +181,7 @@ | infix infix '..' infix { Located ($1 <-> $4) $ (TEnumThen Run) $1 $2 $4 } sequence :: { LocTerm }- : '[' seq ']' { $2 }+ : '[' seq ']' { mapLoc (const ($1 <-> $3)) $2 } | '[' ']' { Located ($1 <-> $2) TRest } choice :: { LocTerm }
src/zwirn-lang/Zwirn/Stream/UI.hs view
@@ -119,21 +119,12 @@ streamSetCPS :: Stream -> Time -> IO () streamSetCPS str c = streamSetBPM str (c * toRational (cBeatsPerCycle (streamConfigClock $ sConfig str) * 60)) --- | set the bpm in the clock and update the tempo variable+-- | set the bpm in the clock streamSetBPM :: Stream -> Time -> IO ()-streamSetBPM s t = streamSet s "tempo" (EZwirn $ pure $ ENum $ realToFrac t) >> Clock.setBPM (sClockRef s) t+streamSetBPM s = Clock.setBPM (sClockRef s) --- | read the tempo variable streamGetBPM :: Stream -> IO Double-streamGetBPM str = do- st <- readMVar (sState str)- (EZwirn zt) <- streamGet str "tempo"- let vs = toList $ unzwirn zt 0 st- case vs of- [] -> return streamDefaultBPM- (v : _) -> case value $ fst v of- ENum x -> return x- _ -> return streamDefaultBPM+streamGetBPM str = realToFrac <$> Clock.getBPM (sClockRef str) streamResetCycles :: Stream -> IO () streamResetCycles s = streamSetCycle s 0
zwirn.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: zwirn-version: 0.2.2.0+version: 0.2.2.1 synopsis: a live coding language for playing with nested functions of time description: zwirn is a live coding language for playing with nested functions of time, which trigger the sending of osc-messages. it's syntax is inspired by TidalCycles'@@ -13,7 +13,7 @@ category: Language, Sound build-type: Simple extra-doc-files: README.md-tested-with: GHC == 9.12.1, GHC == 9.8.2, GHC == 8.10.7+tested-with: GHC == 9.12.2, GHC == 9.6.7 source-repository head type: git