Skip to content

Commit

Permalink
splay and pan added to parsing (not yet implemented in audio or WebGL)
Browse files Browse the repository at this point in the history
  • Loading branch information
dktr0 committed Nov 28, 2024
1 parent 7460334 commit a06948d
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 166 deletions.
320 changes: 161 additions & 159 deletions punctual.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/Parser.purs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ parseReserved p "mesh" = lift $ signalSignalSignal p $ Mesh Combinatorial
parseReserved p "meshp" = lift $ signalSignalSignal p $ Mesh Pairwise
parseReserved p "spr" = lift $ signalSignalSignal p $ Spr Combinatorial
parseReserved p "sprp" = lift $ signalSignalSignal p $ Spr Pairwise
parseReserved p "pan" = pure $ abc p $ Pan Combinatorial
parseReserved p "panp" = pure $ abc p $ Pan Pairwise
parseReserved p "splay" = pure $ abc p $ Splay
parseReserved p "seq" = pure $ signalSignal p Seq
parseReserved p "fit" = lift $ signalSignalSignal p fit
parseReserved p "iline" = lift $ signalSignalSignalSignal p $ ILine Combinatorial
Expand Down
19 changes: 14 additions & 5 deletions src/Signal.purs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ data Signal =
ILines MultiMode Signal Signal |
Mesh MultiMode Signal Signal |
Spr MultiMode Signal Signal |
Pan MultiMode Signal Signal |
Splay Int Signal |
Seq Signal |
Mix MultiMode Signal Signal Signal |
ILine MultiMode Signal Signal Signal |
Expand Down Expand Up @@ -281,6 +283,8 @@ showIndented i (Lines mm x y) = indent i <> "Lines " <> show mm <> "\n" <> showI
showIndented i (ILines mm x y) = indent i <> "ILines " <> show mm <> "\n" <> showIndented (i+1) x <> showIndented (i+1) y
showIndented i (Mesh mm x y) = indent i <> "Mesh " <> show mm <> "\n" <> showIndented (i+1) x <> showIndented (i+1) y
showIndented i (Spr mm x y) = indent i <> "Spr " <> show mm <> "\n" <> showIndented (i+1) x <> showIndented (i+1) y
showIndented i (Pan mm x y) = indent i <> "Pan " <> show mm <> "\n" <> showIndented (i+1) x <> showIndented (i+1) y
showIndented i (Splay n x) = indent i <> "Splay " <> show n <> "\n" <> showIndented (i+1) x
showIndented i (Seq x) = indent i <> "Seq\n" <> showIndented (i+1) x
showIndented i (Mix mm x y z) = indent i <> "Mix " <> show mm <> "\n" <> showIndented (i+1) x <> showIndented (i+1) y <> showIndented (i+1) z
showIndented i (ILine mm x y z) = indent i <> "ILine " <> show mm <> "\n" <> showIndented (i+1) x <> showIndented (i+1) y <> showIndented (i+1) z
Expand Down Expand Up @@ -544,7 +548,9 @@ subSignals (Lines _ x y) = x:y:Nil
subSignals (ILines _ x y) = x:y:Nil
subSignals (Mesh _ x y) = x:y:Nil
subSignals (Spr _ x y) = x:y:Nil
subSignals (Seq steps) = steps:Nil
subSignals (Pan _ x y) = x:y:Nil
subSignals (Splay _ x) = x:Nil
subSignals (Seq x) = x:Nil
subSignals (ILine _ x y z) = x:y:z:Nil
subSignals (Line _ x y z) = x:y:z:Nil
subSignals (LinLin _ x y z) = x:y:z:Nil
Expand Down Expand Up @@ -678,6 +684,8 @@ dimensions (Lines mm x y) = binaryFunctionDimensions mm (nPer 1 4 $ channels x)
dimensions (ILines mm x y) = binaryFunctionDimensions mm (nPer 1 4 $ channels x) (channels y)
dimensions (Mesh mm xy w) = binaryFunctionDimensions mm (meshChannels $ channels xy) (channels w)
dimensions (Spr mm x y) = binaryFunctionDimensions mm (channels y) (dimensions x).rows
dimensions (Pan mm x y) = { columns: 2, rows: binaryFunctionChannels mm (channels x) (channels y) }
dimensions (Splay n _) = { rows: 1, columns: max 1 n }
dimensions (Seq x) = { rows: 1, columns: (dimensions x).rows }
dimensions (Mix mm x y z) = binaryFunctionDimensions mm (max (channels x) (channels y)) (channels z)
dimensions (ILine mm xy1 xy2 w) = binaryFunctionDimensions mm (binaryFunctionChannels mm (nPer 1 2 $ channels xy1) (nPer 1 2 $ channels xy2)) (channels w)
Expand Down Expand Up @@ -708,10 +716,11 @@ meshChannels x
nPer :: Int -> Int -> Int -> Int
nPer n per x = (((x - 1)/per)+1)*n

binaryFunctionDimensions :: MultiMode -> Int -> Int -> { rows :: Int, columns :: Int }
binaryFunctionDimensions Combinatorial x 1 = { rows: 1, columns: x }
binaryFunctionDimensions Combinatorial x y = { rows: x, columns: y }
binaryFunctionDimensions Pairwise x y = { rows: 1, columns: max x y }
-- TODO: probably the order of arguments should be columns then rows here, not the other way around...
binaryFunctionDimensions :: MultiMode -> Int -> Int -> { columns :: Int, rows :: Int }
binaryFunctionDimensions Combinatorial rs 1 = { columns: rs, rows: 1 }
binaryFunctionDimensions Combinatorial rs cs = { columns: cs, rows: rs }
binaryFunctionDimensions Pairwise x y = { columns: max x y, rows: 1 }

binaryFunctionChannels :: MultiMode -> Int -> Int -> Int
binaryFunctionChannels Combinatorial x y = x * y
Expand Down
3 changes: 2 additions & 1 deletion src/TokenParser.purs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ functionsWithArgumentsDef = [
"img","vid",
"mix","mixp",
"import",
"aout"
"aout",
"splay","pan","panp"
]

otherReservedNamesDef :: Array String
Expand Down
2 changes: 1 addition & 1 deletion src/WebGLCanvas.purs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module WebGLCanvas where

import Prelude (Unit, bind, discard, pure, unit, (<$>), (<>), show, (/=),(||),(==))
import Prelude (Unit, bind, discard, pure, unit, (/=), (<$>), (||))
import Effect
import Effect.Console (log)
import Effect.Ref (Ref,new,read,write)
Expand Down

0 comments on commit a06948d

Please sign in to comment.