Skip to content

Commit

Permalink
Merge pull request #287 from tidalcycles/1.0-dev
Browse files Browse the repository at this point in the history
0.9.7
  • Loading branch information
yaxu authored Apr 10, 2018
2 parents b96bc78 + 190bee8 commit ef658d3
Show file tree
Hide file tree
Showing 12 changed files with 196 additions and 117 deletions.
9 changes: 3 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@ 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]}}
- 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]}}
- 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
Expand Down
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# TidalCycles log of changes

## 0.96
## 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

* Added `chord` for chord patterns and `scaleP` for scale patterns
* The `n` pattern parameter is now floating point

## 0.9.5

Expand Down
46 changes: 39 additions & 7 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,60 @@ 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 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:

* Make a dev fork
* Make and test a change
* 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 not being
overlooked.

# 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

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
43 changes: 35 additions & 8 deletions Sound/Tidal/Params.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -174,8 +174,9 @@ 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)
(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:
Expand Down Expand Up @@ -340,14 +341,13 @@ vcf = vcfegint
vco = vcoegint
voi = voice

note, midinote :: Pattern Int -> ParamPattern
note = n
midinote = n . ((subtract 60) <$>)
midinote :: Pattern Double -> ParamPattern
midinote = note . ((subtract 60) <$>)

drum :: Pattern String -> ParamPattern
drum = midinote . (drumN <$>)
drum = n . ((subtract 60) . drumN <$>)

drumN :: String -> Int
drumN :: Num a => String -> a
drumN "bd" = 36
drumN "sn" = 38
drumN "lt" = 43
Expand All @@ -359,3 +359,30 @@ 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

(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
(songPtr, songPtr_p) = pF "songPtr" Nothing
(uid, uid_p) = pF "uid" Nothing
(val, val_p) = pF "val" Nothing
52 changes: 32 additions & 20 deletions Sound/Tidal/Parse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,8 +24,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
Expand All @@ -39,15 +40,18 @@ 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 :: 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 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
Expand All @@ -67,41 +71,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

Expand All @@ -115,10 +127,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
Expand Down Expand Up @@ -158,15 +171,15 @@ 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)
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
Expand Down Expand Up @@ -253,7 +266,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"
Expand All @@ -265,8 +278,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)
Expand All @@ -276,7 +288,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
Expand All @@ -289,7 +301,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
Expand All @@ -311,7 +323,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)
Expand All @@ -322,12 +334,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
Expand Down
Loading

0 comments on commit ef658d3

Please sign in to comment.