-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | a library for live coding and real-time musical applications -- -- Conductive is a set of Haskell packages for live coding and real-time -- music applications. One of its central purposes is controlling the -- timing of events. Conductive-base is the core library for the -- Conductive set of libraries. This library includes the play, pause, -- stop, and reset functions, as well as corresponding data types, -- MusicalEnvironment, Player, and TempoClock. @package conductive-base @version 0.3 module Sound.Conductive.MutableMap type MutableMap t t1 = TVar (Map t t1) newMMapSingleton :: Ord k => (k, a) -> IO (TVar (Map k a)) newMMap :: Ord k => [(k, a)] -> IO (TVar (Map k a)) withMMap :: TVar t -> (t -> b) -> IO b mapMMapIO_ :: TVar (Map k a) -> ((k, a) -> IO b) -> IO () modifyMMap :: TVar a -> (a -> a) -> IO () addVal :: Ord k => TVar (Map k a) -> (k, a) -> IO () addVals :: Ord k => TVar (Map k a) -> [(k, a)] -> IO () (+@) :: Ord k => TVar (Map k a) -> (k, a) -> IO () (?@) :: Ord k => TVar (Map k a) -> k -> IO (Maybe a) deleteVal :: Ord k => TVar (Map k a) -> k -> IO () (-@) :: Ord k => TVar (Map k a) -> k -> IO () copyVal :: Ord k => TVar (Map k a) -> k -> k -> IO () changeVal :: Ord k => TVar (Map k a) -> (k, a) -> IO () changeKey :: Ord k => TVar (Map k a) -> k -> k -> IO () keys :: TVar (Map k a) -> IO [k] elems :: TVar (Map k a) -> IO [a] withKey :: Ord k => TVar (Map k t) -> (t -> a) -> k -> IO (Maybe a) withKeys :: Ord a => TVar (Map a t) -> (t -> a1) -> [a] -> IO [Maybe a1] withKeys_ :: Ord a => TVar (Map a t) -> (t -> a1) -> [a] -> IO () toMap :: TVar a -> IO a module Sound.Conductive.ConductiveBaseData -- | a data type for traditional musical time data MusicalTime MusicalTime :: Int -> Double -> MusicalTime measure :: MusicalTime -> Int beat :: MusicalTime -> Double -- | a data type for describing a tempo and when it began data TempoChange TempoChange :: Double -> Double -> Double -> TempoChange newTempo :: TempoChange -> Double beatOfTempoChange :: TempoChange -> Double timeOfTempoChange :: TempoChange -> Double -- | a data type describing a time signature and when it began. A time -- signature is specified as number of beats per measure. data TimeSignature TimeSignature :: Int -> Double -> Int -> TimeSignature startingMeasure :: TimeSignature -> Int startingBeat :: TimeSignature -> Double timeSignature :: TimeSignature -> Int -- | for Players, the key time-related data type data TempoClock TempoClock :: Double -> [TempoChange] -> [TimeSignature] -> TempoClock startTime :: TempoClock -> Double tempoChanges :: TempoClock -> [TempoChange] timeSignatureChanges :: TempoClock -> [TimeSignature] -- | Players, TempoClocks, etc. are stored here. data MusicalEnvironment MusicalEnvironment :: String -> MutableMap String Player -> MutableMap String TempoClock -> MutableMap String (MusicalEnvironment -> Player -> Double -> Double -> IO Double) -> MutableMap String (MusicalEnvironment -> Player -> Double -> Double -> IO ()) -> MutableMap String ([IO ()]) -> MusicalEnvironment environmentName :: MusicalEnvironment -> String playerStore :: MusicalEnvironment -> MutableMap String Player tempoClockStore :: MusicalEnvironment -> MutableMap String TempoClock iOIStore :: MusicalEnvironment -> MutableMap String (MusicalEnvironment -> Player -> Double -> Double -> IO Double) actionStore :: MusicalEnvironment -> MutableMap String (MusicalEnvironment -> Player -> Double -> Double -> IO ()) interruptStore :: MusicalEnvironment -> MutableMap String ([IO ()]) -- | a data type used by the play function and useful when displaying -- running players data PlayerStatus Stopped :: PlayerStatus Playing :: PlayerStatus Pausing :: PlayerStatus Paused :: PlayerStatus Stopping :: PlayerStatus Resetting :: PlayerStatus -- | Players are played using the play functions. data Player Player :: String -> PlayerStatus -> Integer -> String -> String -> String -> String -> Double -> Double -> Double -> Player playerName :: Player -> String playerStatus :: Player -> PlayerStatus playerCounter :: Player -> Integer playerClock :: Player -> String playerIOI :: Player -> String playerAction :: Player -> String playerInterrupt :: Player -> String playerBeat :: Player -> Double playerStartingBeat :: Player -> Double playerPauseTime :: Player -> Double instance Show MusicalTime instance Show TempoChange instance Show TimeSignature instance Show TempoClock instance Eq PlayerStatus instance Show PlayerStatus instance Show Player instance Show MusicalEnvironment -- | This is a module for functions concerned with time and its use in -- music. module Sound.Conductive.MusicalTime -- | a function which displays a musical time with beats to three decimal -- places, as it's more readable that way... displayMusicalTime :: MusicalTime -> [Char] -- | a cast from POSIX time to a Double currentTime :: IO Double -- | returns the latest (current) tempo change (not tempo) of a clock lastTempoChange :: TempoClock -> TempoChange -- | returns the latest (may not be current) time signature change (not -- timesignature) of a clock lastTimeSignatureChange :: TempoClock -> TimeSignature -- | returns the latest (current) tempo of a clock currentTempo :: TempoClock -> Double -- | returns the current (may not be latest) time signature change of a -- clock currentTimeSignatureChange :: TempoClock -> IO TimeSignature -- | returns the current time signature of a clock currentTimeSignature :: TempoClock -> IO Int -- | returns the time elapsed since the start time of a given clock elapsedTime :: TempoClock -> IO Double -- | returns the time elapsed since the last tempo change timeSinceTempoChange :: TempoClock -> IO Double -- | converts a list of relative time deltas to a list of absolute times -- starting from the given time (first argument) deltasToAbsolutes :: Num a => a -> [a] -> [a] -- | converts a list of relative time deltas to a list of absolute times absolutesToDeltas :: Num a => [a] -> [a] -- | converts a time delta (first argument) to a length specified in beats -- based on the given tempo (second argument) deltaToBeats :: Fractional a => a -> a -> a beatsToDelta' :: Fractional a => a -> a -> a -- | converts a time delta specified in beats (second argument) to one in -- seconds based on the given clock (first argument) beatsToDelta :: TempoClock -> Double -> Double -- | when given a clock, returns the current beat currentBeat :: TempoClock -> IO Double -- | an alias for currentBeat elapsedBeats :: TempoClock -> IO Double -- | when given a clock, returns the current measure currentMeasure :: TempoClock -> IO Int -- | when given a clock, returns the current MusicalTime currentMusicalTime :: TempoClock -> IO MusicalTime -- | shows the elapsed time in terms of a MusicalTime elapsedMusicalTime :: TempoClock -> IO MusicalTime -- | returns the time as a more human-readable string version of -- MusicalTime currentMusicalTime2 :: TempoClock -> IO [Char] -- | given a TempoClock and a new tempo, adds a TempoChange to it and -- returns a new clock changeTempo :: TempoClock -> Double -> IO TempoClock -- | given a TempoClock and a new time signature, adds a -- TimeSignatureChange and returns a new TempoClock. Changing the time -- signature takes effect in the next measure after the current one. changeTimeSignature :: TempoClock -> Int -> IO TempoClock -- | converts a string with the time, written as -- measure.beat.decimalFractionOfABeat, to a MusicalTime. -- -- For example, 2.2.5 converts to MusicalTime { measure = 2, beat -- = 2.5 }. timeStringToMusicalTime :: [Char] -> MusicalTime -- | a cast from MusicalTime to beats musicalTimeToBeats :: TempoClock -> MusicalTime -> Double module Sound.Conductive.MusicalEnvironment -- | returns a list of the names of all Players stored in a -- MusicalEnvironment players :: MusicalEnvironment -> IO [String] -- | returns a list of the names of all TempoClocks stored in a -- MusicalEnvironment tempoClocks :: MusicalEnvironment -> IO [String] -- | returns a list of the names of all IOI functions stored in a -- MusicalEnvironment iOIs :: MusicalEnvironment -> IO [String] -- | returns a list of the names of all action functions stored in a -- MusicalEnvironment actions :: MusicalEnvironment -> IO [String] -- | returns a list of the names of all interrupt functions stored in a -- MusicalEnvironment interrupts :: MusicalEnvironment -> IO [String] withPlayer :: MusicalEnvironment -> (Player -> a) -> String -> IO (Maybe a) withTempoClock :: MusicalEnvironment -> (TempoClock -> a) -> String -> IO (Maybe a) withIOI :: MusicalEnvironment -> ((MusicalEnvironment -> Player -> Double -> Double -> IO Double) -> a) -> String -> IO (Maybe a) withAction :: MusicalEnvironment -> ((MusicalEnvironment -> Player -> Double -> Double -> IO ()) -> a) -> String -> IO (Maybe a) withInterrupt :: MusicalEnvironment -> ([IO ()] -> a) -> String -> IO (Maybe a) eChangeTempo :: MusicalEnvironment -> String -> Double -> IO () eChangeTimeSignature :: MusicalEnvironment -> String -> Int -> IO () module Sound.Conductive.MiscListUtils unconcat :: [t] -> [[t]] getSeed :: IO Integer slice :: [a] -> [Int] -> [a] replaceAt :: Int -> [a] -> [a] -> [a] npletAt :: Fractional a => Int -> Int -> [a] -> [a] joinVals :: Num a => Int -> Int -> [a] -> [a] stutter :: Int -> Int -> Int -> [a] -> [a] diff_select :: Int -> Int -> IO [Int] diff_select' :: (Eq a, Num a) => a -> [a1] -> IO [a1] randomSubset :: [b] -> Int -> IO [b] -- | Randomly shuffle a list without the IO Monad O(N) ??? -- where -- did I get this function from? I didn't write it... shuffle' :: [a] -> StdGen -> ([a], StdGen) shuffle :: [a] -> IO [a] rotate :: [a] -> Int -> [a] lace :: [[a]] -> Int -> [a] randomList :: Int -> StdGen -> [Int] normalize :: (Fractional b, Ord b) => [b] -> [b] normalizeTo :: (Fractional b, Ord b) => b -> [b] -> [b] lerp :: Fractional a => (a, a) -> (a, a) -> a -> a rList :: Int -> IO [Int] pick :: [a] -> IO a pick' :: (Eq t, Num t, Random t) => a -> [a] -> t -> IO a pickN :: (Num a, Enum a) => a -> [b] -> IO [b] coin :: IO Bool odds :: Int -> Int -> IO Bool replicator :: [(Int, b)] -> [b] weightedList :: [(Int, b)] -> [b] takeToValue' :: (Ord a, Num a) => [a] -> a -> a -> [a] -> [a] takeToValue :: (Num a, Ord a) => a -> [a] -> [a] -- | This is a collection of functions which are useful for dealing with -- Players. module Sound.Conductive.Player -- | Displays information about a single player. displayPlayer :: MusicalEnvironment -> String -> IO () -- | Creates a thread delay specified in seconds. sleep :: RealFrac a => a -> IO () -- | Creates a new player. newPlayer :: String -> String -> String -> String -> Double -> Player -- | Used to change a player stored in a MusicalEnvironment. modifyPlayer :: MusicalEnvironment -> String -> (Player -> Player) -> IO () withPlayers :: MusicalEnvironment -> (Player -> a1) -> [String] -> IO [Maybe a1] -- | Change the name of a player from old (second argument) to new (third -- argument). swapName :: MusicalEnvironment -> String -> String -> IO () -- | Change the status of a player. swapStatus :: MusicalEnvironment -> String -> PlayerStatus -> IO () -- | Change the IOI function of a player (second argument) from old IOI -- function to new one (third argument). swapIOI :: MusicalEnvironment -> String -> String -> IO () -- | Change the counter value of a player. swapCounter :: MusicalEnvironment -> String -> Integer -> IO () -- | Change the clock a player is following from old (second argument) to -- new (third argument). swapClock :: MusicalEnvironment -> String -> String -> IO () -- | Change the action function of a player from old (second argument) to -- new (third argument). swapActions :: MusicalEnvironment -> String -> String -> IO () -- | Change the interrupt function of a player from old (second argument) -- to new (third argument). swapInterrupt :: MusicalEnvironment -> String -> String -> IO () -- | Change the beat of the next event of a player. swapBeat :: MusicalEnvironment -> String -> Double -> IO () -- | Change the time of the last pause of a player. swapPauseTime :: MusicalEnvironment -> String -> Double -> IO () -- | Plays a player, specified by the string, from a MusicalEnvironment. -- The start time is determined by the playerBeat field of the player. play :: MusicalEnvironment -> String -> IO () -- | Plays a player, specified by the string, from a MusicalEnvironment. -- The start time is given in beats as the first argument (the Double), -- from which the player automatically adjusts the playerBeat record. playAt :: Double -> MusicalEnvironment -> String -> IO () -- | Plays a player, specified by the string, from a MusicalEnvironment. -- The start time is given as a time string as the first argument (the -- Double), from which the player automatically adjusts the playerBeat -- record. Time strings are specified in the MusicalTime module. playAtTimeString :: [Char] -> MusicalEnvironment -> String -> IO () playNow :: MusicalEnvironment -> String -> IO () playAtStartOfNMeasure :: MusicalEnvironment -> Int -> String -> IO () basicPlay :: MusicalEnvironment -> String -> PlayerStatus -> IO () -- | Pauses the specified player. pause :: MusicalEnvironment -> String -> IO () -- | Stops the specified player. Doing so resets both the playerBeat and -- playerCounter to 0. stop :: MusicalEnvironment -> String -> IO () -- | Resets a paused player. Resetting means setting the playerBeat and -- playerCounter to 0. reset :: MusicalEnvironment -> String -> IO () playN :: MusicalEnvironment -> [String] -> IO () playAll :: MusicalEnvironment -> IO () pauseN :: MusicalEnvironment -> [String] -> IO () pauseAll :: MusicalEnvironment -> IO () stopN :: MusicalEnvironment -> [String] -> IO () stopAll :: MusicalEnvironment -> IO () resetN :: MusicalEnvironment -> [String] -> IO () resetAll :: MusicalEnvironment -> IO () -- | Used for setting up the playerStore of a MusicalEnvironment. It -- automatically creates one player according to the arguments it is -- given. newPlayerStore :: (String, (String, String, String, Double)) -> IO (TVar (Map String Player)) -- | Creates a new player from the given arguments and adds it to the -- MusicalEnvironment. addNewPlayer :: MusicalEnvironment -> (String, (String, String, String, Double)) -> IO () module Sound.Conductive.ConductiveDefaults defaultPlayerStore :: IO (TVar (Map String Player)) defaultTempoClock :: IO TempoClock defaultTempoClockStore :: IO (TVar (Map [Char] TempoClock)) defaultActionStore :: IO (TVar (Map [Char] (t -> t1 -> t2 -> t3 -> IO ()))) defaultIOIStore :: IO (TVar (Map [Char] a)) defaultInterruptStore :: IO (TVar (Map [Char] [IO ()])) defaultMusicalEnvironment :: IO MusicalEnvironment module Sound.Conductive.Table asciiTable :: [[Char]] -> [Char] -> [[[Char]]] -> [Char] -> IO () -- | Uses the asciiTablefunction to create a five-column table of -- information about players in a MusicalEnvironment. That information is -- the player name, its status, the clock it follows, and the action and -- IOI function it uses when played. displayPlayers :: MusicalEnvironment -> IO ()