-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Ableton Link integration for Tidal
--   
--   Ableton Link integration for Tidal, to let Tidal sync with external
--   clocks
@package tidal-link
@version 1.2.0

module Sound.Tidal.Link
data AbletonLinkImpl
data SessionStateImpl
newtype AbletonLink
AbletonLink :: Ptr AbletonLinkImpl -> AbletonLink
newtype SessionState
SessionState :: Ptr SessionStateImpl -> SessionState
type Beat = CDouble
type BPM = CDouble
type Micros = Int64
type Quantum = CDouble
create :: BPM -> IO AbletonLink
abl_link_enable :: AbletonLink -> CBool -> IO ()
setEnabled :: Bool -> AbletonLink -> IO ()
enable :: AbletonLink -> IO ()
disable :: AbletonLink -> IO ()
createSessionState :: IO SessionState
captureAppSessionState :: AbletonLink -> SessionState -> IO ()
createAndCaptureAppSessionState :: AbletonLink -> IO SessionState
commitAppSessionState :: AbletonLink -> SessionState -> IO ()
destroySessionState :: SessionState -> IO ()
commitAndDestroyAppSessionState :: AbletonLink -> SessionState -> IO ()
clock :: AbletonLink -> IO Micros
beatAtTime :: SessionState -> Micros -> Quantum -> IO Beat
timeAtBeat :: SessionState -> Beat -> Quantum -> IO Micros
getTempo :: SessionState -> IO BPM
setTempo :: SessionState -> BPM -> Micros -> IO ()
requestBeatAtTime :: SessionState -> Beat -> Micros -> Quantum -> IO ()
forceBeatAtTime :: SessionState -> Beat -> Micros -> Quantum -> IO ()

-- | Test
hello :: IO ()
instance GHC.Internal.Show.Show Sound.Tidal.Link.AbletonLink
instance GHC.Internal.Show.Show Sound.Tidal.Link.SessionState
instance GHC.Internal.Foreign.Storable.Storable Sound.Tidal.Link.AbletonLink
instance GHC.Internal.Foreign.Storable.Storable Sound.Tidal.Link.SessionState

module Sound.Tidal.Clock
type Time = Rational

-- | representation of a tick based clock
type Clock = ReaderT ClockMemory StateT ClockState IO

-- | internal read-only memory of the clock
data ClockMemory
ClockMemory :: ClockConfig -> ClockRef -> TickAction -> ClockMemory
[clockConfig] :: ClockMemory -> ClockConfig
[clockRef] :: ClockMemory -> ClockRef
[clockAction] :: ClockMemory -> TickAction

-- | internal mutable state of the clock
data ClockState
ClockState :: Int64 -> Micros -> (Time, Time) -> Double -> ClockState
[ticks] :: ClockState -> Int64
[start] :: ClockState -> Micros
[nowArc] :: ClockState -> (Time, Time)
[nudged] :: ClockState -> Double

-- | reference to interact with the clock, while it is running
data ClockRef
ClockRef :: TVar ClockAction -> AbletonLink -> ClockRef
[rAction] :: ClockRef -> TVar ClockAction
[rAbletonLink] :: ClockRef -> AbletonLink

-- | configuration of the clock
data ClockConfig
ClockConfig :: CDouble -> CDouble -> Double -> Bool -> Int64 -> Double -> ClockConfig
[clockQuantum] :: ClockConfig -> CDouble
[clockBeatsPerCycle] :: ClockConfig -> CDouble
[clockFrameTimespan] :: ClockConfig -> Double
[clockEnableLink] :: ClockConfig -> Bool
[clockSkipTicks] :: ClockConfig -> Int64
[clockProcessAhead] :: ClockConfig -> Double

-- | action to be executed on a tick, | given the current timespan, nudge
--   and reference to the clock
type TickAction = (Time, Time) -> Double -> ClockConfig -> ClockRef -> (SessionState, SessionState) -> IO ()

-- | possible actions for interacting with the clock
data ClockAction
NoAction :: ClockAction
SetCycle :: Time -> ClockAction
SetTempo :: Time -> ClockAction
SetNudge :: Double -> ClockAction
defaultCps :: Double
defaultConfig :: ClockConfig

-- | creates a clock according to the config and runs it | in a seperate
--   thread
clocked :: ClockConfig -> TickAction -> IO ClockRef

-- | runs the clock on the initial state and memory as given | by
--   initClock, hands the ClockRef for interaction from outside
runClock :: ClockConfig -> TickAction -> Clock () -> IO ClockRef

-- | creates a ableton link instance and an MVar for interacting | with the
--   clock from outside and computes the initial clock state
initClock :: ClockConfig -> TickAction -> IO (ClockMemory, ClockState)
clockCheck :: Clock ()
tick :: Clock ()
clockProcess :: Clock ()
processAction :: ClockAction -> Clock ()
arcStart :: (Time, Time) -> Time
arcEnd :: (Time, Time) -> Time
beatToCycles :: ClockConfig -> Double -> Double
cyclesToBeat :: ClockConfig -> Double -> Double
getSessionState :: ClockRef -> IO SessionState
getZeroedSessionState :: ClockConfig -> ClockRef -> IO SessionState
getTempo :: SessionState -> IO Time
setTempoCPS :: Time -> Micros -> ClockConfig -> SessionState -> IO ()
timeAtBeat :: ClockConfig -> SessionState -> Double -> IO Micros
timeToCycles :: ClockConfig -> SessionState -> Micros -> IO Time
cyclesToTime :: ClockConfig -> SessionState -> Time -> IO Micros
linkToOscTime :: ClockRef -> Micros -> IO Time
addMicrosToOsc :: Micros -> Time -> Time
logicalTime :: ClockConfig -> Micros -> Int64 -> Micros
getBPM :: ClockRef -> IO Time
getCPS :: ClockConfig -> ClockRef -> IO Time
getCycleTime :: ClockConfig -> ClockRef -> IO Time
resetClock :: ClockRef -> IO ()
setClock :: ClockRef -> Time -> IO ()
setBPM :: ClockRef -> Time -> IO ()
setCPS :: ClockConfig -> ClockRef -> Time -> IO ()
setNudge :: ClockRef -> Double -> IO ()
clockOnce :: TickAction -> ClockConfig -> ClockRef -> IO ()
disableLink :: ClockRef -> IO ()
enableLink :: ClockRef -> IO ()
instance GHC.Internal.Show.Show Sound.Tidal.Clock.ClockState
