Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP sequences #929

Draft
wants to merge 37 commits into
base: 2.0-beatmode-retired
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
0f76b13
Add experimental sequence datatype
yaxu Jul 25, 2022
e646b84
Merge branch 'main' into topic-sequences
yaxu Jul 25, 2022
7b50bba
make transformable work on types of kind a -> a, ref https://club.tid…
yaxu Jul 25, 2022
03e8be6
rename Branch to Sequence
yaxu Jul 26, 2022
a28d1c2
merge Common.hs into Context.hs
yaxu Jul 26, 2022
08d9b60
Added stratApply
aravind-mohandas Jul 28, 2022
9effb34
Added Applicated funtor and monad instances for Sequence
aravind-mohandas Jul 29, 2022
0773bf6
Modified Applicative Functor instance
aravind-mohandas Jul 31, 2022
59459ba
Added methods to reduce sequences
aravind-mohandas Aug 1, 2022
b76c217
Added squeeze strategy and fast method
aravind-mohandas Aug 1, 2022
0e02153
Added fast, slow, rep, repSqueeze
aravind-mohandas Aug 3, 2022
0f28e4b
fix build errors
yaxu Aug 3, 2022
6a8c7fd
Merge branch 'main' into topic-sequences
yaxu Aug 3, 2022
2f7bb08
Modified fast, slow to match with Tidal
aravind-mohandas Aug 4, 2022
6aa7a92
Added every function
aravind-mohandas Aug 5, 2022
2663d93
fiddles to get it to build
yaxu Aug 5, 2022
de7c096
Added fromList Method
aravind-mohandas Aug 9, 2022
30ce5e4
Merge branch 'topic-sequences' of https://github.com/tidalcycles/Tida…
aravind-mohandas Aug 9, 2022
1484946
Added equivalent functions for those from Sound.Tidal.Core for Patterns
aravind-mohandas Aug 9, 2022
c152d5e
Reinstate seqPat
yaxu Aug 9, 2022
9ffff33
Merge branch 'topic-sequences' of github.com:tidalcycles/tidal into t…
yaxu Aug 9, 2022
01c4b48
fix lagging upper bounds, remove bifunctors dependency (this seems to…
yaxu Aug 10, 2022
0d549c2
Merge branch 'main' into topic-sequences
yaxu Aug 10, 2022
298a792
add ghc 9.4.1 to ci workflow
yaxu Aug 10, 2022
e383ee3
Merge branch 'main' into topic-sequences
yaxu Aug 11, 2022
82d8141
Added methods to Context.hs
aravind-mohandas Aug 14, 2022
882f333
Changes to get it to build, added every method
aravind-mohandas Aug 15, 2022
5a47a22
Added ply method
aravind-mohandas Aug 17, 2022
8352755
Added Konnakol to avoid dependency issues
aravind-mohandas Aug 18, 2022
a2074c7
Added methods for shifiting sequences to left or right)
aravind-mohandas Aug 19, 2022
5ed5334
Added iter, fixed shift methods, fixed duration of converting to patt…
aravind-mohandas Aug 22, 2022
d368fa1
Added forTwoS and seqMapS, started writing tests
aravind-mohandas Aug 25, 2022
77831e8
Added option for strategy in all functions that are applied to Sequen…
aravind-mohandas Aug 26, 2022
277cbc5
Fixed Euclid
aravind-mohandas Aug 27, 2022
9c5678f
Finished writing tests
aravind-mohandas Aug 29, 2022
0b4aabb
Added documentation
aravind-mohandas Aug 30, 2022
28abbe0
Merge branch 'main' into topic-sequences
yaxu Mar 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
210 changes: 206 additions & 4 deletions src/Sound/Tidal/Context.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,46 @@
module Sound.Tidal.Context (module C) where
module Sound.Tidal.Context (module C,
Sound.Tidal.Context.rev,
Sound.Tidal.Context.cat,
Sound.Tidal.Context.ply,
Sound.Tidal.Context.stack,
Sound.Tidal.Context.euclid,
Sound.Tidal.Context.fast,
Sound.Tidal.Context.slow,
Sound.Tidal.Context.seqPat,
Sound.Tidal.Context._euclid,
Sound.Tidal.Context._slow,
Sound.Tidal.Context._fast,
Sound.Tidal.Context.timeCat,
Sound.Tidal.Context.timecat,
Sound.Tidal.Context.fastAppend,
Sound.Tidal.Context.fastappend,
Sound.Tidal.Context.slowAppend,
Sound.Tidal.Context.slowappend,
Sound.Tidal.Context.append,
Sound.Tidal.Context.fromList,
Sound.Tidal.Context.fastFromList,
Sound.Tidal.Context.fromMaybes,
Sound.Tidal.Context.run,
Sound.Tidal.Context._run,
Sound.Tidal.Context.scan,
Sound.Tidal.Context._scan,
Sound.Tidal.Context.every,
Sound.Tidal.Context._every,
Sound.Tidal.Context.listToPat,
Sound.Tidal.Context.fastcat,
Sound.Tidal.Context.fastCat,
Sound.Tidal.Context.slowcat,
Sound.Tidal.Context.slowCat,
Sound.Tidal.Context.density,
Sound.Tidal.Context.iter,
Sound.Tidal.Context.iter',
Sound.Tidal.Context._iter,
Sound.Tidal.Context._iter',
Sound.Tidal.Context.rotL,
Sound.Tidal.Context.rotR,
(Sound.Tidal.Context.<~),
(Sound.Tidal.Context.~>)
) where

{-
Context.hs - For exposing the core TidalCycles libraries
Expand All @@ -24,14 +66,174 @@ import Data.Ratio as C

import Sound.Tidal.Config as C
import Sound.Tidal.Control as C
import Sound.Tidal.Core as C
import Sound.Tidal.Core as C hiding (rev, cat, stack, fast, slow,_slow, slowcat, _fast, timeCat, timecat, fastAppend, fastappend,
slowAppend, slowappend, append, fromList, fastFromList, fromMaybes, run, _run, scan,
_scan, every, _every,listToPat, fastCat, fastcat, slowCat, slowcat,density, (<~), (~>)
)
import Sound.Tidal.Params as C
import Sound.Tidal.ParseBP as C
import Sound.Tidal.Pattern as C
import Sound.Tidal.Pattern as C hiding (rotL, rotR)
import Sound.Tidal.Scales as C
import Sound.Tidal.Sequence as C hiding (rev, cat, ply, stack,
unwrap, fast, slow, euclid, _euclid, _slow, _fast,
timeCat, timecat,fastAppend, fastappend, slowAppend, slowappend, append,
fromList, fastFromList, fromMaybes, run, _run, scan, _scan, every, _every, every',
listToPat, fastcat, fastCat, slowcat, slowCat, density, iter, _iter, iter', _iter',
rotL, rotR, (<~), (~>)
)
import Sound.Tidal.Show as C
import Sound.Tidal.Simple as C
import Sound.Tidal.Stream as C
import Sound.Tidal.Transition as C
import Sound.Tidal.UI as C
import Sound.Tidal.UI as C hiding (_ply,ply, euclid,_euclid, iter, _iter, iter', _iter')
import Sound.Tidal.Version as C

import Sound.Tidal.Pattern as Pat
import Sound.Tidal.Core as Pat
import Sound.Tidal.UI as Pat

import Sound.Tidal.Sequence as Seq

class Transformable f where
rev :: f a -> f a
cat :: [f a] -> f a
ply :: f Rational -> f a -> f a
_ply :: Rational ->f a-> f a
stack :: [f a] -> f a
euclid :: f Int -> f Int -> f String -> f String
fast :: f Rational -> f a -> f a
slow :: f Rational -> f a -> f a
_euclid :: Int -> Int -> f a-> f a
_slow :: Rational -> f a -> f a
_fast :: Rational -> f a -> f a
timeCat :: [(Rational, f a)] -> f a
timecat :: [(Rational, f a)] -> f a
fastAppend :: f a -> f a -> f a
fastappend :: f a -> f a -> f a
slowAppend :: f a -> f a -> f a
slowappend :: f a -> f a -> f a
append :: f a -> f a -> f a
fromList :: [a] -> f a
fastFromList :: [a] -> f a
fromMaybes :: [Maybe a] -> f a
run :: (Enum a, Num a) => f a -> f a
_run :: (Enum a, Num a) => a -> f a
scan :: (Enum a, Num a) => f a -> f a
_scan :: (Enum a, Num a) => a -> f a
every :: f Int -> (f b -> f b) -> f b -> f b
_every :: Int -> (f a -> f a) -> f a -> f a
listToPat :: [a] -> f a
fastcat :: [f a] -> f a
fastCat :: [f a] -> f a
slowcat :: [f a] -> f a
slowCat :: [f a] -> f a
density :: f Rational -> f a-> f a
rotL :: Rational -> f a -> f a
rotR :: Rational -> f a -> f a
iter :: f Int -> f a -> f a
iter' :: f Int -> f a -> f a
_iter :: Int -> f a -> f a
_iter' :: Int -> f a -> f a
(<~) :: f Rational -> f a -> f a
(~>) :: f Rational -> f a -> f a

instance Transformable Pattern where
rev = Pat.rev
cat = Pat.cat
ply = Pat.ply
_ply = Pat._ply
stack = Pat.stack
euclid = Pat.euclid
fast = Pat.fast
slow = Pat.slow
_euclid = Pat._euclid
_slow = Pat._slow
_fast = Pat._fast
timeCat = Pat.timeCat
timecat = Pat.timecat
fastAppend = Pat.fastAppend
fastappend = Pat.fastappend
slowAppend = Pat.slowAppend
slowappend = Pat.slowappend
append = Pat.append
fromList = Pat.fromList
fastFromList = Pat.fastFromList
fromMaybes = Pat.fromMaybes
run = Pat.run
_run = Pat._run
scan = Pat.scan
_scan = Pat._scan
every = Pat.every
_every = Pat._every
listToPat = Pat.listToPat
fastCat = Pat.fastCat
fastcat = Pat.fastcat
slowcat = Pat.slowcat
slowCat = Pat.slowCat
density = Pat.density
rotL = Pat.rotL
rotR = Pat.rotR
iter = Pat.iter
iter' = Pat.iter'
_iter = Pat._iter
_iter' = Pat._iter'
(<~) = (Pat.<~)
(~>) = (Pat.~>)

instance Transformable Sequence where
rev = Seq.rev
cat = Seq.cat
ply = Seq.ply
_ply = Seq._ply
stack = Seq.stack
euclid = Seq.euclid
fast = Seq.fast
slow = Seq.slow
_euclid = Seq._euclid
_slow = Seq._slow
_fast = Seq._fast
timeCat = Seq.timeCat
timecat = Seq.timecat
fastAppend = Seq.fastAppend
fastappend = Seq.fastappend
slowAppend = Seq.slowAppend
slowappend = Seq.slowappend
append = Seq.append
fromList = Seq.fromList
fastFromList = Seq.fastFromList
fromMaybes = Seq.fromMaybes
run = Seq.run
_run = Seq._run
scan = Seq.scan
_scan = Seq._scan
every = Seq.every
_every = Seq._every
listToPat = Seq.listToPat
fastCat = Seq.fastCat
fastcat = Seq.fastcat
slowCat = Seq.slowCat
slowcat = Seq.slowcat
density = Seq.density
rotL = Seq.rotL
rotR = Seq.rotR
iter = Seq.iter
iter' = Seq.iter'
_iter = Seq._iter
_iter' = Seq._iter'
(<~) = (Seq.<~)
(~>) = (Seq.~>)


seqPat :: Seq.Sequence a -> Pat.Pattern a
seqPat (Seq.Atom x a) = Pat.slow (fromRational$ toRational x) (pure a)
seqPat (Seq.Gap x) = Pat.slow (fromRational $ toRational x) (Pat.silence)
seqPat (Seq.Sequence bs) = let t = Seq.seqSpan (Seq.Sequence bs) in
Pat.slow (fromRational $ toRational t) $ Pat.timecat $ map (\b -> (seqSpan b, seqPatHelp b)) bs
seqPat (Seq.Stack bs) = let t = Seq.seqSpan (Seq.Stack bs) in
Pat.slow (fromRational $ toRational t) $ Pat.stack $ map seqPat bs

seqPatHelp :: Seq.Sequence a -> Pat.Pattern a
seqPatHelp (Seq.Atom _ a) = pure a
seqPatHelp (Seq.Gap _) = Pat.silence
seqPatHelp (Seq.Sequence bs) = Pat.timecat $ map (\b -> (seqSpan b, seqPatHelp b)) bs
seqPatHelp (Seq.Stack bs) = Pat.stack $ map seqPat bs
Loading