-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Pattern language for improvised music -- -- Tidal is a domain specific language for live coding pattern. @package tidal @version 0.7 module Sound.Tidal.MIDI.Device displayOutputDevices :: IO String displayDevices :: Show a => [(a, DeviceInfo)] -> String getOutputDevices :: [(a, DeviceInfo)] -> [(a, DeviceInfo)] getIndexedDevices :: IO [(Integer, DeviceInfo)] getDevices :: IO ([DeviceInfo]) getIDForDeviceName :: Num a => String -> IO (Maybe a) module Sound.Tidal.Utils enumerate :: [a] -> [(Int, a)] mapFst :: (a -> b) -> (a, c) -> (b, c) mapFsts :: (a -> b) -> [(a, c)] -> [(b, c)] mapSnd :: (a -> b) -> (c, a) -> (c, b) mapSnds :: (a -> b) -> [(c, a)] -> [(c, b)] wordsBy :: (a -> Bool) -> [a] -> [[a]] maybeRead :: String -> Maybe Double fst' :: (t, t1, t2) -> t snd' :: (t, t1, t2) -> t1 thd' :: (t, t1, t2) -> t2 mapFst' :: (a -> x) -> (a, b, c) -> (x, b, c) mapSnd' :: (b -> x) -> (a, b, c) -> (a, x, c) mapThd' :: (c -> x) -> (a, b, c) -> (a, b, x) mapFsts' :: (a -> x) -> [(a, b, c)] -> [(x, b, c)] mapSnds' :: (b -> x) -> [(a, b, c)] -> [(a, x, c)] mapThds' :: (c -> x) -> [(a, b, c)] -> [(a, b, x)] mapArcs :: (a -> a) -> [(a, a, x)] -> [(a, a, x)] getEnvDefault :: String -> String -> IO String mergelists :: [a] -> [a] -> [a] (!!!) :: [a] -> Int -> a module Sound.Tidal.Tempo data Tempo Tempo :: UTCTime -> Double -> Double -> Bool -> Double -> Tempo [at] :: Tempo -> UTCTime [beat] :: Tempo -> Double [cps] :: Tempo -> Double [paused] :: Tempo -> Bool [clockLatency] :: Tempo -> Double type ClientState = [Connection] getLatency :: IO Double getClockIp :: IO String getServerPort :: IO Int readTempo :: String -> Tempo logicalTime :: Tempo -> Double -> Double tempoMVar :: IO (MVar (Tempo)) beatNow :: Tempo -> IO (Double) clientApp :: MVar Tempo -> MVar Double -> ClientApp () sendCps :: Connection -> MVar Tempo -> MVar Double -> IO () connectClient :: Bool -> String -> MVar Tempo -> MVar Double -> IO () runClient :: IO ((MVar Tempo, MVar Double)) cpsUtils :: IO ((Double -> IO (), IO (Rational))) bpsUtils :: IO ((Double -> IO (), IO (Rational))) cpsSetter :: IO (Double -> IO ()) clocked :: (Tempo -> Int -> IO ()) -> IO () clockedTick :: Int -> (Tempo -> Int -> IO ()) -> IO () updateTempo :: Tempo -> Double -> IO (Tempo) addClient :: a -> [a] -> [a] removeClient :: Connection -> ClientState -> ClientState broadcast :: Text -> ClientState -> IO () startServer :: IO (ThreadId) serverApp :: MVar Tempo -> MVar ClientState -> ServerApp serverLoop :: Connection -> MVar Tempo -> MVar ClientState -> IO () instance GHC.Classes.Eq Network.WebSockets.Connection.Connection instance GHC.Show.Show Sound.Tidal.Tempo.Tempo module Sound.Tidal.Time -- | Time is represented by a rational number. Each natural number -- represents both the start of the next rhythmic cycle, and the end of -- the previous one. Rational numbers are used so that subdivisions of -- each cycle can be accurately represented. type Time = Rational -- | (s,e) :: Arc represents a time interval with a start and end -- value. { t : s <= t && t < e } type Arc = (Time, Time) -- | An Event is a value that occurs during the period given by the first -- Arc. The second one indicates the event's "domain of -- influence". These will often be the same, but many temporal -- transformations, such as rotation and scaling time, may result in arcs -- being split or truncated. In such cases, the first arc is preserved, -- but the second arc reflects the portion of the event which is -- relevant. type Event a = (Arc, Arc, a) -- | The starting point of the current cycle. A cycle occurs from each -- natural number to the next, so this is equivalent to floor. sam :: Time -> Time -- | The end point of the current cycle (and starting point of the next -- cycle) nextSam :: Time -> Time -- | The position of a time value relative to the start of its cycle. cyclePos :: Time -> Time -- | isIn a t is True iff t is inside the arc -- represented by a. isIn :: Arc -> Time -> Bool -- | Splits the given Arc into a list of Arcs, at cycle -- boundaries. arcCycles :: Arc -> [Arc] -- | Splits the given Arc into a list of Arcs, at cycle -- boundaries, but wrapping the arcs within the same cycle. arcCycles' :: Arc -> [Arc] -- | subArc i j is the arc that is the intersection of i -- and j. subArc :: Arc -> Arc -> Maybe Arc -- | Map the given function over both the start and end Time -- values of the given Arc. mapArc :: (Time -> Time) -> Arc -> Arc -- | Similar to mapArc but time is relative to the cycle (i.e. the -- sam of the start of the arc) mapCycle :: (Time -> Time) -> Arc -> Arc -- | Returns the `mirror image' of an Arc, used by -- Sound.Tidal.Pattern.rev. mirrorArc :: Arc -> Arc -- | The start time of the given Event eventStart :: Event a -> Time -- | The original onset of the given Event eventOnset :: Event a -> Time -- | The original offset of the given Event eventOffset :: Event a -> Time -- | The arc of the given Event eventArc :: Event a -> Arc -- | The midpoint of an Arc midPoint :: Arc -> Time hasOnset :: Event a -> Bool hasOffset :: Event a -> Bool onsetIn :: Arc -> Event a -> Bool offsetIn :: Arc -> Event a -> Bool module Sound.Tidal.Pattern -- | The pattern datatype, a function from a time Arc to -- Event values. For discrete patterns, this returns the events -- which are active during that time. For continuous patterns, events -- with values for the midpoint of the given Arc is returned. data Pattern a Pattern :: (Arc -> [Event a]) -> Pattern a [arc] :: Pattern a -> Arc -> [Event a] -- | show (p :: Pattern) returns a text string representing the -- event values active during the first cycle of the given pattern. showTime :: (Integral a, Show a) => Ratio a -> String showArc :: (Integral a, Integral a1, Show a, Show a1) => (Ratio a, Ratio a1) -> [Char] showEvent :: (Integral a, Integral a1, Show a, Show a1, Show a2) => ((Ratio a, Ratio a1), (Ratio a, Ratio a1), a2) -> [Char] -- | pure a returns a pattern with an event with value a, -- which has a duration of one cycle, and repeats every cycle. -- | mempty is a synonym for silence. | mappend -- is a synonym for overlay. unwrap :: Pattern (Pattern a) -> Pattern a -- | atom is a synonym for pure. atom :: a -> Pattern a -- | silence returns a pattern with no events. silence :: Pattern a -- | withQueryArc f p returns a new Pattern with function -- f applied to the Arc values passed to the original -- Pattern p. withQueryArc :: (Arc -> Arc) -> Pattern a -> Pattern a -- | withQueryTime f p returns a new Pattern with -- function f applied to the both the start and end -- Time of the Arc passed to Pattern -- p. withQueryTime :: (Time -> Time) -> Pattern a -> Pattern a -- | withResultArc f p returns a new Pattern with -- function f applied to the Arc values in the events -- returned from the original Pattern p. withResultArc :: (Arc -> Arc) -> Pattern a -> Pattern a -- | withResultTime f p returns a new Pattern with -- function f applied to the both the start and end -- Time of the Arc values in the events returned from -- the original Pattern p. withResultTime :: (Time -> Time) -> Pattern a -> Pattern a -- | overlay combines two Patterns into a new pattern, so -- that their events are combined over time. This is the same as the -- infix operator <>. overlay :: Pattern a -> Pattern a -> Pattern a -- | stack combines a list of Patterns into a new -- pattern, so that their events are combined over time. stack :: [Pattern a] -> Pattern a -- | append combines two patterns Patterns into a new -- pattern, so that the events of the second pattern are appended to -- those of the first pattern, within a single cycle append :: Pattern a -> Pattern a -> Pattern a -- | append' does the same as append, but over two -- cycles, so that the cycles alternate between the two patterns. append' :: Pattern a -> Pattern a -> Pattern a -- | cat returns a new pattern which interlaces the cycles of the -- given patterns, within a single cycle. It's the equivalent of -- append, but with a list of patterns. cat :: [Pattern a] -> Pattern a splitAtSam :: Pattern a -> Pattern a -- | slowcat does the same as cat, but maintaining the -- duration of the original patterns. It is the equivalent of -- append', but with a list of patterns. slowcat :: [Pattern a] -> Pattern a -- | listToPat turns the given list of values to a Pattern, which -- cycles through the list. listToPat :: [a] -> Pattern a -- | maybeListToPat is similar to listToPat, but allows -- values to be optional using the Maybe type, so that -- Nothing results in gaps in the pattern. maybeListToPat :: [Maybe a] -> Pattern a -- | run n returns a pattern representing a cycle of -- numbers from 0 to n-1. run :: (Enum a, Num a) => a -> Pattern a scan :: (Enum a, Num a) => a -> Pattern a -- | density returns the given pattern with density increased by -- the given Time factor. Therefore density 2 p will -- return a pattern that is twice as fast, and density (1%3) p -- will return one three times as slow. density :: Time -> Pattern a -> Pattern a -- | densityGap is similar to density but maintains its -- cyclic alignment. For example, densityGap 2 p would squash -- the events in pattern p into the first half of each cycle -- (and the second halves would be empty). densityGap :: Time -> Pattern a -> Pattern a -- | slow does the opposite of density, i.e. slow 2 -- p will return a pattern that is half the speed. slow :: Time -> Pattern a -> Pattern a -- | The <~ operator shifts (or rotates) a pattern to the left -- (or counter-clockwise) by the given Time value. For example -- (1%16) <~ p will return a pattern with all the events -- moved one 16th of a cycle to the left. (<~) :: Time -> Pattern a -> Pattern a -- | The ~> operator does the same as ~> but shifts -- events to the right (or clockwise) rather than to the left. (~>) :: Time -> Pattern a -> Pattern a brak :: Pattern a -> Pattern a iter :: Int -> Pattern a -> Pattern a -- | rev p returns p with the event positions in each -- cycle reversed (or mirrored). rev :: Pattern a -> Pattern a -- | palindrome p applies rev to p every other -- cycle, so that the pattern alternates between forwards and backwards. palindrome :: Pattern a -> Pattern a -- | when test f p applies the function f to p, -- but in a way which only affects cycles where the test -- function applied to the cycle number returns True. when :: (Int -> Bool) -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a whenT :: (Time -> Bool) -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a playWhen :: (Time -> Bool) -> Pattern a -> Pattern a playFor :: Time -> Time -> Pattern a -> Pattern a seqP :: [(Time, Time, Pattern a)] -> Pattern a -- | every n f p applies the function f to p, -- but only affects every n cycles. every :: Int -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a -- | foldEvery ns f p applies the function f to -- p, and is applied for each cycle in ns. foldEvery :: [Int] -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a -- | sig f takes a function from time to values, and turns it into -- a Pattern. sig :: (Time -> a) -> Pattern a -- | sinewave returns a Pattern of continuous -- Double values following a sinewave with frequency of one -- cycle, and amplitude from -1 to 1. sinewave :: Pattern Double -- | sine is a synonym for @sinewave. sine :: Pattern Double -- | sinerat is equivalent to sinewave for -- Rational values, suitable for use as Time offsets. sinerat :: Pattern Rational ratsine :: Pattern Rational -- | sinewave1 is equivalent to sinewave, but with -- amplitude from 0 to 1. sinewave1 :: Pattern Double -- | sine1 is a synonym for sinewave1. sine1 :: Pattern Double -- | sinerat1 is equivalent to sinerat, but with -- amplitude from 0 to 1. sinerat1 :: Pattern Rational -- | sineAmp1 d returns sinewave1 with its amplitude -- offset by d. sineAmp1 :: Double -> Pattern Double -- | sawwave is the equivalent of sinewave for sawtooth -- waves. sawwave :: Pattern Double -- | saw is a synonym for sawwave. saw :: Pattern Double -- | sawrat is the same as sawwave but returns -- Rational values suitable for use as Time offsets. sawrat :: Pattern Rational sawwave1 :: Pattern Double saw1 :: Pattern Double sawrat1 :: Pattern Rational -- | triwave is the equivalent of sinewave for triangular -- waves. triwave :: Pattern Double -- | tri is a synonym for triwave. tri :: Pattern Double -- | trirat is the same as triwave but returns -- Rational values suitable for use as Time offsets. trirat :: Pattern Rational triwave1 :: Pattern Double tri1 :: Pattern Double trirat1 :: Pattern Rational squarewave1 :: Pattern Double square1 :: Pattern Double squarewave :: Pattern Double square :: Pattern Double -- | envL is a Pattern of continuous Double -- values, representing a linear interpolation between 0 and 1 during the -- first cycle, then staying constant at 1 for all following cycles. -- Possibly only useful if you're using something like the retrig -- function defined in tidal.el. envL :: Pattern Double envLR :: Pattern Double envEq :: Pattern Double envEqR :: Pattern Double fadeOut :: Time -> Pattern a -> Pattern a fadeOut' :: Time -> Time -> Pattern a -> Pattern a fadeIn' :: Time -> Time -> Pattern a -> Pattern a fadeIn :: Time -> Pattern a -> Pattern a spread :: (a -> t -> Pattern b) -> [a] -> t -> Pattern b slowspread :: (a -> t -> Pattern b) -> [a] -> t -> Pattern b spread' :: (a -> Pattern b -> Pattern c) -> Pattern a -> Pattern b -> Pattern c filterValues :: (a -> Bool) -> Pattern a -> Pattern a filterOnsets :: Pattern a -> Pattern a filterStartInRange :: Pattern a -> Pattern a filterOnsetsInRange :: Pattern a -> Pattern a seqToRelOnsets :: Arc -> Pattern a -> [(Double, a)] segment :: Pattern a -> Pattern [a] segment' :: [Event a] -> [Event a] split :: Time -> [Event a] -> [Event a] points :: [Event a] -> [Time] groupByTime :: [Event a] -> [Event [a]] ifp :: (Int -> Bool) -> (Pattern a -> Pattern a) -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a rand :: Pattern Double timeToRand :: RealFrac r => r -> Double irand :: Int -> Pattern Int choose :: [a] -> Pattern a degradeBy :: Double -> Pattern a -> Pattern a unDegradeBy :: Double -> Pattern a -> Pattern a sometimesBy :: Double -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a sometimes :: (Pattern a -> Pattern a) -> Pattern a -> Pattern a often :: (Pattern a -> Pattern a) -> Pattern a -> Pattern a rarely :: (Pattern a -> Pattern a) -> Pattern a -> Pattern a almostNever :: (Pattern a -> Pattern a) -> Pattern a -> Pattern a almostAlways :: (Pattern a -> Pattern a) -> Pattern a -> Pattern a degrade :: Pattern a -> Pattern a -- | wedge t p p' combines patterns p and p' by -- squashing the p into the portion of each cycle given by -- t, and p' into the remainer of each cycle. wedge :: Time -> Pattern a -> Pattern a -> Pattern a whenmod :: Int -> Int -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a superimpose :: (Pattern a -> Pattern a) -> Pattern a -> Pattern a -- | splitQueries p wraps p to ensure that it does not -- get queries that span arcs. For example `arc p (0.5, 1.5)` would be -- turned into two queries, `(0.5,1)` and `(1,1.5)`, and the results -- combined. Being able to assume queries don't span cycles often makes -- transformations easier to specify. splitQueries :: Pattern a -> Pattern a trunc :: Time -> Pattern a -> Pattern a zoom :: Arc -> Pattern a -> Pattern a compress :: Arc -> Pattern a -> Pattern a sliceArc :: Arc -> Pattern a -> Pattern a within :: Arc -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a revArc :: Arc -> Pattern a -> Pattern a e :: Int -> Int -> Pattern a -> Pattern a e' :: Int -> Int -> Pattern a -> Pattern a index :: Real b => b -> Pattern b -> Pattern c -> Pattern c -- | prr rot (blen, vlen) beatPattern valuePattern: pattern -- rotate/replace. prrw :: (a -> b -> c) -> Int -> (Time, Time) -> Pattern a -> Pattern b -> Pattern c -- | prr rot (blen, vlen) beatPattern valuePattern: pattern -- rotate/replace. prr :: Int -> (Time, Time) -> Pattern a -> Pattern a -> Pattern a -- | preplace (blen, plen) beats values combines the timing of -- beats with the values of values. Other ways of -- saying this are: * sequential convolution * values quantized -- to beats. -- -- Examples: d1 $ sound $ preplace (1,1) "x [~ x] x x" "bd sn" d1 $ -- sound $ preplace (1,1) "x(3,8)" "bd sn" d1 $ sound $ "x(3,8)" ~ -- "bd sn" d1 $ sound "[jvbass jvbass:5]*3" |+| (shape $ "1 1 1 1 1" -- ~ "0.2 0.9") -- -- It is assumed the pattern fits into a single cycle. This works well -- with pattern literals, but not always with patterns defined elsewhere. -- In those cases use prr and provide desired pattern lengths: @ -- let p = slow 2 $ "x x x" -- -- d1 $ sound $ prr 0 (2,1) p "bd sn" @ preplace :: (Time, Time) -> Pattern a -> Pattern a -> Pattern a prep :: (Time, Time) -> Pattern a -> Pattern a -> Pattern a preplace1 :: Pattern a -> Pattern a -> Pattern a preplaceWith :: (a -> b -> c) -> (Time, Time) -> Pattern a -> Pattern b -> Pattern c prw :: (a -> b -> c) -> (Time, Time) -> Pattern a -> Pattern b -> Pattern c preplaceWith1 :: (a -> b -> c) -> Pattern a -> Pattern b -> Pattern c prw1 :: (a -> b -> c) -> Pattern a -> Pattern b -> Pattern c (<~>) :: Pattern a -> Pattern a -> Pattern a -- | protate len rot p rotates pattern p by rot -- beats to the left. len: length of the pattern, in cycles. -- Example: d1 $ every 4 (protate 2 (-1)) $ slow 2 $ sound "bd hh hh -- hh" protate :: Time -> Int -> Pattern a -> Pattern a prot :: Time -> Int -> Pattern a -> Pattern a prot1 :: Int -> Pattern a -> Pattern a -- | The <<~ operator rotates a unit pattern to the left, -- similar to <~, but by events rather than linear time. The -- timing of the pattern remains constant: -- --
-- d1 $ (1 <<~) $ sound "bd ~ sn hh" -- -- will become -- d1 $ sound "sn ~ hh bd" --(<<~) :: Int -> Pattern a -> Pattern a (~>>) :: Int -> Pattern a -> Pattern a -- | pequal cycles p1 p2: quickly test if p1 and -- p2 are the same. pequal :: Ord a => Time -> Pattern a -> Pattern a -> Bool -- | 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 :: Time -> Pattern a -> Pattern a -- | 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 -- | toMIDI p: converts a pattern of human-readable pitch names -- into MIDI pitch numbers. For example, "cs4" will be rendered -- as "49". Omitting the octave number will create a pitch in -- the fifth octave ("cf" -> "cf5"). Pitches can be -- decorated using: -- --