-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | a library for livecoding and real-time musical applications -- -- Conductive is a set of Haskell libraries for livecoding and real-time -- music applications. The biggest immediate challenge in using Haskell -- for computer music was controlling the exact timing of events in a -- manner similar to that of the Task and Routine functions andPatterns -- library in SuperCollider. This library is intended to supply such -- facilities. This library wraps concurrent process manipulation in a -- way that makes controlling their timing more intuitive for musicians. -- At the same time, the library aims at being as concise as possible to -- lessen the burden on the user. Conductive-base is the core library for -- the Conductive set of libraries. This library includes the useful -- play, pause, stop, and reset functions, as well as corresponding data -- types, MusicalEnvironment, Player, and TempoClock. @package conductive-base @version 0.2 -- | These functions were found to be useful for dealing with MVars. For -- more on MVars, see -- http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-Concurrent-MVar.html. module Sound.Conductive.MVarUtils -- | Applies a pure function to the value stored in an MVar. wm :: MVar a -> (a -> a1) -> IO a1 -- | Applies an IO function to the value stored in an MVar. wIOm :: MVar a -> (a -> IO b) -> IO b -- | Changes the value stored in an MVar based on a pure function. wcm :: MVar a -> (a -> a) -> IO a -- | An alias for the wcm function. withChangeToMVar :: MVar a -> (a -> a) -> IO a module Sound.Conductive.ConductiveBaseData data Generator a Generator :: MVar [a] -> IORef Int -> IORef Int -> Generator a generatorSource :: Generator a -> MVar [a] sourceLength :: Generator a -> IORef Int generatorCounter :: Generator a -> IORef Int -- | 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 -> Map String Player -> Map String TempoClock -> Map String (MVar MusicalEnvironment -> Player -> IO Double) -> Map String (MVar MusicalEnvironment -> Player -> IO ()) -> Map String ([IO ()]) -> Map String (Generator Double) -> Map String [Double] -> MusicalEnvironment environmentName :: MusicalEnvironment -> String playerStore :: MusicalEnvironment -> Map String Player tempoClockStore :: MusicalEnvironment -> Map String TempoClock iOIStore :: MusicalEnvironment -> Map String (MVar MusicalEnvironment -> Player -> IO Double) actionStore :: MusicalEnvironment -> Map String (MVar MusicalEnvironment -> Player -> IO ()) interruptStore :: MusicalEnvironment -> Map String ([IO ()]) doubleGeneratorStore :: MusicalEnvironment -> Map String (Generator Double) iOIListStore :: MusicalEnvironment -> Map String [Double] -- | 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 Player instance Eq PlayerStatus instance Show PlayerStatus instance Show TempoClock instance Show TimeSignature instance Show TempoChange instance Show MusicalTime instance Show MusicalEnvironment -- | This is a module for creating and manipulating mutable generators. -- Generators contain a source finite list and a counter. Items are -- retrieved from the list one at a time, and the list loops when the -- last item has been given. module Sound.Conductive.Generator -- | creates a new Generator from the given source list. newGenerator :: [a] -> IO (Generator a) -- | swaps the source of a Generator swapGenerator :: Generator a -> [a] -> IO [a] newCounter :: IO (IORef Int) -- | returns the current value of a counter in a Generator getCount :: Generator a -> IO Int -- | returns the source of a Generator getGeneratorSource :: Generator a -> IO [a] -- | resets the counter of a Generator resetCounter :: Generator a -> IO () -- | returns the next item from a Generator next :: Generator a -> IO a -- | adds the first argument to the counter value of a Generator and -- returns the corresponding item from the source nextWithOffset :: Int -> Generator a -> IO a -- | given a list of Generators, returns a list containing the next item -- from all of them nexts :: [Generator b] -> IO [b] -- | runs a pure function on the next item from a Generator withNext :: Generator a -> (a -> b) -> IO b -- | creates a Map for storing Generators in newGeneratorStore :: Ord t => (t, [a]) -> IO (Map t (Generator a)) -- | the defaultGeneratorStore used by the defaultMusicalEnvironment defaultGeneratorStore :: IO (Map [Char] (Generator Double)) -- | 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 action functions stored in a -- MusicalEnvironment actions :: MVar MusicalEnvironment -> IO [String] -- | Add an action function to a MusicalEnvironment in an MVar addAction :: MVar MusicalEnvironment -> (String, MVar MusicalEnvironment -> Player -> IO ()) -> IO MusicalEnvironment -- | Add a double Generator to a MusicalEnvironment in an MVar addDoubleGenerator :: MVar MusicalEnvironment -> (String, Generator Double) -> IO MusicalEnvironment -- | Add an IOI function to a MusicalEnvironment in an MVar addIOI :: MVar MusicalEnvironment -> (String, MVar MusicalEnvironment -> Player -> IO Double) -> IO MusicalEnvironment -- | Add an IOI list to a MusicalEnvironment in an MVar addIOIList :: MVar MusicalEnvironment -> (String, [Double]) -> IO MusicalEnvironment -- | Add an interrupt function to a MusicalEnvironment in an MVar addInterrupt :: MVar MusicalEnvironment -> (String, [IO ()]) -> IO MusicalEnvironment -- | Add a double Generator to a MusicalEnvironment in an MVar addNewGenerator :: MVar MusicalEnvironment -> (String, [Double]) -> IO MusicalEnvironment -- | Add a Player to a MusicalEnvironment in an MVar addPlayer :: MVar MusicalEnvironment -> (String, Player) -> IO MusicalEnvironment -- | Add a TempoClock to a MusicalEnvironment in an MVar addTempoClock :: MVar MusicalEnvironment -> (String, TempoClock) -> IO MusicalEnvironment -- | runs a pure function on the Map in a MusicalEnvironment containing the -- action functions changeActions :: (Map String (MVar MusicalEnvironment -> Player -> IO ()) -> Map String (MVar MusicalEnvironment -> Player -> IO ())) -> MusicalEnvironment -> MusicalEnvironment -- | runs a pure function on the Map in a MusicalEnvironment containing the -- double Generators changeDoubleGenerators :: (Map String (Generator Double) -> Map String (Generator Double)) -> MusicalEnvironment -> MusicalEnvironment -- | used to update a MusicalEnvironment stored in an MVar changeEnvironment :: MVar a -> (a -> a) -> IO a -- | runs a pure function on the Map in a MusicalEnvironment containing the -- IOI lists changeIOILists :: (Map String [Double] -> Map String [Double]) -> MusicalEnvironment -> MusicalEnvironment -- | runs a pure function on the Map in a MusicalEnvironment containing the -- IOI functions changeIOIs :: (Map String (MVar MusicalEnvironment -> Player -> IO Double) -> Map String (MVar MusicalEnvironment -> Player -> IO Double)) -> MusicalEnvironment -> MusicalEnvironment -- | runs a pure function on the Map in a MusicalEnvironment containing the -- interrupt functions changeInterrupts :: (Map String [IO ()] -> Map String [IO ()]) -> MusicalEnvironment -> MusicalEnvironment -- | runs a pure function on the Map in a MusicalEnvironment containing the -- Players changePlayers :: (Map String Player -> Map String Player) -> MusicalEnvironment -> MusicalEnvironment -- | runs a pure function on the Map in a MusicalEnvironment containing the -- TempoClocks changeTempoClocks :: (Map String TempoClock -> Map String TempoClock) -> MusicalEnvironment -> MusicalEnvironment -- | Delete an action function from a MusicalEnvironment in an MVar deleteAction :: MVar MusicalEnvironment -> String -> IO MusicalEnvironment -- | Delete a double Generator from a MusicalEnvironment in an MVar deleteDoubleGenerator :: MVar MusicalEnvironment -> String -> IO MusicalEnvironment -- | Delete an IOI function from a MusicalEnvironment in an MVar deleteIOI :: MVar MusicalEnvironment -> String -> IO MusicalEnvironment -- | Delete an IOI list from a MusicalEnvironment in an MVar deleteIOIList :: MVar MusicalEnvironment -> String -> IO MusicalEnvironment -- | Delete an interrupt function from a MusicalEnvironment in an MVar deleteInterrupt :: MVar MusicalEnvironment -> String -> IO MusicalEnvironment -- | Delete a Player to a MusicalEnvironment in an MVar deletePlayer :: MVar MusicalEnvironment -> String -> IO MusicalEnvironment -- | Delete a Tempo Clock from a MusicalEnvironment in an MVar deleteTempoClock :: MVar MusicalEnvironment -> String -> IO MusicalEnvironment -- | returns a list of the names of all double Generators stored in a -- MusicalEnvironment doubleGenerators :: MVar MusicalEnvironment -> IO [String] -- | convenience function for changing the current Tempo of a stored -- TempoClock eChangeTempo :: MVar MusicalEnvironment -> String -> Double -> IO MusicalEnvironment -- | convenience function for changing the current TimeSignature of a -- stored TempoClock eChangeTimeSignature :: MVar MusicalEnvironment -> String -> Int -> IO MusicalEnvironment -- | convenience function for returning the current Tempo from a stored -- TempoClock eCurrentTempo :: MVar MusicalEnvironment -> String -> IO Double -- | convenience function for returning the current TimeSignature from a -- stored TempoClock eCurrentTimeSignature :: MVar MusicalEnvironment -> String -> IO Int -- | convenience function for returning elapsed beats from a stored -- TempoClock eElapsedBeats :: MVar MusicalEnvironment -> String -> IO Double -- | convenience function for returning elapsed time from a stored -- TempoClock eElapsedTime :: MVar MusicalEnvironment -> String -> IO Double -- | returns an action function from a MusicalEnvironment in an MVar getAction :: MVar MusicalEnvironment -> String -> IO (MVar MusicalEnvironment -> Player -> IO ()) -- | convenience function for returning elapsed MusicalTime from a stored -- TempoClock getCurrentTime :: MVar MusicalEnvironment -> String -> IO MusicalTime -- | returns a double Generator from a MusicalEnvironment in an MVar getDoubleGenerator :: MVar MusicalEnvironment -> String -> IO (Generator Double) -- | returns an IOI function from a MusicalEnvironment in an MVar getIOI :: MVar MusicalEnvironment -> String -> IO (MVar MusicalEnvironment -> Player -> IO Double) -- | returns an IOI list from a MusicalEnvironment in an MVar getIOIList :: MVar MusicalEnvironment -> String -> IO [Double] -- | returns an interrupt function from a MusicalEnvironment in an MVar getInterrupt :: MVar MusicalEnvironment -> String -> IO [IO ()] -- | returns a Player from a MusicalEnvironment in an MVar getPlayer :: MVar MusicalEnvironment -> String -> IO Player -- | returns a TempoClock from a MusicalEnvironment in an MVar getTempoClock :: MVar MusicalEnvironment -> String -> IO TempoClock -- | returns a list of the names of all IOI functions stored in a -- MusicalEnvironment iOIs :: MVar MusicalEnvironment -> IO [String] -- | returns a list of the names of all IOI lists stored in a -- MusicalEnvironment iOILists :: MVar MusicalEnvironment -> IO [String] -- | returns a list of the names of all interrupt functions stored in a -- MusicalEnvironment interrupts :: MVar MusicalEnvironment -> IO [String] -- | returns a list of the names of all Players stored in a -- MusicalEnvironment players :: MVar MusicalEnvironment -> IO [String] -- | convenience function for returning elapsed MusicalTime as a string -- from a stored TempoClock showCurrentTime :: MVar MusicalEnvironment -> String -> IO [Char] -- | returns a list of the names of all TempoClocks stored in a -- MusicalEnvironment tempoClocks :: MVar MusicalEnvironment -> IO [String] -- | runs a pure function on a stored action function withAction :: ((MVar MusicalEnvironment -> Player -> IO ()) -> IO b) -> MVar MusicalEnvironment -> String -> IO b -- | runs a pure function on a stored double Generator withDoubleGenerator :: (Generator Double -> IO b) -> MVar MusicalEnvironment -> String -> IO b -- | allows a pure function to be run on a MusicalEnvironment stored in an -- MVar withEnvironment :: MVar a -> (a -> a1) -> IO a1 -- | runs a pure function on a stored IOI function withIOI :: ((MVar MusicalEnvironment -> Player -> IO Double) -> IO b) -> MVar MusicalEnvironment -> String -> IO b -- | runs a pure function on a stored IOI List withIOIList :: ([Double] -> IO b) -> MVar MusicalEnvironment -> String -> IO b -- | runs a pure function on a stored interrupt function withInterrupt :: ([IO ()] -> IO b) -> MVar MusicalEnvironment -> String -> IO b -- | runs a pure function on a stored Player withPlayer :: (Player -> IO b) -> MVar MusicalEnvironment -> String -> IO b -- | runs a pure function on a stored TempoClock withTempoClock :: (TempoClock -> IO b) -> MVar MusicalEnvironment -> String -> IO b -- | This is a collection of functions which are useful for dealing with -- Players. The Player data type is in the MusicalEnvironment module. module Sound.Conductive.Player -- | Creates a new player from the given arguments and adds it to the -- MusicalEnvironment. addNewPlayer :: MVar MusicalEnvironment -> (String, (String, String, String, Double)) -> IO MusicalEnvironment -- | Displays information about a single player. displayPlayer :: MVar MusicalEnvironment -> String -> IO () -- | Used to change a player stored in a MusicalEnvironment. modifyPlayer :: MVar MusicalEnvironment -> String -> (Player -> Player) -> IO MusicalEnvironment -- | Creates a new player. newPlayer :: String -> String -> String -> String -> Double -> Player -- | 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)) -> Map String Player -- | Pauses the specified player. pause :: MVar MusicalEnvironment -> String -> IO () pauseN :: MVar MusicalEnvironment -> [String] -> IO () pauseAll :: MVar MusicalEnvironment -> IO () -- | Plays a player, specified by the string, from a MusicalEnvironment. -- The start time is determined by the playerBeat field of the player. play :: MVar MusicalEnvironment -> String -> IO () playN :: MVar MusicalEnvironment -> [String] -> IO () playAll :: MVar MusicalEnvironment -> 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 -> MVar MusicalEnvironment -> String -> IO () playNAt :: MVar MusicalEnvironment -> [Char] -> [String] -> IO () playAllAt :: MVar MusicalEnvironment -> [Char] -> 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] -> MVar MusicalEnvironment -> String -> IO () -- | Resets a paused player. Resetting means setting the playerBeat and -- playerCounter to 0. reset :: MVar MusicalEnvironment -> String -> IO () resetN :: MVar MusicalEnvironment -> [String] -> IO () resetAll :: MVar MusicalEnvironment -> IO () -- | Creates a thread delay specified in seconds. sleep :: RealFrac a => a -> IO () -- | Stops the specified player. Doing so resets both the playerBeat and -- playerCounter to 0. stop :: MVar MusicalEnvironment -> String -> IO () stopN :: MVar MusicalEnvironment -> [String] -> IO () stopAll :: MVar MusicalEnvironment -> IO () -- | Change the action function of a player from old (second argument) to -- new (third argument). swapActions :: MVar MusicalEnvironment -> String -> String -> IO MusicalEnvironment -- | Change the beat of the next event of a player. swapBeat :: MVar MusicalEnvironment -> String -> Double -> IO MusicalEnvironment -- | Change the clock a player is following from old (second argument) to -- new (third argument). swapClock :: MVar MusicalEnvironment -> String -> String -> IO MusicalEnvironment -- | Change the counter value of a player. swapCounter :: MVar MusicalEnvironment -> String -> Integer -> IO MusicalEnvironment -- | Change the IOI function of a player from old (second argument) to new -- (third argument). swapIOI :: MVar MusicalEnvironment -> String -> String -> IO MusicalEnvironment -- | Change the interrupt function of a player from old (second argument) -- to new (third argument). swapInterrupt :: MVar MusicalEnvironment -> String -> String -> IO MusicalEnvironment -- | Change the name of a player from old (second argument) to new (third -- argument). swapName :: MVar MusicalEnvironment -> String -> String -> IO MusicalEnvironment -- | Change the time of the last pause of a player. swapPauseTime :: MVar MusicalEnvironment -> String -> Double -> IO MusicalEnvironment -- | Change the status of a player. swapStatus :: MVar MusicalEnvironment -> String -> PlayerStatus -> IO MusicalEnvironment timeDiff :: TempoClock -> Double -> IO Double -- | This module contains functions related to IOI functions and IOI lists. module Sound.Conductive.IOI -- | Creates an infinite length list from a start time and a finite list of -- relative time deltas makeIOIList :: Num a => a -> [a] -> [a] -- | An IOI function which gets an IOI from an IOI list iOIFromList :: MVar MusicalEnvironment -> Player -> String -> IO Double -- | Creates an IOI list, adds it to the environment, and adds a lookup -- function for it to the MusicalEnvironment. newIOIFunctionAndIOIList :: MVar MusicalEnvironment -> String -> Double -> [Double] -> IO MusicalEnvironment module Sound.Conductive.ConductiveDefaults defaultPlayerStore :: Map String Player defaultTempoClock :: IO TempoClock defaultTempoClockStore :: IO (Map [Char] TempoClock) defaultActionStore :: Map [Char] (t -> t1 -> IO ()) defaultIOI :: MVar MusicalEnvironment -> Player -> IO Double defaultIOIStore :: Map [Char] (MVar MusicalEnvironment -> Player -> IO Double) defaultInterruptStore :: Map [Char] [IO ()] defaultIOIListStore :: Map [Char] [Double] defaultMusicalEnvironment :: IO (MVar MusicalEnvironment) module Sound.Conductive.Table -- | This function creates a text table suitable for printing in ghci or -- the terminal. -- -- For example: -- -- asciiTable [this,is,a,test] = -- [[hi,hi,hi,hi],[a,a,a,a],[m,m,m,m],[k,k,k,k]] -- -- --
--   this   is   a   test
--   ====   ==   =   ====
--   hi     a    m   k   
--   hi     a    m   k   
--   hi     a    m   k   
--   hi     a    m   k   
--   
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 :: MVar MusicalEnvironment -> IO () module Sound.Conductive.ConductiveBase