From ef01430a9f4881d63438ee0ed72f26876f0d089c Mon Sep 17 00:00:00 2001 From: Ben Gold Date: Fri, 15 Sep 2017 08:56:26 -0500 Subject: [PATCH 01/38] Add two Bjorklund functions Adds `einv` which fills the "blanks" left by `e`: `e 3 8 "x"` -> `"x ~ ~ x ~ ~ x ~"` `einv 3 8 "x"` -> `"~ x x ~ x x ~ x"` And `efull n k pa pb` which takes two patterns, and stacks `e n k` on the first with `einv n k` on the second. `efull 3 8 "2" "1"` -> `"2 1 1 2 1 1 2 1"` --- Sound/Tidal/Pattern.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sound/Tidal/Pattern.hs b/Sound/Tidal/Pattern.hs index 125fbc4b7..98e79fc46 100644 --- a/Sound/Tidal/Pattern.hs +++ b/Sound/Tidal/Pattern.hs @@ -1129,6 +1129,11 @@ e n k p = (flip const) <$> (filterValues (== True) $ listToPat $ bjorklund (n,k) e' :: Int -> Int -> Pattern a -> Pattern a e' n k p = fastcat $ map (\x -> if x then p else silence) (bjorklund (n,k)) +einv :: Int -> Int -> Pattern a -> Pattern a +einv n k p = (flip const) <$> (filterValues (== False) $ listToPat $ bjorklund (n,k)) <*> p + +efull :: Int -> Int -> Pattern a -> Pattern a -> Pattern a +efull n k pa pb = stack [ e n k pa, einv n k pb ] index :: Real b => b -> Pattern b -> Pattern c -> Pattern c index sz indexpat pat = spread' (zoom' $ toRational sz) (toRational . (*(1-sz)) <$> indexpat) pat From 3c1446b331deeb63afcc290cc69af24295c22f2c Mon Sep 17 00:00:00 2001 From: Ben Gold Date: Mon, 9 Oct 2017 17:37:17 -0500 Subject: [PATCH 02/38] added source docs --- Sound/Tidal/Pattern.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sound/Tidal/Pattern.hs b/Sound/Tidal/Pattern.hs index 98e79fc46..4644572cc 100644 --- a/Sound/Tidal/Pattern.hs +++ b/Sound/Tidal/Pattern.hs @@ -1129,9 +1129,16 @@ e n k p = (flip const) <$> (filterValues (== True) $ listToPat $ bjorklund (n,k) e' :: Int -> Int -> Pattern a -> Pattern a e' n k p = fastcat $ map (\x -> if x then p else silence) (bjorklund (n,k)) +{- | `einv` fills in the blanks left by `e` + - + @e 3 8 "x"@ -> @"x ~ ~ x ~ ~ x ~"@ + + @einv 3 8 "x"@ -> @"~ x x ~ x x ~ x"@ +-} einv :: Int -> Int -> Pattern a -> Pattern a einv n k p = (flip const) <$> (filterValues (== False) $ listToPat $ bjorklund (n,k)) <*> p +{- | `efull n k pa pb` stacks @e n k pa@ with @einv n k pb@ -} efull :: Int -> Int -> Pattern a -> Pattern a -> Pattern a efull n k pa pb = stack [ e n k pa, einv n k pb ] From 44f06069caa527553fb4deaa944ff1b4f19a4391 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 4 Jan 2018 15:40:33 +0000 Subject: [PATCH 03/38] fix up linux install script --- doc/install-linux.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/doc/install-linux.sh b/doc/install-linux.sh index 82efa6c41..b2eb631eb 100755 --- a/doc/install-linux.sh +++ b/doc/install-linux.sh @@ -1,19 +1,25 @@ #!/bin/bash -echo -e "\n[ Welcome to the TidalCycles linux install script. This is known to\n work on Ubuntu 17.04. It will probably only work with\n linux distributions that have supercollider 1.3.7 or later. ]" +echo -e "\n[ Welcome to the TidalCycles linux install script. It will probably only work with debian based linux distributions such as Ubuntu. ]" echo -e "\n[ Installing dependencies.. ]" -#sudo apt-get update -#sudo apt-get install build-essential git qjackctl cabal-install zlib1g-dev libportmidi-dev libasound2-dev +sudo apt-get update +sudo apt-get -y install build-essential git qjackctl cabal-install zlib1g-dev libportmidi-dev libasound2-dev + +mkdir ~/tidal-tmp echo -e "\n[ Testing supercollider version ]" if (apt-cache policy supercollider|grep Candidate|grep -q 3.6.6); then echo -e "\n[ Old supercollider version found.. Compiling ]" + cd ~/tidal-tmp + git clone https://github.com/lvm/build-supercollider + cd build-supercollider + ./build-supercollider.sh + ./build-sc3-plugins.sh else echo -e "\n[ Installing distro version of supercollider ]" sudo apt-get install supercollider sc3-plugins fi -exit echo -e "\n[ Adding user to the 'audio' group ]" sudo adduser $USER audio @@ -24,7 +30,7 @@ else echo -e "\n[ Installing atom ]" wget --output-document=/tmp/atom.deb http://atom.io/download/deb sudo dpkg -i /tmp/atom.deb - sudo apt --fix-broken install -y + sudo apt-get --fix-broken install -y fi echo -e "\n[ Changing the default ghci path to stack ghci ]" From fd35fa8e7c050a41e758d7128b608bff5450f3a9 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 4 Jan 2018 16:36:13 +0000 Subject: [PATCH 04/38] add stack --- doc/install-linux.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/install-linux.sh b/doc/install-linux.sh index b2eb631eb..2a14f6a1f 100755 --- a/doc/install-linux.sh +++ b/doc/install-linux.sh @@ -4,7 +4,7 @@ echo -e "\n[ Welcome to the TidalCycles linux install script. It will probably o echo -e "\n[ Installing dependencies.. ]" sudo apt-get update -sudo apt-get -y install build-essential git qjackctl cabal-install zlib1g-dev libportmidi-dev libasound2-dev +sudo apt-get -y install build-essential git qjackctl cabal-install zlib1g-dev libportmidi-dev libasound2-dev haskell-stack mkdir ~/tidal-tmp From e1553b3278cc1229c9d0631ce67208b3298ed9cb Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 8 Jan 2018 22:53:06 +0000 Subject: [PATCH 05/38] superdirt midi params --- Sound/Tidal/Params.hs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Sound/Tidal/Params.hs b/Sound/Tidal/Params.hs index 71d48eb41..6bbf1964e 100644 --- a/Sound/Tidal/Params.hs +++ b/Sound/Tidal/Params.hs @@ -359,3 +359,22 @@ drumN "cl" = 75 drumN "ag" = 67 drumN "cr" = 49 drumN _ = 0 + + +-- SuperDirt MIDI Params + +(array, array_p) = pF "array" Nothing +(midichan, midichan_p) = pF "midichan" Nothing +(control, control_p) = pF "control" Nothing +ctl = control +(ctlNum, ctlNum_p) = pF "ctlNum" Nothing +(frameRate, frameRate_p) = pF "frameRate" Nothing +(frames, frames_p) = pF "frames" Nothing +(hours, hours_p) = pF "hours" Nothing +(midicmd, midicmd_p) = pS "midicmd" Nothing +(minutes, minutes_p) = pF "minutes" Nothing +(progNum, progNum_p) = pF "progNum" Nothing +(seconds, seconds_p) = pF "seconds" Nothing +(songPtr, songPtr_p) = pF "songPtr" Nothing +(uid, uid_p) = pF "uid" Nothing +(val, val_p) = pF "val" Nothing From f15a4b57d821cd056ab49ac57b693cbf6c54b05f Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 8 Jan 2018 22:55:07 +0000 Subject: [PATCH 06/38] superdirt midi params --- Sound/Tidal/Pattern.hs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/Sound/Tidal/Pattern.hs b/Sound/Tidal/Pattern.hs index 652559ed1..8a2188e69 100644 --- a/Sound/Tidal/Pattern.hs +++ b/Sound/Tidal/Pattern.hs @@ -1583,21 +1583,8 @@ scramble::Int -> Pattern a -> Pattern a scramble n = fit' 1 n (_run n) (_density (fromIntegral n) $ liftA2 (+) (pure 0) $ irand n) -ur :: Time -> Pattern String -> [Pattern a] -> Pattern a -ur t outer_p ps = _slow t $ unwrap $ adjust <$> (timedValues $ (getPat . split) <$> outer_p) - where split s = wordsBy (==':') s - getPat (n:xs) = (ps' !!! read n, transform xs) - ps' = map (_density t) ps - adjust (a, (p, f)) = f a p - transform (x:_) a = transform' x a - transform _ _ = id - transform' "in" (s,e) p = twiddle (fadeIn) (s,e) p - transform' "out" (s,e) p = twiddle (fadeOut) (s,e) p - transform' _ _ p = p - twiddle f (s,e) p = s `rotR` (f (e-s) p) - -ur' :: Time -> Pattern String -> [(String, Pattern a)] -> [(String, Pattern a -> Pattern a)] -> Pattern a -ur' t outer_p ps fs = _slow t $ unwrap $ adjust <$> (timedValues $ (getPat . split) <$> outer_p) +ur :: Time -> Pattern String -> [(String, Pattern a)] -> [(String, Pattern a -> Pattern a)] -> Pattern a +ur t outer_p ps fs = _slow t $ unwrap $ adjust <$> (timedValues $ (getPat . split) <$> outer_p) where split s = wordsBy (==':') s getPat (s:xs) = (match s, transform xs) match s = fromMaybe silence $ lookup s ps' From b869ecadb49339f32b8dc58742b877f66e83c56f Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 21 Jan 2018 12:13:26 +0000 Subject: [PATCH 07/38] flesh out --- HACKING.md | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/HACKING.md b/HACKING.md index f487a881b..eb12348c4 100644 --- a/HACKING.md +++ b/HACKING.md @@ -5,18 +5,27 @@ getting started, join the tidal-innards channel on the TOPLAP slack: http://toplap.org/toplap-on-slack/ You can also ask on the mailing list: - http://lurk.org/groups/tidal/ + https://we.lurk.org/postorius/lists/tidal.we.lurk.org/ + +# Tidal + +Tidal is written in the Haskell language, in particular using the ghc +compiler/interpreter. Some resources for learning Haskell: + +* http://learnyouahaskell.com/ +* http://haskellbook.com/ # Quick guide to contributing a change to Tidal The main repository is maintained on github: - https://github.com/tidalcycles/tidalcycles.github.io + https://github.com/tidalcycles/tidal The SuperDirt repository is here: https://github.com/musikinformatik/SuperDirt -We'd like to add some instructions for how to interact with these but -no one has done it yet. For now some bullet points as a placeholder: +In both bases the 'master' branch contains the current release. Active +development takes place on a branch called VERSION-NUMBER-dev (at the +time of writing, 1.0-dev). To make a contribution, you could: * Make a dev fork * Make and test a change @@ -25,8 +34,9 @@ no one has done it yet. For now some bullet points as a placeholder: # A process for making a release -Likewise, we'd like to describe how to.. +We haven't documented a clear process for this, but we'd like to +describe how to.. * Share with others for testing -* Tagging release -* Uploading to hackage +* Tag a release +* Distribute via to hackage / stackage From 79483ba81d75f2211ce4af9ed54f68831a8d98d4 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 21 Jan 2018 12:18:32 +0000 Subject: [PATCH 08/38] a little bit on workflow --- HACKING.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/HACKING.md b/HACKING.md index eb12348c4..ac162df02 100644 --- a/HACKING.md +++ b/HACKING.md @@ -32,6 +32,24 @@ time of writing, 1.0-dev). To make a contribution, you could: * Keep your fork up to date with the master * Make a pull request +# Workflow + +You can accomplish a lot within a normal tidal buffer in e.g. atom, +emacs or vim, by defining and testing functions using `let`. + +For making a change to Tidal itself, take a fork of the code and +switch to the active branch: + +``` +git clone https://github.com/tidalcycles/Tidal.git +cd Tidal +git checkout 1.0-dev +``` + +Then make a change and install it by running a bare `cabal install` +from within the Tidal folder. You'll need to restart the interpreter +within your editor to pick up the new version. + # A process for making a release We haven't documented a clear process for this, but we'd like to From c657d34ada3722ad4de8ff6981e13c2e3b74eacd Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 21 Jan 2018 12:21:33 +0000 Subject: [PATCH 09/38] a little bit on workflow --- HACKING.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/HACKING.md b/HACKING.md index ac162df02..cd64a1ece 100644 --- a/HACKING.md +++ b/HACKING.md @@ -23,7 +23,7 @@ The main repository is maintained on github: The SuperDirt repository is here: https://github.com/musikinformatik/SuperDirt -In both bases the 'master' branch contains the current release. Active +In both cases the 'master' branch contains the current release. Active development takes place on a branch called VERSION-NUMBER-dev (at the time of writing, 1.0-dev). To make a contribution, you could: @@ -32,6 +32,10 @@ time of writing, 1.0-dev). To make a contribution, you could: * Keep your fork up to date with the master * Make a pull request +Others may then review and comment on your pull request. Please do say +when you think it's ready to be accepted to make sure it's being +overlooked. + # Workflow You can accomplish a lot within a normal tidal buffer in e.g. atom, From 2b2072a29dc5a5b23bed8f6931db6cafe0051621 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 21 Jan 2018 12:22:15 +0000 Subject: [PATCH 10/38] oops --- HACKING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HACKING.md b/HACKING.md index cd64a1ece..76a9b80e0 100644 --- a/HACKING.md +++ b/HACKING.md @@ -33,7 +33,7 @@ time of writing, 1.0-dev). To make a contribution, you could: * Make a pull request Others may then review and comment on your pull request. Please do say -when you think it's ready to be accepted to make sure it's being +when you think it's ready to be accepted to make sure it's not being overlooked. # Workflow From 699f80c903e09c8945c9dde2c8cdd74863a361da Mon Sep 17 00:00:00 2001 From: kgwgk Date: Mon, 22 Jan 2018 11:07:09 +0100 Subject: [PATCH 11/38] Use prompt-cont for ghci>=8.2.0 --- tidal.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tidal.el b/tidal.el index 37894e4f4..5561993c9 100644 --- a/tidal.el +++ b/tidal.el @@ -49,6 +49,10 @@ "ghci" "*The haskell interpeter to use (default=ghci).") +(defvar tidal-interpreter-version + (substring (shell-command-to-string (concatenate 'string tidal-interpreter " --numeric-version")) 0 -1) + "*The version of tidal interpreter as a string.") + (defvar tidal-interpreter-arguments (list "-XOverloadedStrings" ) @@ -85,7 +89,9 @@ tidal-interpreter-arguments) (tidal-see-output)) (tidal-send-string ":set prompt \"\"") - (tidal-send-string ":set prompt2 \"\"") + (if (string< tidal-interpreter-version "8.2.0") + (tidal-send-string ":set prompt2 \"\"") + (tidal-send-string ":set prompt-cont \"\"")) (tidal-send-string ":module Sound.Tidal.Context") (tidal-send-string "import qualified Sound.Tidal.Scales as Scales") (tidal-send-string "import qualified Sound.Tidal.Chords as Chords") From 39238bd442b33951dec34f9b9c56316499849916 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 28 Jan 2018 16:54:49 +0000 Subject: [PATCH 12/38] allow * and / speeds to be patterns in the parser --- Sound/Tidal/Parse.hs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Sound/Tidal/Parse.hs b/Sound/Tidal/Parse.hs index 5ae930b96..60a9902b1 100644 --- a/Sound/Tidal/Parse.hs +++ b/Sound/Tidal/Parse.hs @@ -23,8 +23,8 @@ import Sound.Tidal.Time (Arc, Time) -- | AST representation of patterns data TPat a = TPat_Atom a - | TPat_Density Time (TPat a) - | TPat_Slow Time (TPat a) + | TPat_Density (TPat Time) (TPat a) + | TPat_Slow (TPat Time) (TPat a) | TPat_Zoom Arc (TPat a) | TPat_DegradeBy Double (TPat a) | TPat_Silence @@ -46,8 +46,8 @@ instance Parseable a => Monoid (TPat a) where toPat :: Parseable a => TPat a -> Pattern a toPat = \case TPat_Atom x -> atom x - TPat_Density t x -> _density t $ toPat x - TPat_Slow t x -> _slow t $ toPat x + TPat_Density t x -> density (toPat t) $ toPat x + TPat_Slow t x -> slow (toPat t) $ toPat x TPat_Zoom arc x -> zoom arc $ toPat x TPat_DegradeBy amt x -> _degradeBy amt $ toPat x TPat_Silence -> silence @@ -253,7 +253,7 @@ pPolyOut f = do ps <- braces (pSequenceN f `sepBy` symbol ",") spaces pMult $ mconcat $ scale (Just 1) ps where scale _ [] = [] - scale base (ps@((n,_):_)) = map (\(n',p) -> TPat_Density (fromIntegral (fromMaybe n base)/ fromIntegral n') p) ps + scale base (ps@((n,_):_)) = map (\(n',p) -> TPat_Density (TPat_Atom $ fromIntegral (fromMaybe n base)/ fromIntegral n') p) ps pString :: Parser (String) pString = do c <- (letter <|> oneOf "0123456789") "charnum" @@ -322,12 +322,12 @@ pColour = do name <- many1 letter "colour name" pMult :: Parseable a => TPat a -> Parser (TPat a) pMult thing = do char '*' spaces - r <- pRatio + r <- (pRational <|> pPolyIn pRational <|> pPolyOut pRational) return $ TPat_Density r thing <|> do char '/' spaces - r <- pRatio + r <- (pRational <|> pPolyIn pRational <|> pPolyOut pRational) return $ TPat_Slow r thing <|> return thing From 739bf8f75cb902bbf467a89ce80a23dea144109c Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 28 Jan 2018 16:56:22 +0000 Subject: [PATCH 13/38] add distrib function, for meta-bjorklund stuff --- Sound/Tidal/Pattern.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sound/Tidal/Pattern.hs b/Sound/Tidal/Pattern.hs index 8a2188e69..c8a132f68 100644 --- a/Sound/Tidal/Pattern.hs +++ b/Sound/Tidal/Pattern.hs @@ -1148,6 +1148,16 @@ e n k p = (flip const) <$> (filterValues (== True) $ listToPat $ bjorklund (n,k) e' :: Int -> Int -> Pattern a -> Pattern a e' n k p = fastcat $ map (\x -> if x then p else silence) (bjorklund (n,k)) +distrib :: [Int] -> Pattern a -> Pattern a +distrib xs p = boolsToPat (foldr (distrib') (replicate (head $ reverse xs) True) (reverse $ layers xs)) p + where + distrib' :: [Bool] -> [Bool] -> [Bool] + distrib' [] _ = [] + distrib' (_:a) [] = False:(distrib' a []) + distrib' (True:a) (x:b) = x:(distrib' a b) + distrib' (False:a) (b) = False:(distrib' a b) + layers = map bjorklund . (zip<*>tail) + boolsToPat p p' = (flip const) <$> (filterValues (== True) $ listToPat $ p) <*> p' index :: Real b => b -> Pattern b -> Pattern c -> Pattern c index sz indexpat pat = spread' (zoom' $ toRational sz) (toRational . (*(1-sz)) <$> indexpat) pat From 83cda79c1b7b77de69f112db2935f970f4678a99 Mon Sep 17 00:00:00 2001 From: Ben Gold Date: Fri, 2 Feb 2018 09:59:33 -0600 Subject: [PATCH 14/38] generalize `toScale` so it works with `up` `toScale` should now be able to produce Patterns of any numeric type, not just Pattern Int --- Sound/Tidal/Pattern.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sound/Tidal/Pattern.hs b/Sound/Tidal/Pattern.hs index 652559ed1..a9e9ae183 100644 --- a/Sound/Tidal/Pattern.hs +++ b/Sound/Tidal/Pattern.hs @@ -1535,12 +1535,12 @@ into the pattern `"0 4 7 12"`. It assumes your scale fits within an octave; to change this use `toScale' size`. Example: `toScale' 24 [0,4,7,10,14,17] (run 8)` turns into `"0 4 7 10 14 17 24 28"` -} -toScale' :: Int -> [Int] -> Pattern Int -> Pattern Int +toScale' :: Num a => Int -> [a] -> Pattern Int -> Pattern a toScale' o s = fmap noteInScale where octave x = x `div` length s - noteInScale x = (s !!! x) + o * octave x + noteInScale x = (s !!! x) + (fromIntegral $ o * octave x) -toScale :: [Int] -> Pattern Int -> Pattern Int +toScale :: Num a => [a] -> Pattern Int -> Pattern a toScale = toScale' 12 {- | `swingBy x n` divides a cycle into `n` slices and delays the notes in From 6605c33001064c52e1454bccd9b8ec79dc8b0140 Mon Sep 17 00:00:00 2001 From: Ben Gold Date: Fri, 2 Feb 2018 15:20:45 -0600 Subject: [PATCH 15/38] removing older GHC versions Removing Travis CI testing for GHC versions that will fail to build for reasons beyond our control --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3b01d6cee..a7ecbbaf1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,12 +13,6 @@ before_cache: matrix: include: - - env: CABALVER=1.18 GHCVER=7.6.3 - compiler: ": #GHC 7.6.3" - addons: {apt: {packages: [cabal-install-1.18,ghc-7.6.3], sources: [hvr-ghc]}} - - env: CABALVER=1.18 GHCVER=7.8.4 - compiler: ": #GHC 7.8.4" - addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources: [hvr-ghc]}} - env: CABALVER=1.22 GHCVER=7.10.3 compiler: ": #GHC 7.10.3" addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3], sources: [hvr-ghc]}} From ea4cba968709690e46abda7061b1ae2d80a2baae Mon Sep 17 00:00:00 2001 From: Ben Gold Date: Fri, 2 Feb 2018 15:21:28 -0600 Subject: [PATCH 16/38] No longer test against GHC < 7.10.3 --- tidal.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tidal.cabal b/tidal.cabal index 8c65518f8..a18c40e63 100644 --- a/tidal.cabal +++ b/tidal.cabal @@ -12,7 +12,7 @@ Copyright: (c) Tidal contributors, 2017 category: Sound build-type: Simple cabal-version: >=1.10 -tested-with: GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.1 +tested-with: GHC == 7.10.3, GHC == 8.0.1 Extra-source-files: README.md CHANGELOG.md tidal.el doc/tidal.md From 0da1841e7da2deb151b128d4207425a1408275f8 Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 3 Feb 2018 08:12:28 +0100 Subject: [PATCH 17/38] change `n` as a float, update parser to support parsing floats as note names --- Sound/Tidal/Params.hs | 8 ++++---- Sound/Tidal/Parse.hs | 15 +++++++-------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Sound/Tidal/Params.hs b/Sound/Tidal/Params.hs index 6bbf1964e..3e4e8d682 100644 --- a/Sound/Tidal/Params.hs +++ b/Sound/Tidal/Params.hs @@ -174,8 +174,8 @@ Using `cut "0"` is effectively _no_ cutgroup. (loop, loop_p) = pF "loop" (Just 1) (lophat, lophat_p) = pF "lophat" (Just 0) (lsnare, lsnare_p) = pF "lsnare" (Just 0) --- | specifies the sample variation to be used -(n, n_p) = pI "n" (Just 0) +-- | specifies the sample or note number to be used +(n, n_p) = pF "n" (Just 0) {- | Pushes things forward (or backwards within built-in latency) in time. Allows for nice things like _swing_ feeling: @@ -340,14 +340,14 @@ vcf = vcfegint vco = vcoegint voi = voice -note, midinote :: Pattern Int -> ParamPattern +note, midinote :: Pattern Double -> ParamPattern note = n midinote = n . ((subtract 60) <$>) drum :: Pattern String -> ParamPattern drum = midinote . (drumN <$>) -drumN :: String -> Int +drumN :: Num a => String -> a drumN "bd" = 36 drumN "sn" = 38 drumN "lt" = 43 diff --git a/Sound/Tidal/Parse.hs b/Sound/Tidal/Parse.hs index 60a9902b1..8ac99d4fa 100644 --- a/Sound/Tidal/Parse.hs +++ b/Sound/Tidal/Parse.hs @@ -158,12 +158,12 @@ sign = do char '-' return Positive <|> return Positive -intOrFloat :: Parser (Either Integer Double) +intOrFloat :: Parser Double intOrFloat = do s <- sign num <- naturalOrFloat return (case num of - Right x -> Right (applySign s x) - Left x -> Left (applySign s x) + Right x -> applySign s x + Left x -> fromIntegral $ applySign s x ) r :: Parseable a => String -> Pattern a -> IO (Pattern a) @@ -265,8 +265,7 @@ pVocable = do v <- pString return $ TPat_Atom v pDouble :: Parser (TPat Double) -pDouble = do nf <- intOrFloat "float" - let f = either fromIntegral id nf +pDouble = do f <- choice [intOrFloat, parseNote] "float" return $ TPat_Atom f pBool :: Parser (TPat Bool) @@ -276,7 +275,7 @@ pBool = do oneOf "t1" do oneOf "f0" return $ TPat_Atom False -parseIntNote :: Integral i => Parser i +parseIntNote :: Integral i => Parser i parseIntNote = do s <- sign i <- choice [integer, parseNote] return $ applySign s $ fromIntegral i @@ -289,7 +288,7 @@ parseInt = do s <- sign pIntegral :: Parseable a => Integral a => Parser (TPat a) pIntegral = TPat_Atom <$> parseIntNote -parseNote :: Integral a => Parser a +parseNote :: Num a => Parser a parseNote = do n <- notenum modifiers <- many noteModifier octave <- option 5 natural @@ -311,7 +310,7 @@ parseNote = do n <- notenum char 'n' >> return 0 ] -fromNote :: Integral c => Pattern String -> Pattern c +fromNote :: Num a => Pattern String -> Pattern a fromNote p = (\s -> either (const 0) id $ parse parseNote "" s) <$> p pColour :: Parser (TPat ColourD) From 03b43fdc640e53cdc22303d29702d4228a16eea9 Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 3 Feb 2018 16:48:37 +0000 Subject: [PATCH 18/38] generalise scaleP from `Int` to `Num` --- Sound/Tidal/Scales.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sound/Tidal/Scales.hs b/Sound/Tidal/Scales.hs index 375a240e5..0c3435a95 100644 --- a/Sound/Tidal/Scales.hs +++ b/Sound/Tidal/Scales.hs @@ -154,7 +154,7 @@ diminished2 = [0,2,3,5,6,8,9,11] chromatic :: Num a => [a] chromatic = [0,1,2,3,4,5,6,7,8,9,10,11] -scaleP :: Pattern String -> Pattern Int -> Pattern Int +scaleP :: Num a => Pattern String -> Pattern a -> Pattern a scaleP sp p = (\n scaleName -> noteInScale (fromMaybe [0] $ lookup scaleName scaleTable) n) <$> p <*> sp where octave s x = x `div` (length s) noteInScale s x = (s !!! x) + (12 * octave s x) From b1be75689de41712f25e8a39b5562c745679a458 Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 3 Feb 2018 19:20:32 +0000 Subject: [PATCH 19/38] make scaleP work again --- Sound/Tidal/Scales.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sound/Tidal/Scales.hs b/Sound/Tidal/Scales.hs index 0c3435a95..8379ab152 100644 --- a/Sound/Tidal/Scales.hs +++ b/Sound/Tidal/Scales.hs @@ -154,10 +154,10 @@ diminished2 = [0,2,3,5,6,8,9,11] chromatic :: Num a => [a] chromatic = [0,1,2,3,4,5,6,7,8,9,10,11] -scaleP :: Num a => Pattern String -> Pattern a -> Pattern a +scaleP :: Num a => Pattern String -> Pattern Int -> Pattern a scaleP sp p = (\n scaleName -> noteInScale (fromMaybe [0] $ lookup scaleName scaleTable) n) <$> p <*> sp - where octave s x = x `div` (length s) - noteInScale s x = (s !!! x) + (12 * octave s x) + where octave s x = x `div` length s + noteInScale s x = (s !!! x) + (fromIntegral $ 12 * octave s x) scaleTable :: Num a => [(String, [a])] scaleTable = [("minPent", minPent), From cf830ff50962ca05a390d2968cd28414ba21e5ad Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 3 Feb 2018 19:21:43 +0000 Subject: [PATCH 20/38] remove compile warn and the redundant discretise' and _discretise functions --- Sound/Tidal/Pattern.hs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Sound/Tidal/Pattern.hs b/Sound/Tidal/Pattern.hs index 4e371ba9f..747d619a0 100644 --- a/Sound/Tidal/Pattern.hs +++ b/Sound/Tidal/Pattern.hs @@ -442,7 +442,7 @@ rev :: Pattern a -> Pattern a rev p = splitQueries $ Pattern $ \a -> map makeWholeAbsolute $ mapSnds' (mirrorArc (mid a)) $ map makeWholeRelative (arc p (mirrorArc (mid a) a)) where makeWholeRelative ((s,e), part@(s',e'), v) = ((s'-s, e-e'), part, v) makeWholeAbsolute ((s,e), part@(s',e'), v) = ((s'-e,e'+s), part, v) - mid (s,e) = (sam s) + 0.5 + mid (s,_) = (sam s) + 0.5 -- | @palindrome p@ applies @rev@ to @p@ every other cycle, so that -- the pattern alternates between forwards and backwards. @@ -1282,9 +1282,6 @@ pequal cycles p1 p2 = (sort $ arc p1 (0, cycles)) == (sort $ arc p2 (0, cycles)) discretise :: Time -> Pattern a -> Pattern a discretise n p = (_density n $ atom (id)) <*> p -discretise' = discretise -_discretise = discretise - -- | @randcat ps@: does a @slowcat@ on the list of patterns @ps@ but -- randomises the order in which they are played. randcat :: [Pattern a] -> Pattern a From 10fdd93edcde370fe0e1994ee2db3d967d6556aa Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 3 Feb 2018 19:22:08 +0000 Subject: [PATCH 21/38] changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 947dd8596..22000333a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,11 @@ # TidalCycles log of changes -## 0.96 +## 0.9.6 ### Enhancements * Added `chord` for chord patterns and `scaleP` for scale patterns +* The `n` pattern parameter is now floating point ## 0.9.5 From 13589c6b6abc45a408cda013a044a997d655324a Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 3 Feb 2018 21:27:08 +0000 Subject: [PATCH 22/38] give discretise temporal param (again?) --- Sound/Tidal/Pattern.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Sound/Tidal/Pattern.hs b/Sound/Tidal/Pattern.hs index 747d619a0..df4fe4c1b 100644 --- a/Sound/Tidal/Pattern.hs +++ b/Sound/Tidal/Pattern.hs @@ -734,7 +734,7 @@ spread' f vpat pat = vpat >>= \v -> f v pat shorter alias `spreadr`. -} spreadChoose :: (t -> t1 -> Pattern b) -> [t] -> t1 -> Pattern b -spreadChoose f vs p = do v <- discretise 1 (choose vs) +spreadChoose f vs p = do v <- _discretise 1 (choose vs) f v p spreadr :: (t -> t1 -> Pattern b) -> [t] -> t1 -> Pattern b @@ -1278,9 +1278,11 @@ pequal cycles p1 p2 = (sort $ arc p1 (0, cycles)) == (sort $ arc p2 (0, cycles)) -- | @discretise n p@: 'samples' the pattern @p@ at a rate of @n@ -- events per cycle. Useful for turning a continuous pattern into a -- discrete one. +discretise :: Pattern Time -> Pattern a -> Pattern a +discretise = temporalParam _discretise -discretise :: Time -> Pattern a -> Pattern a -discretise n p = (_density n $ atom (id)) <*> p +_discretise :: Time -> Pattern a -> Pattern a +_discretise n p = (_density n $ atom (id)) <*> p -- | @randcat ps@: does a @slowcat@ on the list of patterns @ps@ but -- randomises the order in which they are played. From 0f704d24204f87a1b31df42919b6a7609a0bacdb Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 5 Feb 2018 10:06:59 +0000 Subject: [PATCH 23/38] concatenate isnt defined in my (24.5.1) emacs, Im not an elisp person but using `concat` seems to work --- tidal.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tidal.el b/tidal.el index 5561993c9..4837aeecd 100644 --- a/tidal.el +++ b/tidal.el @@ -50,7 +50,7 @@ "*The haskell interpeter to use (default=ghci).") (defvar tidal-interpreter-version - (substring (shell-command-to-string (concatenate 'string tidal-interpreter " --numeric-version")) 0 -1) + (substring (shell-command-to-string (concat tidal-interpreter " --numeric-version")) 0 -1) "*The version of tidal interpreter as a string.") (defvar tidal-interpreter-arguments From 4eba8aff65699477e10ccd2440580772fae3368d Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 5 Feb 2018 11:25:47 +0000 Subject: [PATCH 24/38] avoid splitting events (was causing a test to fail) --- Sound/Tidal/Pattern.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sound/Tidal/Pattern.hs b/Sound/Tidal/Pattern.hs index df4fe4c1b..68f59b87a 100644 --- a/Sound/Tidal/Pattern.hs +++ b/Sound/Tidal/Pattern.hs @@ -1279,7 +1279,7 @@ pequal cycles p1 p2 = (sort $ arc p1 (0, cycles)) == (sort $ arc p2 (0, cycles)) -- events per cycle. Useful for turning a continuous pattern into a -- discrete one. discretise :: Pattern Time -> Pattern a -> Pattern a -discretise = temporalParam _discretise +discretise n p = (density n $ atom (id)) <*> p _discretise :: Time -> Pattern a -> Pattern a _discretise n p = (_density n $ atom (id)) <*> p From 80199d1c91a6c2bf34353052a2923553cc59fd3e Mon Sep 17 00:00:00 2001 From: Johannes Waldmann <@> Date: Tue, 31 Oct 2017 17:06:38 +0100 Subject: [PATCH 25/38] see issue #255 --- Sound/Tidal/Parse.hs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Sound/Tidal/Parse.hs b/Sound/Tidal/Parse.hs index 8ac99d4fa..d049af763 100644 --- a/Sound/Tidal/Parse.hs +++ b/Sound/Tidal/Parse.hs @@ -43,7 +43,7 @@ instance Parseable a => Monoid (TPat a) where mempty = TPat_Silence mappend = TPat_Overlay -toPat :: Parseable a => TPat a -> Pattern a +toPat :: Enumerable a => TPat a -> Pattern a toPat = \case TPat_Atom x -> atom x TPat_Density t x -> density (toPat t) $ toPat x @@ -67,41 +67,49 @@ durations ((TPat_Elongate n):xs) = (n, TPat_Silence):(durations xs) durations (a:(TPat_Elongate n):xs) = (n+1,a):(durations xs) durations (a:xs) = (1,a):(durations xs) -p :: Parseable a => String -> Pattern a +p :: (Enumerable a, Parseable a) => String -> Pattern a p = toPat . parseTPat class Parseable a where parseTPat :: String -> TPat a + +class Enumerable a where fromTo :: a -> a -> Pattern a fromThenTo :: a -> a -> a -> Pattern a instance Parseable Double where parseTPat = parseRhythm pDouble +instance Enumerable Double where fromTo a b = enumFromTo' a b fromThenTo a b c = enumFromThenTo' a b c instance Parseable String where parseTPat = parseRhythm pVocable +instance Enumerable String where fromTo a b = listToPat [a,b] fromThenTo a b c = listToPat [a,b,c] instance Parseable Bool where parseTPat = parseRhythm pBool +instance Enumerable Bool where fromTo a b = listToPat [a,b] fromThenTo a b c = listToPat [a,b,c] instance Parseable Int where parseTPat = parseRhythm pIntegral +instance Enumerable Int where fromTo a b = enumFromTo' a b fromThenTo a b c = enumFromThenTo' a b c instance Parseable Integer where parseTPat s = parseRhythm pIntegral s +instance Enumerable Integer where fromTo a b = enumFromTo' a b fromThenTo a b c = enumFromThenTo' a b c instance Parseable Rational where parseTPat = parseRhythm pRational +instance Enumerable Rational where fromTo a b = enumFromTo' a b fromThenTo a b c = enumFromThenTo' a b c @@ -115,10 +123,11 @@ type ColourD = Colour Double instance Parseable ColourD where parseTPat = parseRhythm pColour +instance Enumerable ColourD where fromTo a b = listToPat [a,b] fromThenTo a b c = listToPat [a,b,c] -instance (Parseable a) => IsString (Pattern a) where +instance (Enumerable a, Parseable a) => IsString (Pattern a) where fromString = toPat . parseTPat --instance (Parseable a, Pattern p) => IsString (p a) where @@ -166,7 +175,7 @@ intOrFloat = do s <- sign Left x -> fromIntegral $ applySign s x ) -r :: Parseable a => String -> Pattern a -> IO (Pattern a) +r :: (Enumerable a, Parseable a) => String -> Pattern a -> IO (Pattern a) r s orig = do E.handle (\err -> do putStrLn (show (err :: E.SomeException)) return orig From 7896d1d1cae84187680ce30e11b86cfe6e3d361f Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 5 Mar 2018 08:02:10 +0000 Subject: [PATCH 26/38] add independent `note` parameter --- CHANGELOG.md | 8 ++++++++ Sound/Tidal/Params.hs | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22000333a..13b125658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # TidalCycles log of changes +## 0.9.7 + +### Enhancements + +* The `note` pattern parameter is no longer an alias for `midinote`, + but an independent parameter for supercollider to handle (in a manner + similar to `up`) + ## 0.9.6 ### Enhancements diff --git a/Sound/Tidal/Params.hs b/Sound/Tidal/Params.hs index 3e4e8d682..b0b0df2d6 100644 --- a/Sound/Tidal/Params.hs +++ b/Sound/Tidal/Params.hs @@ -176,6 +176,7 @@ Using `cut "0"` is effectively _no_ cutgroup. (lsnare, lsnare_p) = pF "lsnare" (Just 0) -- | specifies the sample or note number to be used (n, n_p) = pF "n" (Just 0) +(note, note_p) = pF "note" (Just 0) {- | Pushes things forward (or backwards within built-in latency) in time. Allows for nice things like _swing_ feeling: @@ -340,8 +341,7 @@ vcf = vcfegint vco = vcoegint voi = voice -note, midinote :: Pattern Double -> ParamPattern -note = n +midinote :: Pattern Double -> ParamPattern midinote = n . ((subtract 60) <$>) drum :: Pattern String -> ParamPattern From 5a7fbf833d865d463eed757f0958451e96758f02 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 5 Mar 2018 16:42:04 +0000 Subject: [PATCH 27/38] map `midinote` to `note`, and drum to `n` --- Sound/Tidal/Params.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sound/Tidal/Params.hs b/Sound/Tidal/Params.hs index b0b0df2d6..ac089aabd 100644 --- a/Sound/Tidal/Params.hs +++ b/Sound/Tidal/Params.hs @@ -342,10 +342,10 @@ vco = vcoegint voi = voice midinote :: Pattern Double -> ParamPattern -midinote = n . ((subtract 60) <$>) +midinote = note . ((subtract 60) <$>) drum :: Pattern String -> ParamPattern -drum = midinote . (drumN <$>) +drum = n . ((subtract 60) . drumN <$>) drumN :: Num a => String -> a drumN "bd" = 36 From c9728bdb73bdcc67d387498bddfb679df339b52d Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 29 Mar 2018 21:26:54 +0100 Subject: [PATCH 28/38] add ccn, ccv, grouped into cc. Alias command for midicmd --- Sound/Tidal/Params.hs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Sound/Tidal/Params.hs b/Sound/Tidal/Params.hs index ac089aabd..d5b0609ec 100644 --- a/Sound/Tidal/Params.hs +++ b/Sound/Tidal/Params.hs @@ -66,7 +66,7 @@ pS name defaultV = (make' VS param, param) (attack, attack_p) = pF "attack" (Just (-1)) -- | a pattern of numbers from 0 to 1. Sets the center frequency of the band-pass filter. (bandf, bandf_p) = pF "bandf" (Just 0) --- | a pattern of numbers from 0 to 1. Sets the q-factor of the band-pass filter. +-- | a pattern of numbers from 0 to 1. Sets the q-factor of the band-pass filter.y (bandq, bandq_p) = pF "bandq" (Just 0) {- | a pattern of numbers from 0 to 1. Skips the beginning of each sample, e.g. `0.25` to cut off the first quarter from each sample. @@ -366,12 +366,20 @@ drumN _ = 0 (array, array_p) = pF "array" Nothing (midichan, midichan_p) = pF "midichan" Nothing (control, control_p) = pF "control" Nothing -ctl = control + +(ccn, ccn_p) = pF "ccn" Nothing +(ccv, ccv_p) = pF "ccv" Nothing +cc = grp [ccn_p, ccv_p] + (ctlNum, ctlNum_p) = pF "ctlNum" Nothing + (frameRate, frameRate_p) = pF "frameRate" Nothing (frames, frames_p) = pF "frames" Nothing (hours, hours_p) = pF "hours" Nothing + (midicmd, midicmd_p) = pS "midicmd" Nothing +command = midicmd + (minutes, minutes_p) = pF "minutes" Nothing (progNum, progNum_p) = pF "progNum" Nothing (seconds, seconds_p) = pF "seconds" Nothing From f618811c1ff83f47ba637e39922c7f23d5e6e227 Mon Sep 17 00:00:00 2001 From: Alex McLean Date: Fri, 6 Apr 2018 20:31:16 +0100 Subject: [PATCH 29/38] Try to add 8.4.1 --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index a7ecbbaf1..660b56fdf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,9 @@ matrix: - env: CABALVER=1.24 GHCVER=8.0.1 compiler: ": #GHC 8.0.1" addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1], sources: [hvr-ghc]}} + - env: CABALVER=1.24 GHCVER=8.0.1 + compiler: ": #GHC 8.4.1" + addons: {apt: {packages: [cabal-install-head,ghc-8.4.1], sources: [hvr-ghc]}} before_install: - unset CC From dd014681ee3f779d3fccfc71639c5fde28faa30a Mon Sep 17 00:00:00 2001 From: Alex McLean Date: Fri, 6 Apr 2018 20:32:42 +0100 Subject: [PATCH 30/38] delete stray backup file --- tests/test.hs~ | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 tests/test.hs~ diff --git a/tests/test.hs~ b/tests/test.hs~ deleted file mode 100644 index ed6c163d9..000000000 --- a/tests/test.hs~ +++ /dev/null @@ -1,30 +0,0 @@ -import Test.Tasty -import Test.Tasty.SmallCheck as SC -import Test.Tasty.QuickCheck as QC -import Test.Tasty.HUnit - -import Data.List -import Data.Ord - -main = defaultMain tests - -tests :: TestTree -tests = testGroup "Tests" [sequences] - -sequences :: TestTree -sequences = testGroup "Sequences" [basic1] - -basic1 = testGroup "fast / slow" - [testCase "fast" $ - True - ] - - -unitTests = testGroup "Unit tests" - [ testCase "List comparison (different length)" $ - [1, 2, 3] `compare` [1,2] @?= GT - - -- the following test does not hold - , testCase "List comparison (same length)" $ - [1, 2, 3] `compare` [1,2,2] @?= LT - ] From d8f5bc8f6380e1d77a60949fb851c7dd2930a3ea Mon Sep 17 00:00:00 2001 From: Alex McLean Date: Fri, 6 Apr 2018 20:39:35 +0100 Subject: [PATCH 31/38] Update .travis.yml --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 660b56fdf..385089a82 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,9 +19,9 @@ matrix: - env: CABALVER=1.24 GHCVER=8.0.1 compiler: ": #GHC 8.0.1" addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1], sources: [hvr-ghc]}} - - env: CABALVER=1.24 GHCVER=8.0.1 - compiler: ": #GHC 8.4.1" - addons: {apt: {packages: [cabal-install-head,ghc-8.4.1], sources: [hvr-ghc]}} + - compiler: "ghc-8.4.1" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.4.1], sources: [hvr-ghc]}} before_install: - unset CC From 5f8879474ca088ac7e92a98cc61890736c736cf1 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 6 Apr 2018 21:40:26 +0100 Subject: [PATCH 32/38] add semigroup to support 8.4.1 (plus remove a couple of minor warnings) --- Sound/Tidal/Pattern.hs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Sound/Tidal/Pattern.hs b/Sound/Tidal/Pattern.hs index 68f59b87a..c1f8a07e2 100644 --- a/Sound/Tidal/Pattern.hs +++ b/Sound/Tidal/Pattern.hs @@ -23,6 +23,7 @@ import Sound.Tidal.Bjorklund import Text.Show.Functions () import qualified Control.Exception as E +import qualified Data.Semigroup as Sem -- | The pattern datatype, a function from a time @Arc@ to @Event@ -- values. For discrete patterns, this returns the events which are @@ -161,11 +162,14 @@ instance Applicative Pattern where (xs (s',e')) ) +-- | @mappend@ a.k.a. @<>@ is a synonym for @overlay@. +instance Sem.Semigroup (Pattern a) where + (<>) = overlay + -- | @mempty@ is a synonym for @silence@. --- | @mappend@ is a synonym for @overlay@. instance Monoid (Pattern a) where - mempty = silence - mappend = overlay + mempty = silence + mappend = (<>) instance Monad Pattern where return = pure @@ -1370,10 +1374,11 @@ randArcs n = where pairUp [] = [] pairUp xs = (0,head xs):(pairUp' xs) pairUp' [] = [] - pairUp' (a:[]) = [] - pairUp' (a:b:[]) = [(a,1)] + pairUp' (_:[]) = [] + pairUp' (a:_:[]) = [(a,1)] pairUp' (a:b:xs) = (a,b):(pairUp' (b:xs)) +randStruct :: Int -> Pattern Int randStruct n = splitQueries $ Pattern f where f (s,e) = mapSnds' fromJust $ filter (\(_,x,_) -> isJust x) $ as where as = map (\(n, (s',e')) -> ((s' + sam s, e' + sam s), From 1c4f6d3993b468f59cf0f7258cfc5e7db9e5da9f Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 6 Apr 2018 21:45:11 +0100 Subject: [PATCH 33/38] disable broken test --- tests/test.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test.hs b/tests/test.hs index d54f3452c..90e71310a 100644 --- a/tests/test.hs +++ b/tests/test.hs @@ -9,12 +9,12 @@ import Data.List import Data.Ord import Sound.Tidal.Context - +pp main = defaultMain tests tests :: TestTree -tests = testGroup "Tests" [basic1, - patternsOfPatterns +tests = testGroup "Tests" [basic1 + -- patternsOfPatterns ] basic1 = testGroup "fast / slow" From 11e53cf6839b90fce34be4a0c56540a74145f14c Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 6 Apr 2018 21:46:47 +0100 Subject: [PATCH 34/38] bump to 0.9.7, add semigroups for 8.4.1 compatibility --- tidal.cabal | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tidal.cabal b/tidal.cabal index a18c40e63..6c14c0fde 100644 --- a/tidal.cabal +++ b/tidal.cabal @@ -1,5 +1,5 @@ name: tidal -version: 0.9.6 +version: 0.9.7 synopsis: Pattern language for improvised music -- description: homepage: http://tidalcycles.org/ @@ -55,6 +55,9 @@ library , websockets > 0.8 , mtl >= 2.1 + if !impl(ghc >= 8.0) + build-depends: semigroups == 0.18.* + source-repository head type: git location: https://github.com/tidalcycles/Tidal @@ -70,6 +73,6 @@ test-suite test test.hs build-depends: base >= 4 && < 5 - , tasty >= 0.11 + , tasty , tasty-hunit , tidal From e6532b31eb178731506de9c1d8f6942d0a6ec75e Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 6 Apr 2018 21:56:34 +0100 Subject: [PATCH 35/38] ahem --- tests/test.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test.hs b/tests/test.hs index 90e71310a..16ee193dc 100644 --- a/tests/test.hs +++ b/tests/test.hs @@ -9,7 +9,7 @@ import Data.List import Data.Ord import Sound.Tidal.Context -pp + main = defaultMain tests tests :: TestTree From 3d2338196ece6ff354d842e6ced91e288e631255 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 6 Apr 2018 22:08:46 +0100 Subject: [PATCH 36/38] semigroup instance for tpat --- Sound/Tidal/Parse.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sound/Tidal/Parse.hs b/Sound/Tidal/Parse.hs index d049af763..37b7bc22c 100644 --- a/Sound/Tidal/Parse.hs +++ b/Sound/Tidal/Parse.hs @@ -12,6 +12,7 @@ import Data.Colour.Names import Data.Colour.SRGB import GHC.Exts( IsString(..) ) import Data.Monoid +import qualified Data.Semigroup as Sem import Control.Exception as E import Control.Applicative ((<$>), (<*>), pure) import Data.Maybe @@ -39,9 +40,12 @@ data TPat a = TPat_Atom a | TPat_pE (TPat Int) (TPat Int) (TPat Integer) (TPat a) deriving (Show) +instance Sem.Semigroup (TPat a) where + (<>) = TPat_Overlay + instance Parseable a => Monoid (TPat a) where mempty = TPat_Silence - mappend = TPat_Overlay + mappend = (<>) toPat :: Enumerable a => TPat a -> Pattern a toPat = \case From 2705628c5cbe0f6a7a6f9ec205e10aac62788242 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 6 Apr 2018 23:11:48 +0100 Subject: [PATCH 37/38] default discretise to not have patterned first parameter.. it seems values < 1 arent working --- Sound/Tidal/Pattern.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Sound/Tidal/Pattern.hs b/Sound/Tidal/Pattern.hs index c1f8a07e2..cdcdd3afa 100644 --- a/Sound/Tidal/Pattern.hs +++ b/Sound/Tidal/Pattern.hs @@ -1282,8 +1282,11 @@ pequal cycles p1 p2 = (sort $ arc p1 (0, cycles)) == (sort $ arc p2 (0, cycles)) -- | @discretise n p@: 'samples' the pattern @p@ at a rate of @n@ -- events per cycle. Useful for turning a continuous pattern into a -- discrete one. -discretise :: Pattern Time -> Pattern a -> Pattern a -discretise n p = (density n $ atom (id)) <*> p +discretise :: Time -> Pattern a -> Pattern a +discretise = _discretise + +discretise' :: Pattern Time -> Pattern a -> Pattern a +discretise' n p = (density n $ atom (id)) <*> p _discretise :: Time -> Pattern a -> Pattern a _discretise n p = (_density n $ atom (id)) <*> p @@ -1291,7 +1294,7 @@ _discretise n p = (_density n $ atom (id)) <*> p -- | @randcat ps@: does a @slowcat@ on the list of patterns @ps@ but -- randomises the order in which they are played. randcat :: [Pattern a] -> Pattern a -randcat ps = spread' (rotL) (discretise 1 $ ((%1) . fromIntegral) <$> (irand (length ps) :: Pattern Int)) (slowcat ps) +randcat ps = spread' (rotL) (_discretise 1 $ ((%1) . fromIntegral) <$> (irand (length ps) :: Pattern Int)) (slowcat ps) -- @fromNote p@: converts a pattern of human-readable pitch names -- into pitch numbers. For example, @"cs2"@ will be parsed as C Sharp @@ -1343,7 +1346,7 @@ fit perCycle xs p = (xs !!!) <$> (Pattern $ \a -> map ((\e -> (mapThd' (+ (cycle where cyclePos perCycle e = perCycle * (floor $ eventStart e) permstep :: RealFrac b => Int -> [a] -> Pattern b -> Pattern a -permstep steps things p = unwrap $ (\n -> listToPat $ concatMap (\x -> replicate (fst x) (snd x)) $ zip (ps !! (floor (n * (fromIntegral $ (length ps - 1))))) things) <$> (discretise 1 p) +permstep steps things p = unwrap $ (\n -> listToPat $ concatMap (\x -> replicate (fst x) (snd x)) $ zip (ps !! (floor (n * (fromIntegral $ (length ps - 1))))) things) <$> (_discretise 1 p) where ps = permsort (length things) steps deviance avg xs = sum $ map (abs . (avg-) . fromIntegral) xs permsort n total = map fst $ sortBy (comparing snd) $ map (\x -> (x,deviance (fromIntegral total / (fromIntegral n :: Double)) x)) $ perms n total From 190bee8c37e94a34ac3949c8fdead5a681c4dbe2 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 10 Apr 2018 20:44:31 +0100 Subject: [PATCH 38/38] update ghc versions --- tidal.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tidal.cabal b/tidal.cabal index 6c14c0fde..0e4f2fe22 100644 --- a/tidal.cabal +++ b/tidal.cabal @@ -12,7 +12,7 @@ Copyright: (c) Tidal contributors, 2017 category: Sound build-type: Simple cabal-version: >=1.10 -tested-with: GHC == 7.10.3, GHC == 8.0.1 +tested-with: GHC == 7.10.3, GHC == 8.0.1, GHC == 8.4.1 Extra-source-files: README.md CHANGELOG.md tidal.el doc/tidal.md