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


-- | Bindings for the JACK Audio Connection Kit
--   
--   Bindings for the JACK Audio Connection Kit
--   <a>http://jackaudio.org/</a>. It has support both for PCM audio and
--   MIDI handling.
--   
--   In order to adapt to your system, you may have to disable pkgConfig or
--   jackFree cabal flags.
--   
--   You should compile your clients with <tt>ghc --make -O2 -threaded
--   ...</tt>
@package jack
@version 0.7.1.3

module Sound.JACK.Exception
class ToString e
toString :: ToString e => e -> String
toStringWithHead :: All -> String
type All = Status (PortRegister (PortMismatch Errno))
class ThrowsStatus e
status :: ThrowsStatus e => StatusSet -> e
data Status e
Status :: StatusSet -> Status e
NoStatus :: e -> Status e
class ThrowsPortRegister e
portRegister :: ThrowsPortRegister e => e
data PortRegister e
PortRegister :: PortRegister e
NoPortRegister :: e -> PortRegister e
class ThrowsPortMismatch e
portMismatch :: ThrowsPortMismatch e => PortMismatchKind -> e
data PortMismatch e
PortMismatch :: PortMismatchKind -> PortMismatch e
NoPortMismatch :: e -> PortMismatch e
data PortMismatchKind
TypeMismatch :: PortMismatchKind
DirectionMismatch :: PortMismatchKind
class ThrowsErrno e
errno :: ThrowsErrno e => Errno -> e
data Errno e
Errno :: Errno -> Errno e
NoErrno :: e -> Errno e
instance Sound.JACK.Exception.ToString e => Sound.JACK.Exception.ToString (Sound.JACK.Exception.Errno e)
instance Sound.JACK.Exception.ThrowsStatus e => Sound.JACK.Exception.ThrowsStatus (Sound.JACK.Exception.Errno e)
instance Sound.JACK.Exception.ThrowsPortRegister e => Sound.JACK.Exception.ThrowsPortRegister (Sound.JACK.Exception.Errno e)
instance Sound.JACK.Exception.ThrowsPortMismatch e => Sound.JACK.Exception.ThrowsPortMismatch (Sound.JACK.Exception.Errno e)
instance Sound.JACK.Exception.ThrowsErrno (Sound.JACK.Exception.Errno e)
instance Sound.JACK.Exception.ThrowsErrno e => Sound.JACK.Exception.ThrowsErrno (Sound.JACK.Exception.Status e)
instance Sound.JACK.Exception.ThrowsErrno e => Sound.JACK.Exception.ThrowsErrno (Sound.JACK.Exception.PortRegister e)
instance Sound.JACK.Exception.ThrowsErrno e => Sound.JACK.Exception.ThrowsErrno (Sound.JACK.Exception.PortMismatch e)
instance Sound.JACK.Exception.ThrowsErrno Foreign.C.Error.Errno
instance Sound.JACK.Exception.ThrowsPortMismatch e => Sound.JACK.Exception.ThrowsPortMismatch (Sound.JACK.Exception.Status e)
instance Sound.JACK.Exception.ThrowsPortMismatch e => Sound.JACK.Exception.ThrowsPortMismatch (Sound.JACK.Exception.PortRegister e)
instance Sound.JACK.Exception.ThrowsPortMismatch (Sound.JACK.Exception.PortMismatch e)
instance Sound.JACK.Exception.ToString e => Sound.JACK.Exception.ToString (Sound.JACK.Exception.PortMismatch e)
instance Sound.JACK.Exception.ThrowsStatus e => Sound.JACK.Exception.ThrowsStatus (Sound.JACK.Exception.PortMismatch e)
instance Sound.JACK.Exception.ThrowsPortRegister e => Sound.JACK.Exception.ThrowsPortRegister (Sound.JACK.Exception.PortMismatch e)
instance Sound.JACK.Exception.ToString e => Sound.JACK.Exception.ToString (Sound.JACK.Exception.PortRegister e)
instance Sound.JACK.Exception.ThrowsStatus e => Sound.JACK.Exception.ThrowsStatus (Sound.JACK.Exception.PortRegister e)
instance Sound.JACK.Exception.ThrowsPortRegister (Sound.JACK.Exception.PortRegister e)
instance Sound.JACK.Exception.ThrowsPortRegister e => Sound.JACK.Exception.ThrowsPortRegister (Sound.JACK.Exception.Status e)
instance Sound.JACK.Exception.ToString e => Sound.JACK.Exception.ToString (Sound.JACK.Exception.Status e)
instance Sound.JACK.Exception.ThrowsStatus (Sound.JACK.Exception.Status e)
instance (Data.Bits.Bits w, GHC.Enum.Enum a, GHC.Show.Show a) => Sound.JACK.Exception.ToString (Data.EnumSet.T w a)
instance Sound.JACK.Exception.ToString Foreign.C.Error.Errno


-- | The Jack module defines types and functions that allows you to use the
--   JACK Audio Connection Kit.
module Sound.JACK

-- | Handles of Jack clients
data Client

-- | Constructs a new Jack client.
newClient :: (ThrowsStatus e) => String -> String -> ExceptionalT e IO Client

-- | Creates a new JACK client with the <tt>default</tt> server
newClientDefault :: (ThrowsStatus e) => String -> ExceptionalT e IO Client
disposeClient :: (ThrowsErrno e) => Client -> ExceptionalT e IO ()

-- | Run a block of code with a newly allocated client. Do not use the
--   client outside the block.
withClient :: (ThrowsStatus e) => String -> String -> (Client -> ExceptionalT e IO a) -> ExceptionalT e IO a
withClientDefault :: (ThrowsStatus e) => String -> (Client -> ExceptionalT e IO a) -> ExceptionalT e IO a

-- | closes the given Jack client without causing any trouble (hopefully)
clientClose :: (ThrowsErrno e) => Client -> PortSet -> ExceptionalT e IO ()

-- | activates the given Jack client
activate :: (ThrowsErrno e) => Client -> ExceptionalT e IO ()
deactivate :: (ThrowsErrno e) => Client -> ExceptionalT e IO ()
withActivation :: (ThrowsErrno e) => Client -> ExceptionalT e IO () -> ExceptionalT e IO ()

-- | Jack Port Type
class PortType typ
class Direction dir

-- | Type argument for Jack input ports
data Input

-- | Type argument for Jack output ports
data Output

-- | Type argument for Jack ports where the type of samples transported by
--   the port is unknown.
data UnknownType

-- | Type argument for Jack ports where we do not know whether it is an
--   input or an output port.
data UnknownDirection
data Port typ dir

-- | Better use <a>withPort</a> that also handles freeing the port.
newPort :: (PortType typ, Direction dir, ThrowsPortRegister e) => Client -> String -> ExceptionalT e IO (Port typ dir)
disposePort :: (PortType typ, Direction dir, ThrowsErrno e) => Client -> Port typ dir -> ExceptionalT e IO ()

-- | Creates a new port for the given client and delete it after usage. The
--   port manages audio or MIDI data in input or output direction depending
--   on the Port type. Usually the required port type can be inferred from
--   following actions that use that port.
--   
--   Do not use the port outside the enclosed block.
withPort :: (PortType typ, Direction dir, ThrowsPortRegister e, ThrowsErrno e) => Client -> String -> (Port typ dir -> ExceptionalT e IO a) -> ExceptionalT e IO a

-- | A collection of mixed types of ports. It is mainly needed for freeing
--   all allocated ports.
data PortSet
setOfPort :: (PortType typ, Direction dir) => Port typ dir -> PortSet
setOfPorts :: (PortType typ, Direction dir) => [Port typ dir] -> PortSet
type Process arg = NFrames -> Ptr arg -> IO Errno
connect :: (ThrowsErrno e) => Client -> String -> String -> ExceptionalT e IO ()
disconnect :: (ThrowsErrno e) => Client -> String -> String -> ExceptionalT e IO ()
makeProcess :: Process arg -> IO (FunPtr (Process arg))
setProcess :: (ThrowsErrno e) => Client -> FunPtr (Process arg) -> Ptr arg -> ExceptionalT e IO ()

-- | The callback function must respond in real-time, i.e. in a bounded
--   amout of time. That is, strictly spoken it must not wait for anything,
--   e.g. it must not wait for locks and it must not allocate memory. In
--   Haskell this is practically impossible because even simplest
--   operations allocate memory. If the callback needs to much time, JACK
--   will shut down your client. The best you can do is to hope that
--   nothing evil happens.
withProcess :: (ThrowsErrno e) => Client -> (NFrames -> ExceptionalT Errno IO ()) -> ExceptionalT e IO a -> ExceptionalT e IO a
getBufferSize :: Client -> IO Int
getSampleRate :: Client -> IO Int
lastFrameTime :: Client -> IO NFrames

-- | Create a client registration callback <a>FunPtr</a>.
makeClientRegistration :: ClientRegistration arg -> IO (FunPtr (ClientRegistration arg))

-- | Set the client registration callback.
setClientRegistration :: (ThrowsErrno e) => Client -> FunPtr (ClientRegistration arg) -> Ptr arg -> ExceptionalT e IO ()
withClientRegistration :: (ThrowsErrno e) => Client -> (String -> Bool -> IO ()) -> ExceptionalT e IO a -> ExceptionalT e IO a
data PortId

-- | Create a port registration callback <a>FunPtr</a>.
makePortRegistration :: PortRegistration arg -> IO (FunPtr (PortRegistration arg))

-- | Set the port registration callback.
setPortRegistration :: (ThrowsErrno e) => Client -> FunPtr (PortRegistration arg) -> Ptr arg -> ExceptionalT e IO ()
withPortRegistration :: (ThrowsErrno e) => Client -> (PortId -> Bool -> IO ()) -> ExceptionalT e IO a -> ExceptionalT e IO a

-- | Create a port connect callback <a>FunPtr</a>.
makePortConnect :: PortConnect arg -> IO (FunPtr (PortConnect arg))

-- | Set the port connect callback.
setPortConnect :: (ThrowsErrno e) => Client -> FunPtr (PortConnect arg) -> Ptr arg -> ExceptionalT e IO ()
withPortConnect :: (ThrowsErrno e) => Client -> (PortId -> PortId -> Bool -> IO ()) -> ExceptionalT e IO a -> ExceptionalT e IO a
portById :: Client -> PortId -> IO (Port UnknownType UnknownDirection)
portByName :: Client -> String -> IO (Port UnknownType UnknownDirection)

-- | Return the full port name, including the <tt>client_name:</tt> prefix.
portName :: Port typ dir -> IO String

-- | Return the short port name, not including the <tt>client_name:</tt>
--   prefix.
portShortName :: Port typ dir -> IO String

-- | Return the port aliases, including the <tt>client_name:</tt> prefixes.
--   
--   This is especially useful for external midi devices, as the alias
--   names are usually more descriptive than
--   <tt>system:midi_capture_1</tt>.
portAliases :: Port typ dir -> IO [String]

-- | Returns the names of all existing ports.
getPorts :: Client -> IO [String]

-- | Return all the port names a given port is connected to.
--   
--   This function must not be called from a JACK event callback.
portGetAllConnections :: Client -> Port typ dir -> IO [String]
narrowPort :: (PortType typ, Direction dir, ThrowsPortMismatch e) => Port UnknownType UnknownDirection -> ExceptionalT e IO (Port typ dir)
narrowPortType :: (PortType typ, ThrowsPortMismatch e) => Port UnknownType dir -> ExceptionalT e IO (Port typ dir)
narrowPortDirection :: (Direction dir, ThrowsPortMismatch e) => Port typ UnknownDirection -> ExceptionalT e IO (Port typ dir)
switchUnknownTypePort :: (ThrowsPortMismatch e) => Port UnknownType dir -> (Port CFloat dir -> ExceptionalT e IO a) -> (Port EventBuffer dir -> ExceptionalT e IO a) -> ExceptionalT e IO a
switchUnknownDirectionPort :: (ThrowsPortMismatch e) => Port typ UnknownDirection -> (Port typ Input -> ExceptionalT e IO a) -> (Port typ Output -> ExceptionalT e IO a) -> ExceptionalT e IO a

-- | represents absolute frame time
newtype NFrames
NFrames :: Word32 -> NFrames
nframesIndices :: NFrames -> [NFrames]
nframesBounds :: NFrames -> (NFrames, NFrames)

-- | <i>Deprecated: Write your own function instead.</i>
quit :: MVar () -> Client -> PortSet -> IO ()

-- | <i>Deprecated: Write your own function instead.</i>
waitForBreakAndClose :: Client -> PortSet -> IO ()
waitForBreak :: IO ()
handleExceptions :: ExceptionalT All IO () -> IO ()
instance Data.Semigroup.Semigroup Sound.JACK.PortSet
instance GHC.Base.Monoid Sound.JACK.PortSet
instance Sound.JACK.Direction Sound.JACK.FFI.Input
instance Sound.JACK.Direction Sound.JACK.FFI.Output

module Sound.JACK.MIDI

-- | Represents a raw JACK MIDI event
data RawEvent

-- | Smart constructor for a raw MIDI event.
rawEvent :: NFrames -> ByteString -> RawEvent
rawEventTime :: RawEvent -> NFrames
rawEventBuffer :: RawEvent -> ByteString

-- | Converts high level MIDI Event transformation functions into raw MIDI
--   Event transformation functions
toRawEventFunction :: (NFrames -> (NFrames, T) -> IO (NFrames, T)) -> (NFrames -> RawEvent -> IO RawEvent)
type Port = Port EventBuffer
withPort :: (Direction dir, ThrowsPortRegister e, ThrowsErrno e) => Client -> String -> (Port dir -> ExceptionalT e IO a) -> ExceptionalT e IO a

-- | sets the process loop of the JACK Client
withProcess :: (ThrowsErrno e) => Client -> Port Input -> (NFrames -> RawEvent -> IO RawEvent) -> Port Output -> ExceptionalT e IO a -> ExceptionalT e IO a
data Buffer dir
getBuffer :: Direction dir => Port dir -> NFrames -> IO (Buffer dir)
clearBuffer :: Buffer Output -> IO ()

-- | reads all available MIDI Events on the given PortBuffer
readRawEvents :: (ThrowsErrno e) => Buffer Input -> ExceptionalT e IO [RawEvent]

-- | writes a MIDI event to the PortBuffer of a MIDI output or throws
--   eNOBUFS if JackMIDI.buffer is full
writeRawEvent :: (ThrowsErrno e) => Buffer Output -> RawEvent -> ExceptionalT e IO ()
readRawEventsFromPort :: (ThrowsErrno e) => Port Input -> NFrames -> ExceptionalT e IO [RawEvent]

-- | Clears an output buffer and writes a sequence of events to it. That
--   is, you must only call this function once per callback.
writeRawEventsToPort :: (ThrowsErrno e) => Port Output -> NFrames -> [RawEvent] -> ExceptionalT e IO ()
writeEvent :: (ThrowsErrno e) => Buffer Output -> NFrames -> T -> ExceptionalT e IO ()

-- | Reads midi events from an input buffer and converts them to a
--   high-level representation. Messages are simply ignored if they cannot
--   be parsed.
readEventsFromPort :: (ThrowsErrno e) => Port Input -> NFrames -> ExceptionalT e IO (T NFrames T)

-- | Clears an output buffer and writes a sequence of events to it. That
--   is, you must only call this function once per callback.
writeEventsToPort :: (ThrowsErrno e) => Port Output -> NFrames -> T NFrames T -> ExceptionalT e IO ()

-- | Creates an input and an output, and transforms all input events into
--   output events using the given function
main :: (NFrames -> (NFrames, T) -> IO (NFrames, T)) -> IO ()

-- | Creates an input and an output, and transforms all raw input events
--   into raw output events using the given function
mainRaw :: (NFrames -> RawEvent -> IO RawEvent) -> IO ()

module Sound.JACK.Audio
type Sample = CFloat
type Port = Port Sample
withPort :: (Direction dir, ThrowsPortRegister e, ThrowsErrno e) => Client -> String -> (Port dir -> ExceptionalT e IO a) -> ExceptionalT e IO a
withProcessMono :: (ThrowsErrno e) => Client -> Port Input -> (Sample -> IO Sample) -> Port Output -> ExceptionalT e IO a -> ExceptionalT e IO a
withProcessStereo :: (ThrowsErrno e) => Client -> Port Input -> Port Input -> ((Sample, Sample) -> IO (Sample, Sample)) -> Port Output -> Port Output -> ExceptionalT e IO a -> ExceptionalT e IO a
getBufferPtr :: (Direction dir) => Port dir -> NFrames -> IO (Ptr Sample)
getBufferArray :: (Direction dir) => Port dir -> NFrames -> IO (StorableArray NFrames Sample)
mainMono :: (Sample -> IO Sample) -> IO ()
mainStereo :: ((Sample, Sample) -> IO (Sample, Sample)) -> IO ()
