Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- type Time = Rational
- type Arc = (Time, Time)
- type Part = (Arc, Arc)
- type Event a = (Part, a)
- data State = State {
- arc :: Arc
- controls :: ControlMap
- type Query a = State -> [Event a]
- data Nature
- data Pattern a = Pattern {}
- data Value
- type ControlMap = Map String Value
- type ControlPattern = Pattern ControlMap
- (<*) :: Pattern (a -> b) -> Pattern a -> Pattern b
- (*>) :: Pattern (a -> b) -> Pattern a -> Pattern b
- unwrap :: Pattern (Pattern a) -> Pattern a
- innerJoin :: Pattern (Pattern a) -> Pattern a
- outerJoin :: Pattern (Pattern a) -> Pattern a
- unwrapSqueeze :: Pattern (Pattern a) -> Pattern a
- noOv :: String -> a
- class TolerantEq a where
- showPattern :: Show a => Arc -> Pattern a -> String
- prettyRat :: Rational -> String
- showFrac :: Integer -> Integer -> String
- empty :: Pattern a
- queryArc :: Pattern a -> Arc -> [Event a]
- eventWhole :: Event a -> Arc
- eventWholeOnset :: Event a -> Time
- eventPart :: Event a -> Arc
- eventValue :: Event a -> a
- eventHasOnset :: Event a -> Bool
- isDigital :: Pattern a -> Bool
- isAnalog :: Pattern a -> Bool
- arcCycles :: Arc -> [Arc]
- arcCyclesZW :: Arc -> [Arc]
- mapArc :: (Time -> Time) -> Arc -> Arc
- mapCycle :: (Time -> Time) -> Arc -> Arc
- splitQueries :: Pattern a -> Pattern a
- sam :: Time -> Time
- toTime :: Real a => a -> Rational
- nextSam :: Time -> Time
- cyclePos :: Time -> Time
- isIn :: Arc -> Time -> Bool
- onsetIn :: Arc -> Event a -> Bool
- subArc :: Arc -> Arc -> Maybe Arc
- timeToCycleArc :: Time -> Arc
- cyclesInArc :: Integral a => Arc -> [a]
- cycleArcsInArc :: Arc -> [Arc]
- withResultArc :: (Arc -> Arc) -> Pattern a -> Pattern a
- withResultTime :: (Time -> Time) -> Pattern a -> Pattern a
- withQueryArc :: (Arc -> Arc) -> Pattern a -> Pattern a
- withQueryTime :: (Time -> Time) -> Pattern a -> Pattern a
- withEvent :: (Event a -> Event b) -> Pattern a -> Pattern b
- withEvents :: ([Event a] -> [Event b]) -> Pattern a -> Pattern b
- withPart :: (Arc -> Arc) -> Pattern a -> Pattern a
- compareDefrag :: (Eq a, Ord a) => [Event a] -> [Event a] -> Bool
- defragParts :: Eq a => [Event a] -> [Event a]
- isAdjacent :: Eq a => Event a -> Event a -> Bool
- applyFIS :: (Double -> Double) -> (Int -> Int) -> (String -> String) -> Value -> Value
- fNum2 :: (Int -> Int -> Int) -> (Double -> Double -> Double) -> Value -> Value -> Value
- getI :: Value -> Maybe Int
- getF :: Value -> Maybe Double
- getS :: Value -> Maybe String
- __compress :: Arc -> Pattern a -> Pattern a
- __compressTo :: Arc -> Pattern a -> Pattern a
- _fastGap :: Time -> Pattern a -> Pattern a
- rotL :: Time -> Pattern a -> Pattern a
- rotR :: Time -> Pattern a -> Pattern a
- filterValues :: (a -> Bool) -> Pattern a -> Pattern a
- filterJust :: Pattern (Maybe a) -> Pattern a
- filterWhen :: (Time -> Bool) -> Pattern a -> Pattern a
- playFor :: Time -> Time -> Pattern a -> Pattern a
- tParam :: (a -> Pattern b -> Pattern c) -> Pattern a -> Pattern b -> Pattern c
- tParam2 :: (a -> b -> Pattern c -> Pattern d) -> Pattern a -> Pattern b -> Pattern c -> Pattern d
- tParam3 :: (a -> b -> c -> Pattern d -> Pattern e) -> Pattern a -> Pattern b -> Pattern c -> Pattern d -> Pattern e
- tParamSqueeze :: (a -> Pattern b -> Pattern c) -> Pattern a -> Pattern b -> Pattern c
Types
type Part = (Arc, Arc) Source #
The second arc (the part) should be equal to or fit inside the first one (the whole that it's a part of).
Also known as Continuous vs Discrete/Amorphous vs Pulsating etc.
A datatype that's basically a query, plus a hint about whether its events are Analogue or Digital by nature
Instances
Instances
type ControlPattern = Pattern ControlMap Source #
Instances
(<*) :: Pattern (a -> b) -> Pattern a -> Pattern b infixl 4 Source #
Like *, but the structure only comes from the left
(*>) :: Pattern (a -> b) -> Pattern a -> Pattern b infixl 4 Source #
Like *, but the structure only comes from the right
unwrap :: Pattern (Pattern a) -> Pattern a Source #
Turns a pattern of patterns into a single pattern.
(this is actually join
)
1/ For query arc
, get the events from the outer pattern pp
2/ Query the inner pattern using the part
of the outer
3/ For each inner event, set the whole and part to be the intersection
of the outer whole and part, respectively
4 Concatenate all the events together (discarding wholesparts that didn't intersect)
TODO - what if a continuous pattern contains a discrete one, or vice-versa?
innerJoin :: Pattern (Pattern a) -> Pattern a Source #
Turns a pattern of patterns into a single pattern. Like unwrap
,
but structure only comes from the inner pattern.
outerJoin :: Pattern (Pattern a) -> Pattern a Source #
Turns a pattern of patterns into a single pattern. Like unwrap
,
but structure only comes from the outer pattern.
unwrapSqueeze :: Pattern (Pattern a) -> Pattern a Source #
Like unwrap
, but cycles of the inner patterns are compressed to fit the
timespan of the outer whole (or the original query if it's a continuous pattern?)
TODO - what if a continuous pattern contains a discrete one, or vice-versa?
class TolerantEq a where Source #
Instances
TolerantEq ControlMap Source # | |
Defined in Sound.Tidal.Pattern (~==) :: ControlMap -> ControlMap -> Bool Source # | |
TolerantEq Value Source # | |
TolerantEq a => TolerantEq [a] Source # | |
Defined in Sound.Tidal.Pattern | |
TolerantEq (Event ControlMap) Source # | |
Defined in Sound.Tidal.Pattern (~==) :: Event ControlMap -> Event ControlMap -> Bool Source # |
Internal functions
eventWhole :: Event a -> Arc Source #
Get the timespan of an event's whole
eventWholeOnset :: Event a -> Time Source #
Get the onset of an event's whole
eventValue :: Event a -> a Source #
eventHasOnset :: Event a -> Bool Source #
arcCyclesZW :: Arc -> [Arc] Source #
Like arcCycles, but returns zero-width arcs
mapArc :: (Time -> Time) -> Arc -> Arc Source #
Map the given function over both the start and end Time
values
of the given Arc
.
mapCycle :: (Time -> Time) -> Arc -> Arc Source #
Similar to mapArc
but time is relative to the cycle (i.e. the
sam of the start of the arc)
splitQueries :: Pattern a -> Pattern a Source #
Splits queries that span cycles. For example `query 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.
toTime :: Real a => a -> Rational Source #
Turns a number into a (rational) time value. An alias for toRational
.
nextSam :: Time -> Time Source #
The end point of the current cycle (and starting point of the next cycle)
subArc :: Arc -> Arc -> Maybe Arc Source #
subArc i j
is the timespan that is the intersection of i
and j
.
The definition is a bit fiddly as results might be zero-width, but
not at the end of an non-zero-width arc - e.g. (0,1) and (1,2) do
not intersect, but (1,1) (1,1) does.
timeToCycleArc :: Time -> Arc Source #
The arc of the whole cycle that the given time value falls within
cyclesInArc :: Integral a => Arc -> [a] Source #
A list of cycle numbers which are included in the given arc
cycleArcsInArc :: Arc -> [Arc] Source #
A list of arcs of the whole cycles which are included in the given arc
withResultArc :: (Arc -> Arc) -> Pattern a -> Pattern a Source #
Apply a function to the arcs/timespans (both whole and parts) of the result
withResultTime :: (Time -> Time) -> Pattern a -> Pattern a Source #
Apply a function to the time (both start and end of the timespans of both whole and parts) of the result
withQueryArc :: (Arc -> Arc) -> Pattern a -> Pattern a Source #
Apply a function to the timespan of the query
withQueryTime :: (Time -> Time) -> Pattern a -> Pattern a Source #
Apply a function to the time (both start and end) of the query
withEvent :: (Event a -> Event b) -> Pattern a -> Pattern b Source #
withEvent f p
returns a new Pattern
with each event mapped over
function f
.
withEvents :: ([Event a] -> [Event b]) -> Pattern a -> Pattern b Source #
withEvent f p
returns a new Pattern
with f applied to the resulting list of events for each query
function f
.
withPart :: (Arc -> Arc) -> Pattern a -> Pattern a Source #
withPart f p
returns a new Pattern
with function f
applied
to the part.
compareDefrag :: (Eq a, Ord a) => [Event a] -> [Event a] -> Bool Source #
Compares two lists of events, attempting to combine fragmented events in the process
for a truer
compare
defragParts :: Eq a => [Event a] -> [Event a] Source #
Returns a list of events, with any adjacent parts of the same whole combined
isAdjacent :: Eq a => Event a -> Event a -> Bool Source #
Returns True
if the two given events are adjacent parts of the same whole
applyFIS :: (Double -> Double) -> (Int -> Int) -> (String -> String) -> Value -> Value Source #
Apply one of three functions to a Value, depending on its type
fNum2 :: (Int -> Int -> Int) -> (Double -> Double -> Double) -> Value -> Value -> Value Source #
Apply one of two functions to a Value, depending on its type (int or float; strings are ignored)
rotL :: Time -> Pattern a -> Pattern a Source #
Shifts a pattern back in time by the given amount, expressed in cycles
rotR :: Time -> Pattern a -> Pattern a Source #
Shifts a pattern forward in time by the given amount, expressed in cycles
Event filters
filterValues :: (a -> Bool) -> Pattern a -> Pattern a Source #
Remove events from patterns that to not meet the given test
Temporal parameter helpers
tParam2 :: (a -> b -> Pattern c -> Pattern d) -> Pattern a -> Pattern b -> Pattern c -> Pattern d Source #
tParam3 :: (a -> b -> c -> Pattern d -> Pattern e) -> Pattern a -> Pattern b -> Pattern c -> Pattern d -> Pattern e Source #